import { type PropsWithChildren } from "react"; import { useBoolean } from "usehooks-ts"; import { Button } from "@/components/ui/button/button"; import Card from "@/components/ui/card/card"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { useUserDepartmentQuery } from "@/services/eva-display/user-department/user-department.service"; import { CustomerInfoSelectProvider, useCustomerInfoSelectCtx, } from "./customer-info-select.context"; interface CustomerInfoSelectProps { children: (variables: { showUserSelect: () => void; isShowUserSelect: boolean; }) => React.ReactNode; onChange: (value: string) => void; value: string | null; defaultOpen?: boolean; } export const CustomerInfoSelect = (props: CustomerInfoSelectProps) => { const dropdownBoolean = useBoolean(props.defaultOpen ?? false); return (
{props.children({ showUserSelect: dropdownBoolean.setTrue, isShowUserSelect: dropdownBoolean.value, })}
); }; export const CustomerInfoSelectInfoBox = (props: PropsWithChildren) => { const { isShowDropdown } = useCustomerInfoSelectCtx(); if (isShowDropdown) return null; return (
{props.children}
); }; interface CustomerInfoSelectInfoBoxPropertyProps { title: string; value: string; } export const CustomerInfoSelectInfoBoxProperty = ( props: CustomerInfoSelectInfoBoxPropertyProps, ) => { return (
{props.title}
{props.value}
); }; interface CustomerInfoSelectDropdownProps {} export const CustomerInfoSelectDropdown = ( _props: CustomerInfoSelectDropdownProps, ) => { const userDepartmentQuery = useUserDepartmentQuery(); const { isShowDropdown, setShowDropdown, onChange, value } = useCustomerInfoSelectCtx(); if (!isShowDropdown) return null; return (
); };