Files
cal.diy/packages/platform/atoms/hooks/useAtomsContext.ts
T
Morgan 1263519973 chore: add i18n to atoms (#15698)
* chore: add i18n to atoms

* fixup! chore: add i18n to atoms

* fixup! fixup! chore: add i18n to atoms

* fixup! Merge branch 'platform-atoms-i18n' of github.com:calcom/cal.com into platform-atoms-i18n

* fixup! Merge branch 'main' into platform-atoms-i18n
2024-07-10 12:34:41 +00:00

42 lines
1.1 KiB
TypeScript

import { createContext, useContext } from "react";
import type { translationKeys, CalProviderLanguagesType } from "../cal-provider/CalProvider";
import type http from "../lib/http";
export interface IAtomsContextOptions {
refreshUrl?: string;
apiUrl: string;
}
export interface IAtomsContext {
clientId: string;
accessToken?: string;
options: IAtomsContextOptions;
error?: string;
getClient: () => typeof http | void;
refreshToken?: string;
isRefreshing?: boolean;
isAuth: boolean;
isValidClient: boolean;
isInit: boolean;
t: (key: string, values: Record<string, string | number | undefined | null>) => string;
i18n: {
language: CalProviderLanguagesType;
defaultLocale: CalProviderLanguagesType;
locales: CalProviderLanguagesType[];
exists: (key: translationKeys | string) => boolean;
};
}
export const AtomsContext = createContext({
clientId: "",
accessToken: "",
options: { refreshUrl: "", apiUrl: "" },
error: "",
getClient: () => {
return;
},
} as IAtomsContext);
export const useAtomsContext = () => useContext(AtomsContext);