mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat: typeing AppIntlProvider
This commit is contained in:
@@ -1,12 +1,31 @@
|
||||
// @ts-nocheck
|
||||
import React, { createContext } from 'react';
|
||||
|
||||
const AppIntlContext = createContext();
|
||||
interface AppIntlContextValue {
|
||||
currentLocale: string;
|
||||
direction: 'rtl' | 'ltr';
|
||||
isRTL: boolean;
|
||||
isLTR: boolean;
|
||||
}
|
||||
|
||||
const AppIntlContext = createContext<AppIntlContextValue>(
|
||||
{} as AppIntlContextValue,
|
||||
);
|
||||
|
||||
interface AppIntlProviderProps {
|
||||
currentLocale: string;
|
||||
isRTL: boolean;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Application intl provider.
|
||||
*/
|
||||
function AppIntlProvider({ currentLocale, isRTL, children }) {
|
||||
function AppIntlProvider({
|
||||
currentLocale,
|
||||
isRTL,
|
||||
children,
|
||||
}: AppIntlProviderProps) {
|
||||
const provider = {
|
||||
currentLocale,
|
||||
isRTL,
|
||||
@@ -21,6 +40,7 @@ function AppIntlProvider({ currentLocale, isRTL, children }) {
|
||||
);
|
||||
}
|
||||
|
||||
const useAppIntlContext = () => React.useContext(AppIntlContext);
|
||||
const useAppIntlContext = () =>
|
||||
React.useContext<AppIntlContextValue>(AppIntlContext);
|
||||
|
||||
export { AppIntlProvider, useAppIntlContext };
|
||||
|
||||
Reference in New Issue
Block a user