diff --git a/eslint.config.mjs b/eslint.config.mjs index 719cea2b..fa167c8d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,6 +1,6 @@ -import { dirname } from "path"; -import { fileURLToPath } from "url"; -import { FlatCompat } from "@eslint/eslintrc"; +import { dirname } from 'path'; +import { fileURLToPath } from 'url'; +import { FlatCompat } from '@eslint/eslintrc'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -10,14 +10,14 @@ const compat = new FlatCompat({ }); const eslintConfig = [ - ...compat.extends("next/core-web-vitals", "next/typescript"), + ...compat.extends('next/core-web-vitals', 'next/typescript'), { ignores: [ - "node_modules/**", - ".next/**", - "out/**", - "build/**", - "next-env.d.ts", + 'node_modules/**', + '.next/**', + 'out/**', + 'build/**', + 'next-env.d.ts', ], }, ]; diff --git a/package-lock.json b/package-lock.json index e1f28d3e..33b7c640 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,6 +39,7 @@ "eslint": "^9", "eslint-config-next": "15.5.3", "husky": "^9.1.7", + "prettier": "^3.6.2", "tailwindcss": "^4", "typescript": "^5" } @@ -5669,6 +5670,22 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", diff --git a/package.json b/package.json index b371e4e7..10fe9598 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "next build --turbopack", "start": "next start", "lint": "eslint", - "prepare": "husky" + "prepare": "husky", + "format": "prettier --write ." }, "dependencies": { "@tanstack/match-sorter-utils": "^8.19.4", @@ -41,6 +42,7 @@ "eslint": "^9", "eslint-config-next": "15.5.3", "husky": "^9.1.7", + "prettier": "^3.6.2", "tailwindcss": "^4", "typescript": "^5" } diff --git a/postcss.config.mjs b/postcss.config.mjs index c7bcb4b1..ba720fe5 100644 --- a/postcss.config.mjs +++ b/postcss.config.mjs @@ -1,5 +1,5 @@ const config = { - plugins: ["@tailwindcss/postcss"], + plugins: ['@tailwindcss/postcss'], }; export default config; diff --git a/src/app/globals.css b/src/app/globals.css index 97be6978..c3d05c67 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -3,10 +3,10 @@ @import '../styles/daisyui.css'; @plugin "daisyui/theme" { - name: "lti"; + name: 'lti'; default: false; prefersdark: false; - color-scheme: "light"; + color-scheme: 'light'; --color-base-100: oklch(98% 0.001 106.423); --color-base-200: oklch(97% 0.001 106.424); --color-base-300: oklch(92% 0.003 48.717); @@ -37,8 +37,6 @@ --noise: 0; } - - :root { --color-primary: #1f74bf; } diff --git a/src/app/inventory/adjustment/add/page.tsx b/src/app/inventory/adjustment/add/page.tsx index 3bd64573..e20eedfc 100644 --- a/src/app/inventory/adjustment/add/page.tsx +++ b/src/app/inventory/adjustment/add/page.tsx @@ -1,11 +1,11 @@ -import InventoryAdjustmentForm from "@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm"; +import InventoryAdjustmentForm from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm'; const CreateInventoryAdjustment = () => { return ( -
- +
+
); -} +}; -export default CreateInventoryAdjustment; \ No newline at end of file +export default CreateInventoryAdjustment; diff --git a/src/app/inventory/adjustment/detail/layout.tsx b/src/app/inventory/adjustment/detail/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/inventory/adjustment/detail/layout.tsx +++ b/src/app/inventory/adjustment/detail/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/inventory/adjustment/detail/page.tsx b/src/app/inventory/adjustment/detail/page.tsx index 5e96c86a..acb9f8db 100644 --- a/src/app/inventory/adjustment/detail/page.tsx +++ b/src/app/inventory/adjustment/detail/page.tsx @@ -7,11 +7,12 @@ import type { InventoryAdjustment } from '@/types/api/inventory/adjustment'; const DetailInventoryAdjustment = () => { const router = useRouter(); - const [inventoryAdjustment, setInventoryAdjustment] = useState(null); + const [inventoryAdjustment, setInventoryAdjustment] = + useState(null); // Ambil data dari router state useEffect(() => { - console.log("Router State"); + console.log('Router State'); console.log(window.history.state); const state = window.history.state?.usr as | { inventoryAdjustment?: InventoryAdjustment } @@ -24,20 +25,20 @@ const DetailInventoryAdjustment = () => { }, [router]); const finalData = inventoryAdjustment; - - console.log("Final Data"); + + console.log('Final Data'); console.log(finalData); if (!finalData) { return ( -
- +
+
); } return ( -
+
); diff --git a/src/app/master-data/customer/add/page.tsx b/src/app/master-data/customer/add/page.tsx index a1096f02..dd75c679 100644 --- a/src/app/master-data/customer/add/page.tsx +++ b/src/app/master-data/customer/add/page.tsx @@ -1,11 +1,11 @@ -import CustomerForm from "@/components/pages/master-data/customer/form/CustomerForm"; +import CustomerForm from '@/components/pages/master-data/customer/form/CustomerForm'; const AddCustomer = () => { return ( -
- +
+
); -} +}; -export default AddCustomer; \ No newline at end of file +export default AddCustomer; diff --git a/src/app/master-data/customer/detail/page.tsx b/src/app/master-data/customer/detail/page.tsx index 263458c2..d778f83b 100644 --- a/src/app/master-data/customer/detail/page.tsx +++ b/src/app/master-data/customer/detail/page.tsx @@ -1,45 +1,47 @@ -'use client' +'use client'; -import { useRouter, useSearchParams } from "next/navigation"; -import useSWR from "swr"; +import { useRouter, useSearchParams } from 'next/navigation'; +import useSWR from 'swr'; import { CustomerApi } from '@/services/api/master-data'; -import { isResponseError, isResponseSuccess } from "@/lib/api-helper"; -import CustomerForm from "@/components/pages/master-data/customer/form/CustomerForm"; +import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import CustomerForm from '@/components/pages/master-data/customer/form/CustomerForm'; const CustomerDetail = () => { const router = useRouter(); const searchParams = useSearchParams(); - const costumerId = searchParams.get("customerId"); + const costumerId = searchParams.get('customerId'); const { data: costumer, isLoading: isLoadingCostumer } = useSWR( costumerId, (id: number) => CustomerApi.getSingle(id) ); - if(!costumerId){ + if (!costumerId) { router.back(); return ( -
- +
+
); } - if(!isLoadingCostumer && (!costumer || isResponseError(costumer))){ - router.replace("/404"); + if (!isLoadingCostumer && (!costumer || isResponseError(costumer))) { + router.replace('/404'); return; } return ( -
- {isLoadingCostumer && } +
+ {isLoadingCostumer && ( + + )} {!isLoadingCostumer && isResponseSuccess(costumer) && ( - + )}
- ) + ); }; export default CustomerDetail; diff --git a/src/app/master-data/customer/page.tsx b/src/app/master-data/customer/page.tsx index b80401f1..8aec1088 100644 --- a/src/app/master-data/customer/page.tsx +++ b/src/app/master-data/customer/page.tsx @@ -1,11 +1,11 @@ -import CustomersTable from "@/components/pages/master-data/customer/CustomersTable"; +import CustomersTable from '@/components/pages/master-data/customer/CustomersTable'; const Customer = () => { return ( -
+
- ) + ); }; -export default Customer; \ No newline at end of file +export default Customer; diff --git a/src/app/master-data/flock/add/page.tsx b/src/app/master-data/flock/add/page.tsx index 5ee3958e..d038d414 100644 --- a/src/app/master-data/flock/add/page.tsx +++ b/src/app/master-data/flock/add/page.tsx @@ -1,11 +1,11 @@ -import FlockForm from "@/components/pages/master-data/flock/form/FlockForm"; +import FlockForm from '@/components/pages/master-data/flock/form/FlockForm'; const AddFlock = () => { return ( -
+
); -} +}; export default AddFlock; diff --git a/src/app/master-data/flock/detail/edit/page.tsx b/src/app/master-data/flock/detail/edit/page.tsx index c9651727..babc6653 100644 --- a/src/app/master-data/flock/detail/edit/page.tsx +++ b/src/app/master-data/flock/detail/edit/page.tsx @@ -1,10 +1,10 @@ -'use client' +'use client'; -import FlockForm from "@/components/pages/master-data/flock/form/FlockForm"; -import { isResponseError, isResponseSuccess } from "@/lib/api-helper"; -import { FlockApi } from "@/services/api/master-data"; -import { useRouter, useSearchParams } from "next/navigation"; -import useSWR from "swr"; +import FlockForm from '@/components/pages/master-data/flock/form/FlockForm'; +import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import { FlockApi } from '@/services/api/master-data'; +import { useRouter, useSearchParams } from 'next/navigation'; +import useSWR from 'swr'; const FlockEdit = () => { const router = useRouter(); @@ -44,6 +44,6 @@ const FlockEdit = () => { )}
); -} +}; -export default FlockEdit; \ No newline at end of file +export default FlockEdit; diff --git a/src/app/master-data/flock/detail/layout.tsx b/src/app/master-data/flock/detail/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/master-data/flock/detail/layout.tsx +++ b/src/app/master-data/flock/detail/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/master-data/flock/detail/page.tsx b/src/app/master-data/flock/detail/page.tsx index 8a805911..e9620d33 100644 --- a/src/app/master-data/flock/detail/page.tsx +++ b/src/app/master-data/flock/detail/page.tsx @@ -1,10 +1,10 @@ -'use client' +'use client'; -import FlockForm from "@/components/pages/master-data/flock/form/FlockForm"; -import { isResponseError, isResponseSuccess } from "@/lib/api-helper"; -import { FlockApi } from "@/services/api/master-data"; -import { useRouter, useSearchParams } from "next/navigation"; -import useSWR from "swr"; +import FlockForm from '@/components/pages/master-data/flock/form/FlockForm'; +import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import { FlockApi } from '@/services/api/master-data'; +import { useRouter, useSearchParams } from 'next/navigation'; +import useSWR from 'swr'; const FlockDetail = () => { const router = useRouter(); @@ -14,33 +14,36 @@ const FlockDetail = () => { const flockId = searchParams.get('flockId'); // Fetch Data - const { data: flock, isLoading: isLoadingFlock } = useSWR(flockId, (id: number) => FlockApi.getSingle(id)); + const { data: flock, isLoading: isLoadingFlock } = useSWR( + flockId, + (id: number) => FlockApi.getSingle(id) + ); - if(!flockId){ + if (!flockId) { router.back(); return ( -
- +
+
); } - if(!isLoadingFlock && (!flock || isResponseError(flock))){ + if (!isLoadingFlock && (!flock || isResponseError(flock))) { router.replace('/404'); return; } return ( -
+
{isLoadingFlock && ( - + )} {!isLoadingFlock && isResponseSuccess(flock) && ( - + )}
); -} +}; -export default FlockDetail; \ No newline at end of file +export default FlockDetail; diff --git a/src/app/master-data/flock/page.tsx b/src/app/master-data/flock/page.tsx index b317091a..76cc32c1 100644 --- a/src/app/master-data/flock/page.tsx +++ b/src/app/master-data/flock/page.tsx @@ -1,11 +1,11 @@ -import FlockTable from "@/components/pages/master-data/flock/FlocksTable"; +import FlockTable from '@/components/pages/master-data/flock/FlocksTable'; const Flock = () => { return ( -
- +
+
- ); -} + ); +}; export default Flock; diff --git a/src/app/master-data/product-category/add/page.tsx b/src/app/master-data/product-category/add/page.tsx index 0993ba7a..2331159e 100644 --- a/src/app/master-data/product-category/add/page.tsx +++ b/src/app/master-data/product-category/add/page.tsx @@ -1,11 +1,11 @@ -import ProductCategoryForm from "@/components/pages/master-data/product-category/form/ProductCategoryForm"; +import ProductCategoryForm from '@/components/pages/master-data/product-category/form/ProductCategoryForm'; const AddProductCategory = () => { return ( -
+
); }; -export default AddProductCategory; \ No newline at end of file +export default AddProductCategory; diff --git a/src/app/master-data/product-category/detail/edit/page.tsx b/src/app/master-data/product-category/detail/edit/page.tsx index 6bc10644..4cb7eb5a 100644 --- a/src/app/master-data/product-category/detail/edit/page.tsx +++ b/src/app/master-data/product-category/detail/edit/page.tsx @@ -9,39 +9,44 @@ import { ProductCategoryApi } from '@/services/api/master-data'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; const ProductCategoryEdit = () => { - const router = useRouter(); - const searchParams = useSearchParams(); + const router = useRouter(); + const searchParams = useSearchParams(); - const productCategoryId = searchParams.get('productCategoryId'); + const productCategoryId = searchParams.get('productCategoryId'); - const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR( - productCategoryId, - (id: number) => ProductCategoryApi.getSingle(id) - ); + const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR( + productCategoryId, + (id: number) => ProductCategoryApi.getSingle(id) + ); - if (!productCategoryId) { - router.back(); - - return ( -
- -
- ); - } - - if (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) { - router.replace('/404'); - return; - } + if (!productCategoryId) { + router.back(); return ( -
- {isLoadingProductCategory && } - {!isLoadingProductCategory && isResponseSuccess(productCategory) && ( - - )} -
+
+ +
); -} + } -export default ProductCategoryEdit; \ No newline at end of file + if ( + !isLoadingProductCategory && + (!productCategory || isResponseError(productCategory)) + ) { + router.replace('/404'); + return; + } + + return ( +
+ {isLoadingProductCategory && ( + + )} + {!isLoadingProductCategory && isResponseSuccess(productCategory) && ( + + )} +
+ ); +}; + +export default ProductCategoryEdit; diff --git a/src/app/master-data/product-category/detail/page.tsx b/src/app/master-data/product-category/detail/page.tsx index cba06fdb..c1a21aaf 100644 --- a/src/app/master-data/product-category/detail/page.tsx +++ b/src/app/master-data/product-category/detail/page.tsx @@ -29,16 +29,24 @@ const ProductCategoryDetail = () => { ); } - if (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) { + if ( + !isLoadingProductCategory && + (!productCategory || isResponseError(productCategory)) + ) { router.replace('/404'); return; } return (
- {isLoadingProductCategory && } + {isLoadingProductCategory && ( + + )} {!isLoadingProductCategory && isResponseSuccess(productCategory) && ( - + )}
); diff --git a/src/app/master-data/product-category/page.tsx b/src/app/master-data/product-category/page.tsx index 5ec6d555..78a4fda3 100644 --- a/src/app/master-data/product-category/page.tsx +++ b/src/app/master-data/product-category/page.tsx @@ -1,11 +1,11 @@ -import ProductCategoryTable from "@/components/pages/master-data/product-category/ProductCategoryTable"; +import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable'; const ProductCategory = () => { return ( -
+
); }; -export default ProductCategory; \ No newline at end of file +export default ProductCategory; diff --git a/src/app/master-data/product/add/page.tsx b/src/app/master-data/product/add/page.tsx index 7cc995b6..37f42691 100644 --- a/src/app/master-data/product/add/page.tsx +++ b/src/app/master-data/product/add/page.tsx @@ -2,10 +2,10 @@ import ProductForm from '@/components/pages/master-data/product/form/ProductForm const AddProduct = () => { return ( -
+
); }; -export default AddProduct; \ No newline at end of file +export default AddProduct; diff --git a/src/app/master-data/product/detail/edit/page.tsx b/src/app/master-data/product/detail/edit/page.tsx index 96cfdc42..8916a98e 100644 --- a/src/app/master-data/product/detail/edit/page.tsx +++ b/src/app/master-data/product/detail/edit/page.tsx @@ -13,9 +13,8 @@ const ProductEdit = () => { const productId = searchParams.get('productId'); - const { data: product, isLoading } = useSWR( - productId, - (id: number) => ProductApi.getSingle(id) + const { data: product, isLoading } = useSWR(productId, (id: number) => + ProductApi.getSingle(id) ); if (!productId) { @@ -42,4 +41,4 @@ const ProductEdit = () => { ); }; -export default ProductEdit; \ No newline at end of file +export default ProductEdit; diff --git a/src/app/master-data/product/detail/page.tsx b/src/app/master-data/product/detail/page.tsx index 916a44d0..34743e1f 100644 --- a/src/app/master-data/product/detail/page.tsx +++ b/src/app/master-data/product/detail/page.tsx @@ -13,9 +13,8 @@ const ProductDetail = () => { const productId = searchParams.get('productId'); - const { data: product, isLoading } = useSWR( - productId, - (id: number) => ProductApi.getSingle(id) + const { data: product, isLoading } = useSWR(productId, (id: number) => + ProductApi.getSingle(id) ); if (!productId) { @@ -42,4 +41,4 @@ const ProductDetail = () => { ); }; -export default ProductDetail; \ No newline at end of file +export default ProductDetail; diff --git a/src/app/master-data/product/page.tsx b/src/app/master-data/product/page.tsx index 6014aeb9..a385d411 100644 --- a/src/app/master-data/product/page.tsx +++ b/src/app/master-data/product/page.tsx @@ -1,11 +1,11 @@ -import ProductsTable from "@/components/pages/master-data/product/ProductTable"; +import ProductsTable from '@/components/pages/master-data/product/ProductTable'; const Product = () => { return ( -
- +
+
); }; -export default Product; \ No newline at end of file +export default Product; diff --git a/src/app/master-data/supplier/add/page.tsx b/src/app/master-data/supplier/add/page.tsx index 8a95c3c6..37df33b0 100644 --- a/src/app/master-data/supplier/add/page.tsx +++ b/src/app/master-data/supplier/add/page.tsx @@ -8,4 +8,4 @@ const AddSupplier = () => { ); }; -export default AddSupplier; \ No newline at end of file +export default AddSupplier; diff --git a/src/app/master-data/supplier/detail/page.tsx b/src/app/master-data/supplier/detail/page.tsx index 433fa043..a34ad72e 100644 --- a/src/app/master-data/supplier/detail/page.tsx +++ b/src/app/master-data/supplier/detail/page.tsx @@ -46,4 +46,4 @@ const SupplierDetail = () => { ); }; -export default SupplierDetail; \ No newline at end of file +export default SupplierDetail; diff --git a/src/app/master-data/supplier/page.tsx b/src/app/master-data/supplier/page.tsx index 1f54bd0d..8000be0a 100644 --- a/src/app/master-data/supplier/page.tsx +++ b/src/app/master-data/supplier/page.tsx @@ -1,4 +1,4 @@ -import SuppliersTable from "@/components/pages/master-data/supplier/SupplierTable"; +import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable'; const Supplier = () => { return ( diff --git a/src/app/production/chickin/add/layout.tsx b/src/app/production/chickin/add/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/production/chickin/add/layout.tsx +++ b/src/app/production/chickin/add/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/production/chickin/detail/layout.tsx b/src/app/production/chickin/detail/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/production/chickin/detail/layout.tsx +++ b/src/app/production/chickin/detail/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/production/chickin/detail/page.tsx b/src/app/production/chickin/detail/page.tsx index 96647c55..be8c5332 100644 --- a/src/app/production/chickin/detail/page.tsx +++ b/src/app/production/chickin/detail/page.tsx @@ -20,7 +20,7 @@ import useSWR from 'swr'; /** * TODO: Refactor code - pindahin detail ke reuseable component - * setelah implement approval and reject + * setelah implement approval and reject */ const DetailChickin = () => { @@ -43,9 +43,8 @@ const DetailChickin = () => { // chickin.data?.approval.step_number == 1 ? false : true true ); - const [isRejectedDisabled, setIsRejectedDisabled] = useState( - !isApprovedDisabled - ); + const [isRejectedDisabled, setIsRejectedDisabled] = + useState(!isApprovedDisabled); const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>( !isApprovedDisabled ? 'APPROVED' : 'REJECTED' ); @@ -264,7 +263,8 @@ const DetailChickin = () => { Delete - + )} ); }; diff --git a/src/components/pages/ApprovalSteps.tsx b/src/components/pages/ApprovalSteps.tsx index 184b3f20..daac4ab0 100644 --- a/src/components/pages/ApprovalSteps.tsx +++ b/src/components/pages/ApprovalSteps.tsx @@ -31,21 +31,21 @@ const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => { approval.status === 'APPROVED' ? 'success' : approval.status === 'REJECTED' - ? 'error' - : approval.status === 'WAITING' - ? 'warning' - : undefined; + ? 'error' + : approval.status === 'WAITING' + ? 'warning' + : undefined; const stepItemIcon = approval.status === 'APPROVED' ? 'material-symbols:check-rounded' : approval.status === 'REJECTED' - ? 'material-symbols:close-rounded' - : approval.status === 'WAITING' - ? 'pajamas:dash-circle' - : approval.logs && approval.logs.length > 0 - ? 'material-symbols:info-outline-rounded' - : 'bxs:hourglass'; + ? 'material-symbols:close-rounded' + : approval.status === 'WAITING' + ? 'pajamas:dash-circle' + : approval.logs && approval.logs.length > 0 + ? 'material-symbols:info-outline-rounded' + : 'bxs:hourglass'; return ( { }); // Fetch Data - const { - data: inventoryAdjustments, - isLoading, - } = useSWR( + const { data: inventoryAdjustments, isLoading } = useSWR( `${inventoryAdjustmentApi.basePath}${getTableFilterQueryString()}`, inventoryAdjustmentApi.getAllFetcher ); @@ -113,8 +106,8 @@ const InventoryAdjustmentTable = () => { type === 'INCREASE' ? 'Peningkatan' : type === 'DECREASE' - ? 'Penurunan' - : '-'; + ? 'Penurunan' + : '-'; return (
{
-
- @@ -211,7 +209,7 @@ const InventoryAdjustmentTable = () => { value: tableFilterState.pageSize, }} onChange={pageSizeChangeHandler} - className={{ wrapper: 'max-w-28' }} + className={{ wrapper: 'min-w-28' }} />
diff --git a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts index d7a0ae0a..0a6dc1f9 100644 --- a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts +++ b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts @@ -4,24 +4,21 @@ export const InventoryAdjustmentFormSchema = Yup.object({ product_category: Yup.object({ value: Yup.number().required('ID Kategori Produk wajib diisi!'), label: Yup.string().required('Nama Kategori Produk wajib diisi!'), - }) - .nullable(), + }).nullable(), product_category_id: Yup.number().nullable(), product: Yup.object({ value: Yup.number().required('ID Produk wajib diisi!'), label: Yup.string().required('Nama Produk wajib diisi!'), - }) - .nullable(), + }).nullable(), product_id: Yup.number().nullable(), warehouse: Yup.object({ value: Yup.number().required('ID Gudang wajib diisi!'), label: Yup.string().required('Nama Gudang wajib diisi!'), - }) - .nullable(), + }).nullable(), warehouse_id: Yup.number().nullable(), diff --git a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx index 9a19ced1..69860be9 100644 --- a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx +++ b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx @@ -51,9 +51,8 @@ const InventoryAdjustmentForm = ({ // Submit Handler const createInventoryAdjustmentHandler = useCallback( async (payload: CreateInventoryAdjustmentPayload) => { - const createInventoryAdjustmentRes = await inventoryAdjustmentApi.create( - payload - ); + const createInventoryAdjustmentRes = + await inventoryAdjustmentApi.create(payload); if (isResponseError(createInventoryAdjustmentRes)) { setInventoryAdjustmentFormErrorMessage( @@ -68,7 +67,9 @@ const InventoryAdjustmentForm = ({ [router] ); - const formikInitialValues = useMemo>(() => { + const formikInitialValues = useMemo< + Partial + >(() => { return { product_category_id: initialValues?.product_category?.id ?? 0, product_id: initialValues?.product?.id ?? 0, @@ -185,7 +186,6 @@ const InventoryAdjustmentForm = ({ warehouseChangeHandler(null); }; - const { setValues: formikSetValues } = formik; // Effect @@ -225,7 +225,13 @@ const InventoryAdjustmentForm = ({ const type = initialValues.transaction_type.toLowerCase(); setQuantityLabel(type === 'increase' ? 'Tambah Stok' : 'Kurangi Stok'); } - }, [formik, initialValues, setQuantityLabel, setDisabledProduct, setSelectedProductCategories]); + }, [ + formik, + initialValues, + setQuantityLabel, + setDisabledProduct, + setSelectedProductCategories, + ]); useEffect(() => { formikSetValues(formikInitialValues as InventoryAdjustmentFormValues); }, [formikSetValues, formikInitialValues]); @@ -364,15 +370,19 @@ const InventoryAdjustmentForm = ({ errorMessage={formik.errors.transaction_type as string} variant='radio-primary' required - bottomLabel={formik.values.transaction_type == undefined ? 'Pilih salah satu tipe transaksi' : undefined} + bottomLabel={ + formik.values.transaction_type == undefined + ? 'Pilih salah satu tipe transaksi' + : undefined + } disabled={type === 'detail'} /> {/* Number Input Stock */} - - {/* Text Area Input Reason */}