Files
sorvor-back/components/locationContenxt.tsx
Thanu Poptiphueng 05f3e019a8
All checks were successful
backend-action / build-image (push) Successful in 1m50s
added location element
2024-05-16 12:50:14 +07:00

33 lines
730 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;
}) {
let zone = useState<number | undefined>(undefined);
let province = useState<number | undefined>(undefined);
return (
<LocationContext.Provider value={{ zone, province }}>
{children}
</LocationContext.Provider>
);
}