Files
sorvor-back/components/locationContext.tsx
Thanu Poptiphueng c1a019a461
All checks were successful
backend-action / build-image (push) Successful in 1m9s
lint
2024-05-16 17:26:27 +07:00

33 lines
735 B
TypeScript

"use client";
import {
Dispatch,
ReactNode,
SetStateAction,
createContext,
useState,
} from "react";
type LocationContextType = {
zone: [number | undefined, Dispatch<SetStateAction<number | undefined>>];
province: [number | undefined, Dispatch<SetStateAction<number | undefined>>];
};
export const LocationContext = createContext<LocationContextType | undefined>(
undefined,
);
export default function LocationContextProvider({
children,
}: {
children?: ReactNode;
}) {
const zone = useState<number | undefined>(undefined);
const province = useState<number | undefined>(undefined);
return (
<LocationContext.Provider value={{ zone, province }}>
{children}
</LocationContext.Provider>
);
}