diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx index 07e7b2f..37fdea7 100644 --- a/src/app/(main)/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -12,6 +12,7 @@ import { CameraProvider } from "@/components/Cameras/CameraProvider"; import { UploadProvider } from "@/components/UploadProvider/UploadProvider"; import SessionProviderWrapper from "@/components/SessionProviderWrapper/SessionProviderWrapper"; import QrCodeScannerProvider from "@/components/QrCodeScannerProvider/QrCodeScannerProvider"; +import { I18nProvider } from "@/i18n"; export default async function MainLayout({ children, diff --git a/src/app/(main)/po/page.tsx b/src/app/(main)/po/page.tsx index 77b9b3f..08e0675 100644 --- a/src/app/(main)/po/page.tsx +++ b/src/app/(main)/po/page.tsx @@ -1,7 +1,7 @@ import { preloadClaims } from "@/app/api/claims"; import ClaimSearch from "@/components/ClaimSearch"; import PoSearch from "@/components/PoSearch"; -import { getServerI18n } from "@/i18n"; +import { getServerI18n, I18nProvider } from "@/i18n"; import Add from "@mui/icons-material/Add"; import Button from "@mui/material/Button"; import Stack from "@mui/material/Stack"; @@ -35,9 +35,11 @@ const PurchaseOrder: React.FC = async () => { {t("Create Po")} */} + }> + ); }; diff --git a/src/components/PoDetail/PoInputGrid.tsx b/src/components/PoDetail/PoInputGrid.tsx index 6afb7fb..6eef0aa 100644 --- a/src/components/PoDetail/PoInputGrid.tsx +++ b/src/components/PoDetail/PoInputGrid.tsx @@ -110,7 +110,7 @@ function PoInputGrid({ warehouse, }: Props) { console.log(itemDetail); - const { t } = useTranslation("home"); + const { t } = useTranslation("po"); const apiRef = useGridApiRef(); const [rowModesModel, setRowModesModel] = useState({}); const getRowId = useCallback>( @@ -479,7 +479,7 @@ function PoInputGrid({ stockInLineStatusMap[status] === 9 || stockInLineStatusMap[status] <= 2 || stockInLineStatusMap[status] >= 7 || - (!session?.user?.abilities?.includes("APPROVAL") && stockInLineStatusMap[status] >= 3 && stockInLineStatusMap[status] <= 5) + (!session?.user?.abilities?.includes("APPROVAL") && (stockInLineStatusMap[status] >= 3 || stockInLineStatusMap[status] <= 5)) } // set _isNew to false after posting // or check status diff --git a/src/components/PoSearch/PoSearch.tsx b/src/components/PoSearch/PoSearch.tsx index 3f03cd7..8cdd822 100644 --- a/src/components/PoSearch/PoSearch.tsx +++ b/src/components/PoSearch/PoSearch.tsx @@ -28,14 +28,12 @@ const PoSearch: React.FC = ({ po, warehouse }) => { const searchCriteria: Criterion[] = useMemo(() => { var searchCriteria: Criterion[] = [ { label: t("Code"), paramName: "code", type: "text" }, - // { label: t("Name"), paramName: "name", type: "text" }, + { label: t("Status"), paramName: "status", type: "select", options: ["PENDING", "RECEIVING", "COMPLETED"] }, + { label: t("Escalated"), paramName: "escalated", type: "select", options: [t("Escalated"), t("NotEscalated")] }, ]; return searchCriteria; }, [t, po]); - const {data: session} = useSession(); - - console.log(session); const onDetailClick = useCallback( (po: PoResult) => { @@ -75,7 +73,7 @@ const PoSearch: React.FC = ({ po, warehouse }) => { label: t("Escalated"), renderCell: (params) => { return params.escalated ? : undefined - } + } }, // { // name: "name", @@ -133,10 +131,11 @@ const PoSearch: React.FC = ({ po, warehouse }) => { onSearch={(query) => { setFilteredPo( po.filter((p) => { - return p.code - .toLowerCase() - .includes(query.code.toLowerCase()); - // p.name.toLowerCase().includes(query.name.toLowerCase()) + return ( + p.code.toLowerCase().includes(query.code.toLowerCase()) && + (query.status === "All" || p.status === query.status) && + (query.escalated === "All" || p.escalated === (query.escalated === t("Escalated"))) + ) }) ); }} diff --git a/src/components/UserSearch/UserSearch.tsx b/src/components/UserSearch/UserSearch.tsx index 60e1976..b437900 100644 --- a/src/components/UserSearch/UserSearch.tsx +++ b/src/components/UserSearch/UserSearch.tsx @@ -20,7 +20,7 @@ type SearchQuery = Partial>; type SearchParamNames = keyof SearchQuery; const UserSearch: React.FC = ({ users }) => { - const { t } = useTranslation(); + const { t } = useTranslation("user"); const [filteredUser, setFilteredUser] = useState(users); const router = useRouter(); diff --git a/src/i18n/en/user.json b/src/i18n/en/user.json new file mode 100644 index 0000000..2548c90 --- /dev/null +++ b/src/i18n/en/user.json @@ -0,0 +1,18 @@ +{ + "Create User": "新增用戶", + "User Detail": "用戶詳細資料", + "User Authority": "用戶權限", + "Authority Pool": "權限池", + "Allocated Authority": "已分配權限", + "username": "用戶名稱", + "password": "密碼", + "Confirm Password": "確認密碼", + "Reset": "重置", + "Cancel": "取消", + "Confirm": "確認", + "name": "姓名", + "User ID": "用戶ID", + "User Name": "用戶名稱", + "User Group": "用戶群組", + "Authority": "權限" +} \ No newline at end of file diff --git a/src/i18n/zh/po.json b/src/i18n/zh/po.json new file mode 100644 index 0000000..57e34cb --- /dev/null +++ b/src/i18n/zh/po.json @@ -0,0 +1,16 @@ +{ + "code": "代码", + "status": "状态", + "escalated": "已升级", + "notEscalated": "未升级", + "All": "全部", + "Pending": "待处理", + "Receiving": "接收中", + "Completed": "已完成", + "Purchase Order": "采购订单", + "Details": "详情", + "OrderDate": "订单日期", + "Supplier": "供应商", + "Escalated": "已升级", + "NotEscalated": "未升级" +} \ No newline at end of file