18 lines
717 B
TypeScript
18 lines
717 B
TypeScript
"use client";
|
|
|
|
import { createContext, useContext, useMemo, type ReactNode } from "react";
|
|
import { wording, type WordMode, type Words } from "@peppa/shared/wording";
|
|
|
|
const Ctx = createContext<WordMode>("product");
|
|
|
|
/** PEP-123: the layout tells client components which view the user chose («Продакт» / «Инженер»). */
|
|
export function WordsProvider({ mode, children }: { mode: WordMode; children: ReactNode }) {
|
|
return <Ctx.Provider value={mode}>{children}</Ctx.Provider>;
|
|
}
|
|
|
|
/** Words of the current view for client components; server components call `words()` from lib/auth. */
|
|
export function useWords(): Words {
|
|
const mode = useContext(Ctx);
|
|
return useMemo(() => wording(mode), [mode]);
|
|
}
|