mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore: format code using prettier
This commit is contained in:
+9
-9
@@ -1,6 +1,6 @@
|
|||||||
import { dirname } from "path";
|
import { dirname } from 'path';
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from 'url';
|
||||||
import { FlatCompat } from "@eslint/eslintrc";
|
import { FlatCompat } from '@eslint/eslintrc';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
@@ -10,14 +10,14 @@ const compat = new FlatCompat({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const eslintConfig = [
|
const eslintConfig = [
|
||||||
...compat.extends("next/core-web-vitals", "next/typescript"),
|
...compat.extends('next/core-web-vitals', 'next/typescript'),
|
||||||
{
|
{
|
||||||
ignores: [
|
ignores: [
|
||||||
"node_modules/**",
|
'node_modules/**',
|
||||||
".next/**",
|
'.next/**',
|
||||||
"out/**",
|
'out/**',
|
||||||
"build/**",
|
'build/**',
|
||||||
"next-env.d.ts",
|
'next-env.d.ts',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
const config = {
|
const config = {
|
||||||
plugins: ["@tailwindcss/postcss"],
|
plugins: ['@tailwindcss/postcss'],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
+2
-4
@@ -3,10 +3,10 @@
|
|||||||
@import '../styles/daisyui.css';
|
@import '../styles/daisyui.css';
|
||||||
|
|
||||||
@plugin "daisyui/theme" {
|
@plugin "daisyui/theme" {
|
||||||
name: "lti";
|
name: 'lti';
|
||||||
default: false;
|
default: false;
|
||||||
prefersdark: false;
|
prefersdark: false;
|
||||||
color-scheme: "light";
|
color-scheme: 'light';
|
||||||
--color-base-100: oklch(98% 0.001 106.423);
|
--color-base-100: oklch(98% 0.001 106.423);
|
||||||
--color-base-200: oklch(97% 0.001 106.424);
|
--color-base-200: oklch(97% 0.001 106.424);
|
||||||
--color-base-300: oklch(92% 0.003 48.717);
|
--color-base-300: oklch(92% 0.003 48.717);
|
||||||
@@ -37,8 +37,6 @@
|
|||||||
--noise: 0;
|
--noise: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--color-primary: #1f74bf;
|
--color-primary: #1f74bf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import InventoryAdjustmentForm from "@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm";
|
import InventoryAdjustmentForm from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm';
|
||||||
|
|
||||||
const CreateInventoryAdjustment = () => {
|
const CreateInventoryAdjustment = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4 flex flex-row justify-center">
|
<section className='w-full p-4 flex flex-row justify-center'>
|
||||||
<InventoryAdjustmentForm/>
|
<InventoryAdjustmentForm />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default CreateInventoryAdjustment;
|
export default CreateInventoryAdjustment;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import SuspenseHelper from "@/components/helper/SuspenseHelper"
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
const Layout = ({
|
const Layout = ({
|
||||||
children
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode
|
children: React.ReactNode;
|
||||||
}>) => {
|
}>) => {
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Layout;
|
export default Layout;
|
||||||
@@ -7,11 +7,12 @@ import type { InventoryAdjustment } from '@/types/api/inventory/adjustment';
|
|||||||
|
|
||||||
const DetailInventoryAdjustment = () => {
|
const DetailInventoryAdjustment = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [inventoryAdjustment, setInventoryAdjustment] = useState<InventoryAdjustment | null>(null);
|
const [inventoryAdjustment, setInventoryAdjustment] =
|
||||||
|
useState<InventoryAdjustment | null>(null);
|
||||||
|
|
||||||
// Ambil data dari router state
|
// Ambil data dari router state
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("Router State");
|
console.log('Router State');
|
||||||
console.log(window.history.state);
|
console.log(window.history.state);
|
||||||
const state = window.history.state?.usr as
|
const state = window.history.state?.usr as
|
||||||
| { inventoryAdjustment?: InventoryAdjustment }
|
| { inventoryAdjustment?: InventoryAdjustment }
|
||||||
@@ -25,19 +26,19 @@ const DetailInventoryAdjustment = () => {
|
|||||||
|
|
||||||
const finalData = inventoryAdjustment;
|
const finalData = inventoryAdjustment;
|
||||||
|
|
||||||
console.log("Final Data");
|
console.log('Final Data');
|
||||||
console.log(finalData);
|
console.log(finalData);
|
||||||
|
|
||||||
if (!finalData) {
|
if (!finalData) {
|
||||||
return (
|
return (
|
||||||
<div className="w-full flex flex-row justify-center items-center p-4">
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
<span className="loading loading-spinner loading-xl" />
|
<span className='loading loading-spinner loading-xl' />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4 flex flex-row justify-center">
|
<section className='w-full p-4 flex flex-row justify-center'>
|
||||||
<InventoryAdjustmentForm initialValues={finalData} />
|
<InventoryAdjustmentForm initialValues={finalData} />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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 = () => {
|
const AddCustomer = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4 flex flex-row justify-center">
|
<section className='w-full p-4 flex flex-row justify-center'>
|
||||||
<CustomerForm/>
|
<CustomerForm />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default AddCustomer;
|
export default AddCustomer;
|
||||||
@@ -1,45 +1,47 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import useSWR from "swr";
|
import useSWR from 'swr';
|
||||||
import { CustomerApi } from '@/services/api/master-data';
|
import { CustomerApi } from '@/services/api/master-data';
|
||||||
import { isResponseError, isResponseSuccess } from "@/lib/api-helper";
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import CustomerForm from "@/components/pages/master-data/customer/form/CustomerForm";
|
import CustomerForm from '@/components/pages/master-data/customer/form/CustomerForm';
|
||||||
|
|
||||||
const CustomerDetail = () => {
|
const CustomerDetail = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
const costumerId = searchParams.get("customerId");
|
const costumerId = searchParams.get('customerId');
|
||||||
|
|
||||||
const { data: costumer, isLoading: isLoadingCostumer } = useSWR(
|
const { data: costumer, isLoading: isLoadingCostumer } = useSWR(
|
||||||
costumerId,
|
costumerId,
|
||||||
(id: number) => CustomerApi.getSingle(id)
|
(id: number) => CustomerApi.getSingle(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!costumerId){
|
if (!costumerId) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full flex flex-row justify-center items-center p-4">
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
<span className="loading loading-spinner loading-xl" />
|
<span className='loading loading-spinner loading-xl' />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isLoadingCostumer && (!costumer || isResponseError(costumer))){
|
if (!isLoadingCostumer && (!costumer || isResponseError(costumer))) {
|
||||||
router.replace("/404");
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full p-4 flex flex-row justify-center">
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
{isLoadingCostumer && <span className="loading loading-spinner loading-xl" />}
|
{isLoadingCostumer && (
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
)}
|
||||||
{!isLoadingCostumer && isResponseSuccess(costumer) && (
|
{!isLoadingCostumer && isResponseSuccess(costumer) && (
|
||||||
<CustomerForm formType="detail" initialValues={costumer.data} />
|
<CustomerForm formType='detail' initialValues={costumer.data} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CustomerDetail;
|
export default CustomerDetail;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import CustomersTable from "@/components/pages/master-data/customer/CustomersTable";
|
import CustomersTable from '@/components/pages/master-data/customer/CustomersTable';
|
||||||
|
|
||||||
const Customer = () => {
|
const Customer = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4">
|
<section className='w-full p-4'>
|
||||||
<CustomersTable />
|
<CustomersTable />
|
||||||
</section>
|
</section>
|
||||||
)
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Customer;
|
export default Customer;
|
||||||
@@ -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 = () => {
|
const AddFlock = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4 flex flex-row justify-center">
|
<section className='w-full p-4 flex flex-row justify-center'>
|
||||||
<FlockForm />
|
<FlockForm />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default AddFlock;
|
export default AddFlock;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import FlockForm from "@/components/pages/master-data/flock/form/FlockForm";
|
import FlockForm from '@/components/pages/master-data/flock/form/FlockForm';
|
||||||
import { isResponseError, isResponseSuccess } from "@/lib/api-helper";
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { FlockApi } from "@/services/api/master-data";
|
import { FlockApi } from '@/services/api/master-data';
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import useSWR from "swr";
|
import useSWR from 'swr';
|
||||||
|
|
||||||
const FlockEdit = () => {
|
const FlockEdit = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -44,6 +44,6 @@ const FlockEdit = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default FlockEdit;
|
export default FlockEdit;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import SuspenseHelper from "@/components/helper/SuspenseHelper"
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
const Layout = ({
|
const Layout = ({
|
||||||
children
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode
|
children: React.ReactNode;
|
||||||
}>) => {
|
}>) => {
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Layout;
|
export default Layout;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import FlockForm from "@/components/pages/master-data/flock/form/FlockForm";
|
import FlockForm from '@/components/pages/master-data/flock/form/FlockForm';
|
||||||
import { isResponseError, isResponseSuccess } from "@/lib/api-helper";
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { FlockApi } from "@/services/api/master-data";
|
import { FlockApi } from '@/services/api/master-data';
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import useSWR from "swr";
|
import useSWR from 'swr';
|
||||||
|
|
||||||
const FlockDetail = () => {
|
const FlockDetail = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -14,33 +14,36 @@ const FlockDetail = () => {
|
|||||||
const flockId = searchParams.get('flockId');
|
const flockId = searchParams.get('flockId');
|
||||||
|
|
||||||
// Fetch Data
|
// 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();
|
router.back();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full flex flex-row justify-center items-center p-4">
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
<span className="loading loading-spinner loading-xl" />
|
<span className='loading loading-spinner loading-xl' />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isLoadingFlock && (!flock || isResponseError(flock))){
|
if (!isLoadingFlock && (!flock || isResponseError(flock))) {
|
||||||
router.replace('/404');
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full p-4 flex flex-row justify-center">
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
{isLoadingFlock && (
|
{isLoadingFlock && (
|
||||||
<span className="loading loading-spinner loading-xl" />
|
<span className='loading loading-spinner loading-xl' />
|
||||||
)}
|
)}
|
||||||
{!isLoadingFlock && isResponseSuccess(flock) && (
|
{!isLoadingFlock && isResponseSuccess(flock) && (
|
||||||
<FlockForm formType="detail" initialValues={flock.data} />
|
<FlockForm formType='detail' initialValues={flock.data} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default FlockDetail;
|
export default FlockDetail;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import FlockTable from "@/components/pages/master-data/flock/FlocksTable";
|
import FlockTable from '@/components/pages/master-data/flock/FlocksTable';
|
||||||
|
|
||||||
const Flock = () => {
|
const Flock = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4">
|
<section className='w-full p-4'>
|
||||||
<FlockTable/>
|
<FlockTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Flock;
|
export default Flock;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import ProductCategoryForm from "@/components/pages/master-data/product-category/form/ProductCategoryForm";
|
import ProductCategoryForm from '@/components/pages/master-data/product-category/form/ProductCategoryForm';
|
||||||
|
|
||||||
const AddProductCategory = () => {
|
const AddProductCategory = () => {
|
||||||
return (
|
return (
|
||||||
<div className="w-full p-4 flex flex-row justify-center">
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
<ProductCategoryForm />
|
<ProductCategoryForm />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,39 +9,44 @@ import { ProductCategoryApi } from '@/services/api/master-data';
|
|||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
const ProductCategoryEdit = () => {
|
const ProductCategoryEdit = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
const productCategoryId = searchParams.get('productCategoryId');
|
const productCategoryId = searchParams.get('productCategoryId');
|
||||||
|
|
||||||
const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR(
|
const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR(
|
||||||
productCategoryId,
|
productCategoryId,
|
||||||
(id: number) => ProductCategoryApi.getSingle(id)
|
(id: number) => ProductCategoryApi.getSingle(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!productCategoryId) {
|
if (!productCategoryId) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
{isLoadingProductCategory && <span className='loading loading-spinner loading-xl' />}
|
<span className='loading loading-spinner loading-xl' />
|
||||||
{!isLoadingProductCategory && isResponseSuccess(productCategory) && (
|
</div>
|
||||||
<ProductCategoryForm type='edit' initialValues={productCategory.data} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!isLoadingProductCategory &&
|
||||||
|
(!productCategory || isResponseError(productCategory))
|
||||||
|
) {
|
||||||
|
router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
|
{isLoadingProductCategory && (
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
)}
|
||||||
|
{!isLoadingProductCategory && isResponseSuccess(productCategory) && (
|
||||||
|
<ProductCategoryForm type='edit' initialValues={productCategory.data} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default ProductCategoryEdit;
|
export default ProductCategoryEdit;
|
||||||
@@ -29,16 +29,24 @@ const ProductCategoryDetail = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) {
|
if (
|
||||||
|
!isLoadingProductCategory &&
|
||||||
|
(!productCategory || isResponseError(productCategory))
|
||||||
|
) {
|
||||||
router.replace('/404');
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
{isLoadingProductCategory && <span className='loading loading-spinner loading-xl' />}
|
{isLoadingProductCategory && (
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
)}
|
||||||
{!isLoadingProductCategory && isResponseSuccess(productCategory) && (
|
{!isLoadingProductCategory && isResponseSuccess(productCategory) && (
|
||||||
<ProductCategoryForm type='detail' initialValues={productCategory.data} />
|
<ProductCategoryForm
|
||||||
|
type='detail'
|
||||||
|
initialValues={productCategory.data}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import ProductCategoryTable from "@/components/pages/master-data/product-category/ProductCategoryTable";
|
import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable';
|
||||||
|
|
||||||
const ProductCategory = () => {
|
const ProductCategory = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4">
|
<section className='w-full p-4'>
|
||||||
<ProductCategoryTable />
|
<ProductCategoryTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import ProductForm from '@/components/pages/master-data/product/form/ProductForm
|
|||||||
|
|
||||||
const AddProduct = () => {
|
const AddProduct = () => {
|
||||||
return (
|
return (
|
||||||
<div className="w-full p-4 flex flex-row justify-center">
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
<ProductForm />
|
<ProductForm />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ const ProductEdit = () => {
|
|||||||
|
|
||||||
const productId = searchParams.get('productId');
|
const productId = searchParams.get('productId');
|
||||||
|
|
||||||
const { data: product, isLoading } = useSWR(
|
const { data: product, isLoading } = useSWR(productId, (id: number) =>
|
||||||
productId,
|
ProductApi.getSingle(id)
|
||||||
(id: number) => ProductApi.getSingle(id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!productId) {
|
if (!productId) {
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ const ProductDetail = () => {
|
|||||||
|
|
||||||
const productId = searchParams.get('productId');
|
const productId = searchParams.get('productId');
|
||||||
|
|
||||||
const { data: product, isLoading } = useSWR(
|
const { data: product, isLoading } = useSWR(productId, (id: number) =>
|
||||||
productId,
|
ProductApi.getSingle(id)
|
||||||
(id: number) => ProductApi.getSingle(id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!productId) {
|
if (!productId) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import ProductsTable from "@/components/pages/master-data/product/ProductTable";
|
import ProductsTable from '@/components/pages/master-data/product/ProductTable';
|
||||||
|
|
||||||
const Product = () => {
|
const Product = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4">
|
<section className='w-full p-4'>
|
||||||
<ProductsTable />
|
<ProductsTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import SuppliersTable from "@/components/pages/master-data/supplier/SupplierTable";
|
import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable';
|
||||||
|
|
||||||
const Supplier = () => {
|
const Supplier = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import SuspenseHelper from "@/components/helper/SuspenseHelper"
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
const Layout = ({
|
const Layout = ({
|
||||||
children
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode
|
children: React.ReactNode;
|
||||||
}>) => {
|
}>) => {
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Layout;
|
export default Layout;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import SuspenseHelper from "@/components/helper/SuspenseHelper"
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
const Layout = ({
|
const Layout = ({
|
||||||
children
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode
|
children: React.ReactNode;
|
||||||
}>) => {
|
}>) => {
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Layout;
|
export default Layout;
|
||||||
@@ -43,9 +43,8 @@ const DetailChickin = () => {
|
|||||||
// chickin.data?.approval.step_number == 1 ? false : true
|
// chickin.data?.approval.step_number == 1 ? false : true
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
const [isRejectedDisabled, setIsRejectedDisabled] = useState(
|
const [isRejectedDisabled, setIsRejectedDisabled] =
|
||||||
!isApprovedDisabled
|
useState(!isApprovedDisabled);
|
||||||
);
|
|
||||||
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
||||||
!isApprovedDisabled ? 'APPROVED' : 'REJECTED'
|
!isApprovedDisabled ? 'APPROVED' : 'REJECTED'
|
||||||
);
|
);
|
||||||
@@ -264,7 +263,8 @@ const DetailChickin = () => {
|
|||||||
<Icon icon='mdi:times' width={24} height={24} />
|
<Icon icon='mdi:times' width={24} height={24} />
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
<Button color='warning'
|
<Button
|
||||||
|
color='warning'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
chickinModal.openModal();
|
chickinModal.openModal();
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import ChickinTable from "@/components/pages/production/chickin/ChickinTable";
|
import ChickinTable from '@/components/pages/production/chickin/ChickinTable';
|
||||||
|
|
||||||
const Chickin = () => {
|
const Chickin = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4">
|
<section className='w-full p-4'>
|
||||||
<ChickinTable/>
|
<ChickinTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
export default Chickin;
|
export default Chickin;
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import ProjectFlockForm from "@/components/pages/production/project-flock/form/ProjectFlockForm";
|
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
||||||
|
|
||||||
const AddProjectFlock = () => {
|
const AddProjectFlock = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4 flex flex-row justify-center">
|
<section className='w-full p-4 flex flex-row justify-center'>
|
||||||
<ProjectFlockForm formType="add"/>
|
<ProjectFlockForm formType='add' />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default AddProjectFlock;
|
export default AddProjectFlock;
|
||||||
@@ -1,46 +1,47 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
|
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
||||||
import ProjectFlockForm from "@/components/pages/production/project-flock/form/ProjectFlockForm";
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { isResponseError, isResponseSuccess } from "@/lib/api-helper";
|
import { ProjectFlockApi } from '@/services/api/production';
|
||||||
import { ProjectFlockApi } from "@/services/api/production";
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import useSWR from 'swr';
|
||||||
import useSWR from "swr";
|
|
||||||
|
|
||||||
const ProjectFlockEdit = () => {
|
const ProjectFlockEdit = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
const projectFlockId = searchParams.get("projectFlockId");
|
const projectFlockId = searchParams.get('projectFlockId');
|
||||||
|
|
||||||
const { data: projectFlock, isLoading: isLoadingCostumer } = useSWR(
|
const { data: projectFlock, isLoading: isLoadingCostumer } = useSWR(
|
||||||
projectFlockId,
|
projectFlockId,
|
||||||
(id: number) => ProjectFlockApi.getSingle(id)
|
(id: number) => ProjectFlockApi.getSingle(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!projectFlockId){
|
if (!projectFlockId) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full flex flex-row justify-center items-center p-4">
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
<span className="loading loading-spinner loading-xl" />
|
<span className='loading loading-spinner loading-xl' />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isLoadingCostumer && (!projectFlock || isResponseError(projectFlock))){
|
if (!isLoadingCostumer && (!projectFlock || isResponseError(projectFlock))) {
|
||||||
router.replace("/404");
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full p-4 flex flex-row justify-center">
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
{isLoadingCostumer && <span className="loading loading-spinner loading-xl" />}
|
{isLoadingCostumer && (
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
)}
|
||||||
{!isLoadingCostumer && isResponseSuccess(projectFlock) && (
|
{!isLoadingCostumer && isResponseSuccess(projectFlock) && (
|
||||||
<ProjectFlockForm formType="edit" initialValues={projectFlock.data} />
|
<ProjectFlockForm formType='edit' initialValues={projectFlock.data} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default ProjectFlockEdit;
|
export default ProjectFlockEdit;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import SuspenseHelper from "@/components/helper/SuspenseHelper"
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
const Layout = ({
|
const Layout = ({
|
||||||
children
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode
|
children: React.ReactNode;
|
||||||
}>) => {
|
}>) => {
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Layout;
|
export default Layout;
|
||||||
@@ -42,7 +42,11 @@ const ProjectFlockDetail = () => {
|
|||||||
<span className='loading loading-spinner loading-xl' />
|
<span className='loading loading-spinner loading-xl' />
|
||||||
)}
|
)}
|
||||||
{!isLoadingProjectFlock && isResponseSuccess(projectFlock) && (
|
{!isLoadingProjectFlock && isResponseSuccess(projectFlock) && (
|
||||||
<ProjectFlockForm formType='detail' initialValues={projectFlock.data} refreshProjectFlocks={refreshProjectFlock} />
|
<ProjectFlockForm
|
||||||
|
formType='detail'
|
||||||
|
initialValues={projectFlock.data}
|
||||||
|
refreshProjectFlocks={refreshProjectFlock}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import ProjectFlockTable from "@/components/pages/production/project-flock/ProjectFlockTable";
|
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
|
||||||
|
|
||||||
const ProjectFlock = () => {
|
const ProjectFlock = () => {
|
||||||
return (
|
return (
|
||||||
<section className="w-full p-4">
|
<section className='w-full p-4'>
|
||||||
<ProjectFlockTable/>
|
<ProjectFlockTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default ProjectFlock;
|
export default ProjectFlock;
|
||||||
|
|||||||
+13
-15
@@ -1,13 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import {
|
import { HTMLAttributes, ReactNode } from 'react';
|
||||||
HTMLAttributes,
|
|
||||||
ReactNode,
|
|
||||||
} from 'react';
|
|
||||||
|
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
|
|
||||||
export interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'className'> {
|
export interface CardProps
|
||||||
|
extends Omit<HTMLAttributes<HTMLDivElement>, 'className'> {
|
||||||
title?: string;
|
title?: string;
|
||||||
subtitle?: string;
|
subtitle?: string;
|
||||||
image?: string;
|
image?: string;
|
||||||
@@ -44,17 +42,17 @@ const Card = ({
|
|||||||
const baseClasses = 'card bg-base-100';
|
const baseClasses = 'card bg-base-100';
|
||||||
|
|
||||||
const variantClasses = {
|
const variantClasses = {
|
||||||
'default': '',
|
default: '',
|
||||||
'compact': 'card-compact',
|
compact: 'card-compact',
|
||||||
'bordered': 'border border-base-300',
|
bordered: 'border border-base-300',
|
||||||
'shadow': 'shadow-xl',
|
shadow: 'shadow-xl',
|
||||||
'image-full': 'card-side card-compact shadow-xl',
|
'image-full': 'card-side card-compact shadow-xl',
|
||||||
};
|
};
|
||||||
|
|
||||||
const sizeClasses = {
|
const sizeClasses = {
|
||||||
'sm': 'w-64',
|
sm: 'w-64',
|
||||||
'md': 'w-96',
|
md: 'w-96',
|
||||||
'lg': 'w-[28rem]',
|
lg: 'w-[28rem]',
|
||||||
};
|
};
|
||||||
|
|
||||||
return cn(
|
return cn(
|
||||||
@@ -84,9 +82,9 @@ const Card = ({
|
|||||||
|
|
||||||
const getTitleClasses = () => {
|
const getTitleClasses = () => {
|
||||||
const sizeClasses = {
|
const sizeClasses = {
|
||||||
'sm': 'text-lg',
|
sm: 'text-lg',
|
||||||
'md': 'text-xl',
|
md: 'text-xl',
|
||||||
'lg': 'text-2xl',
|
lg: 'text-2xl',
|
||||||
};
|
};
|
||||||
|
|
||||||
return cn('card-title font-bold', sizeClasses[size], className?.title);
|
return cn('card-title font-bold', sizeClasses[size], className?.title);
|
||||||
|
|||||||
@@ -185,17 +185,17 @@ const Pagination = ({
|
|||||||
currentPage <= 2
|
currentPage <= 2
|
||||||
? currentPage + 2
|
? currentPage + 2
|
||||||
: currentPage === totalPages - 2
|
: currentPage === totalPages - 2
|
||||||
? 3
|
? 3
|
||||||
: currentPage >= totalPages - 1
|
: currentPage >= totalPages - 1
|
||||||
? 4
|
? 4
|
||||||
: 1
|
: 1
|
||||||
}
|
}
|
||||||
endPage={
|
endPage={
|
||||||
currentPage <= 2 || currentPage >= totalPages - 1
|
currentPage <= 2 || currentPage >= totalPages - 1
|
||||||
? totalPages - 3
|
? totalPages - 3
|
||||||
: currentPage === totalPages - 2
|
: currentPage === totalPages - 2
|
||||||
? totalPages - 4
|
? totalPages - 4
|
||||||
: 2
|
: 2
|
||||||
}
|
}
|
||||||
onPageItemClick={pageChangeHandler}
|
onPageItemClick={pageChangeHandler}
|
||||||
/>
|
/>
|
||||||
@@ -242,15 +242,15 @@ const Pagination = ({
|
|||||||
currentPage <= 3
|
currentPage <= 3
|
||||||
? currentPage + 2
|
? currentPage + 2
|
||||||
: currentPage >= 4
|
: currentPage >= 4
|
||||||
? currentPage + 2
|
? currentPage + 2
|
||||||
: 1
|
: 1
|
||||||
}
|
}
|
||||||
endPage={
|
endPage={
|
||||||
currentPage <= 3
|
currentPage <= 3
|
||||||
? totalPages - 2
|
? totalPages - 2
|
||||||
: currentPage >= 4
|
: currentPage >= 4
|
||||||
? totalPages - 1
|
? totalPages - 1
|
||||||
: 0
|
: 0
|
||||||
}
|
}
|
||||||
onPageItemClick={pageChangeHandler}
|
onPageItemClick={pageChangeHandler}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import {
|
import { ChangeEventHandler, FocusEventHandler, ReactNode } from 'react';
|
||||||
ChangeEventHandler,
|
|
||||||
FocusEventHandler,
|
|
||||||
ReactNode,
|
|
||||||
} from 'react';
|
|
||||||
|
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
|
|
||||||
@@ -109,10 +105,7 @@ const DateInput = ({
|
|||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={cn(
|
className={cn('grow bg-transparent cursor-pointer', className?.input)}
|
||||||
'grow bg-transparent cursor-pointer',
|
|
||||||
className?.input
|
|
||||||
)}
|
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -69,10 +69,7 @@ const FileInput = ({
|
|||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={cn(
|
className={cn('grow file-input w-full h-12 rounded', className?.input)}
|
||||||
'grow file-input w-full h-12 rounded',
|
|
||||||
className?.input
|
|
||||||
)}
|
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { ChangeEvent, ReactNode } from "react";
|
import { ChangeEvent, ReactNode } from 'react';
|
||||||
import { NumericFormat, OnValueChange } from "react-number-format";
|
import { NumericFormat, OnValueChange } from 'react-number-format';
|
||||||
import TextInput, { TextInputProps } from "@/components/input/TextInput";
|
import TextInput, { TextInputProps } from '@/components/input/TextInput';
|
||||||
|
|
||||||
interface NumberInputProps extends Omit<TextInputProps, "type"> {
|
interface NumberInputProps extends Omit<TextInputProps, 'type'> {
|
||||||
thousandSeparator?: string;
|
thousandSeparator?: string;
|
||||||
decimalSeparator?: string;
|
decimalSeparator?: string;
|
||||||
decimalScale?: number;
|
decimalScale?: number;
|
||||||
@@ -17,8 +17,8 @@ interface NumberInputProps extends Omit<TextInputProps, "type"> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NumberInput = ({
|
const NumberInput = ({
|
||||||
thousandSeparator = ",",
|
thousandSeparator = ',',
|
||||||
decimalSeparator = ".",
|
decimalSeparator = '.',
|
||||||
decimalScale = 5,
|
decimalScale = 5,
|
||||||
allowNegative = true,
|
allowNegative = true,
|
||||||
onChange,
|
onChange,
|
||||||
@@ -28,7 +28,7 @@ const NumberInput = ({
|
|||||||
}: NumberInputProps) => {
|
}: NumberInputProps) => {
|
||||||
const valueChangeHandler: OnValueChange = (
|
const valueChangeHandler: OnValueChange = (
|
||||||
numberFormatValues,
|
numberFormatValues,
|
||||||
sourceInfo,
|
sourceInfo
|
||||||
) => {
|
) => {
|
||||||
const newChangeEvent = sourceInfo.event as
|
const newChangeEvent = sourceInfo.event as
|
||||||
| ChangeEvent<HTMLInputElement>
|
| ChangeEvent<HTMLInputElement>
|
||||||
|
|||||||
@@ -31,21 +31,21 @@ const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => {
|
|||||||
approval.status === 'APPROVED'
|
approval.status === 'APPROVED'
|
||||||
? 'success'
|
? 'success'
|
||||||
: approval.status === 'REJECTED'
|
: approval.status === 'REJECTED'
|
||||||
? 'error'
|
? 'error'
|
||||||
: approval.status === 'WAITING'
|
: approval.status === 'WAITING'
|
||||||
? 'warning'
|
? 'warning'
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const stepItemIcon =
|
const stepItemIcon =
|
||||||
approval.status === 'APPROVED'
|
approval.status === 'APPROVED'
|
||||||
? 'material-symbols:check-rounded'
|
? 'material-symbols:check-rounded'
|
||||||
: approval.status === 'REJECTED'
|
: approval.status === 'REJECTED'
|
||||||
? 'material-symbols:close-rounded'
|
? 'material-symbols:close-rounded'
|
||||||
: approval.status === 'WAITING'
|
: approval.status === 'WAITING'
|
||||||
? 'pajamas:dash-circle'
|
? 'pajamas:dash-circle'
|
||||||
: approval.logs && approval.logs.length > 0
|
: approval.logs && approval.logs.length > 0
|
||||||
? 'material-symbols:info-outline-rounded'
|
? 'material-symbols:info-outline-rounded'
|
||||||
: 'bxs:hourglass';
|
: 'bxs:hourglass';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StepItem
|
<StepItem
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ const InventoryAdjustmentTable = () => {
|
|||||||
type === 'INCREASE'
|
type === 'INCREASE'
|
||||||
? 'Peningkatan'
|
? 'Peningkatan'
|
||||||
: type === 'DECREASE'
|
: type === 'DECREASE'
|
||||||
? 'Penurunan'
|
? 'Penurunan'
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -4,24 +4,21 @@ export const InventoryAdjustmentFormSchema = Yup.object({
|
|||||||
product_category: Yup.object({
|
product_category: Yup.object({
|
||||||
value: Yup.number().required('ID Kategori Produk wajib diisi!'),
|
value: Yup.number().required('ID Kategori Produk wajib diisi!'),
|
||||||
label: Yup.string().required('Nama Kategori Produk wajib diisi!'),
|
label: Yup.string().required('Nama Kategori Produk wajib diisi!'),
|
||||||
})
|
}).nullable(),
|
||||||
.nullable(),
|
|
||||||
|
|
||||||
product_category_id: Yup.number().nullable(),
|
product_category_id: Yup.number().nullable(),
|
||||||
|
|
||||||
product: Yup.object({
|
product: Yup.object({
|
||||||
value: Yup.number().required('ID Produk wajib diisi!'),
|
value: Yup.number().required('ID Produk wajib diisi!'),
|
||||||
label: Yup.string().required('Nama Produk wajib diisi!'),
|
label: Yup.string().required('Nama Produk wajib diisi!'),
|
||||||
})
|
}).nullable(),
|
||||||
.nullable(),
|
|
||||||
|
|
||||||
product_id: Yup.number().nullable(),
|
product_id: Yup.number().nullable(),
|
||||||
|
|
||||||
warehouse: Yup.object({
|
warehouse: Yup.object({
|
||||||
value: Yup.number().required('ID Gudang wajib diisi!'),
|
value: Yup.number().required('ID Gudang wajib diisi!'),
|
||||||
label: Yup.string().required('Nama Gudang wajib diisi!'),
|
label: Yup.string().required('Nama Gudang wajib diisi!'),
|
||||||
})
|
}).nullable(),
|
||||||
.nullable(),
|
|
||||||
|
|
||||||
warehouse_id: Yup.number().nullable(),
|
warehouse_id: Yup.number().nullable(),
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,8 @@ const InventoryAdjustmentForm = ({
|
|||||||
// Submit Handler
|
// Submit Handler
|
||||||
const createInventoryAdjustmentHandler = useCallback(
|
const createInventoryAdjustmentHandler = useCallback(
|
||||||
async (payload: CreateInventoryAdjustmentPayload) => {
|
async (payload: CreateInventoryAdjustmentPayload) => {
|
||||||
const createInventoryAdjustmentRes = await inventoryAdjustmentApi.create(
|
const createInventoryAdjustmentRes =
|
||||||
payload
|
await inventoryAdjustmentApi.create(payload);
|
||||||
);
|
|
||||||
|
|
||||||
if (isResponseError(createInventoryAdjustmentRes)) {
|
if (isResponseError(createInventoryAdjustmentRes)) {
|
||||||
setInventoryAdjustmentFormErrorMessage(
|
setInventoryAdjustmentFormErrorMessage(
|
||||||
@@ -68,7 +67,9 @@ const InventoryAdjustmentForm = ({
|
|||||||
[router]
|
[router]
|
||||||
);
|
);
|
||||||
|
|
||||||
const formikInitialValues = useMemo<Partial<InventoryAdjustmentFormValues>>(() => {
|
const formikInitialValues = useMemo<
|
||||||
|
Partial<InventoryAdjustmentFormValues>
|
||||||
|
>(() => {
|
||||||
return {
|
return {
|
||||||
product_category_id: initialValues?.product_category?.id ?? 0,
|
product_category_id: initialValues?.product_category?.id ?? 0,
|
||||||
product_id: initialValues?.product?.id ?? 0,
|
product_id: initialValues?.product?.id ?? 0,
|
||||||
@@ -185,7 +186,6 @@ const InventoryAdjustmentForm = ({
|
|||||||
warehouseChangeHandler(null);
|
warehouseChangeHandler(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const { setValues: formikSetValues } = formik;
|
const { setValues: formikSetValues } = formik;
|
||||||
|
|
||||||
// Effect
|
// Effect
|
||||||
@@ -225,7 +225,13 @@ const InventoryAdjustmentForm = ({
|
|||||||
const type = initialValues.transaction_type.toLowerCase();
|
const type = initialValues.transaction_type.toLowerCase();
|
||||||
setQuantityLabel(type === 'increase' ? 'Tambah Stok' : 'Kurangi Stok');
|
setQuantityLabel(type === 'increase' ? 'Tambah Stok' : 'Kurangi Stok');
|
||||||
}
|
}
|
||||||
}, [formik, initialValues, setQuantityLabel, setDisabledProduct, setSelectedProductCategories]);
|
}, [
|
||||||
|
formik,
|
||||||
|
initialValues,
|
||||||
|
setQuantityLabel,
|
||||||
|
setDisabledProduct,
|
||||||
|
setSelectedProductCategories,
|
||||||
|
]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
formikSetValues(formikInitialValues as InventoryAdjustmentFormValues);
|
formikSetValues(formikInitialValues as InventoryAdjustmentFormValues);
|
||||||
}, [formikSetValues, formikInitialValues]);
|
}, [formikSetValues, formikInitialValues]);
|
||||||
@@ -364,15 +370,19 @@ const InventoryAdjustmentForm = ({
|
|||||||
errorMessage={formik.errors.transaction_type as string}
|
errorMessage={formik.errors.transaction_type as string}
|
||||||
variant='radio-primary'
|
variant='radio-primary'
|
||||||
required
|
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'}
|
disabled={type === 'detail'}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Number Input Stock */}
|
{/* Number Input Stock */}
|
||||||
<TextInput
|
<TextInput
|
||||||
className={{
|
className={{
|
||||||
wrapper: `${formik.values.transaction_type != undefined ? '' : 'hidden'}`,
|
wrapper: `${formik.values.transaction_type != undefined ? '' : 'hidden'}`,
|
||||||
}}
|
}}
|
||||||
required
|
required
|
||||||
label={quantityLabel}
|
label={quantityLabel}
|
||||||
name='quantity'
|
name='quantity'
|
||||||
@@ -395,8 +405,6 @@ const InventoryAdjustmentForm = ({
|
|||||||
readOnly={type === 'detail'}
|
readOnly={type === 'detail'}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/* Text Area Input Reason */}
|
{/* Text Area Input Reason */}
|
||||||
<TextArea
|
<TextArea
|
||||||
required
|
required
|
||||||
@@ -413,14 +421,23 @@ const InventoryAdjustmentForm = ({
|
|||||||
<div className='flex flex-row justify-between gap-2 flex-wrap'>
|
<div className='flex flex-row justify-between gap-2 flex-wrap'>
|
||||||
{type !== 'detail' && (
|
{type !== 'detail' && (
|
||||||
<div className='flex flex-row justify-end gap-2'>
|
<div className='flex flex-row justify-end gap-2'>
|
||||||
<Button type='button' color='warning' className='px-4' onClick={resetHandler}>
|
<Button
|
||||||
|
type='button'
|
||||||
|
color='warning'
|
||||||
|
className='px-4'
|
||||||
|
onClick={resetHandler}
|
||||||
|
>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type='submit'
|
type='submit'
|
||||||
color='primary'
|
color='primary'
|
||||||
isLoading={formik.isSubmitting}
|
isLoading={formik.isSubmitting}
|
||||||
disabled={!formik.isValid || formik.isSubmitting || formik.values.product == undefined}
|
disabled={
|
||||||
|
!formik.isValid ||
|
||||||
|
formik.isSubmitting ||
|
||||||
|
formik.values.product == undefined
|
||||||
|
}
|
||||||
className='px-4'
|
className='px-4'
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ import {
|
|||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { CustomerFormSchema, CustomerFormValues, UpdateCustomerFormSchema } from '@/components/pages/master-data/customer/form/CustomerForm.schema';
|
import {
|
||||||
|
CustomerFormSchema,
|
||||||
|
CustomerFormValues,
|
||||||
|
UpdateCustomerFormSchema,
|
||||||
|
} from '@/components/pages/master-data/customer/form/CustomerForm.schema';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
@@ -150,7 +154,8 @@ const CustomerForm = ({
|
|||||||
const formik = useFormik<CustomerFormValues>({
|
const formik = useFormik<CustomerFormValues>({
|
||||||
initialValues: formikInitialValues,
|
initialValues: formikInitialValues,
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
validationSchema: formType === 'edit' ? UpdateCustomerFormSchema : CustomerFormSchema,
|
validationSchema:
|
||||||
|
formType === 'edit' ? UpdateCustomerFormSchema : CustomerFormSchema,
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
// reset error message
|
// reset error message
|
||||||
setCustomerFormErrorMessage('');
|
setCustomerFormErrorMessage('');
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ import * as Yup from 'yup';
|
|||||||
export const FlockFormSchema = Yup.object({
|
export const FlockFormSchema = Yup.object({
|
||||||
name: Yup.string()
|
name: Yup.string()
|
||||||
.required('Nama wajib diisi!')
|
.required('Nama wajib diisi!')
|
||||||
.matches(
|
.matches(/^[\p{L}\p{N}\s]+$/u, 'Nama tidak boleh mengandung simbol'),
|
||||||
/^[\p{L}\p{N}\s]+$/u,
|
|
||||||
'Nama tidak boleh mengandung simbol'
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const UpdateFlockFormSchema = FlockFormSchema;
|
export const UpdateFlockFormSchema = FlockFormSchema;
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import { useModal } from '@/components/Modal';
|
import { useModal } from '@/components/Modal';
|
||||||
import { FlockApi } from '@/services/api/master-data';
|
import { FlockApi } from '@/services/api/master-data';
|
||||||
import { Flock } from '@/types/api/master-data/flock';
|
import { Flock } from '@/types/api/master-data/flock';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { FlockFormSchema, FlockFormValues, UpdateFlockFormSchema } from '@/components/pages/master-data/flock/form/FlockForm.schema';
|
import {
|
||||||
|
FlockFormSchema,
|
||||||
|
FlockFormValues,
|
||||||
|
UpdateFlockFormSchema,
|
||||||
|
} from '@/components/pages/master-data/flock/form/FlockForm.schema';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
@@ -48,7 +52,8 @@ const FlockForm = ({ formType = 'add', initialValues }: FlockCustomProps) => {
|
|||||||
const formik = useFormik<FlockFormValues>({
|
const formik = useFormik<FlockFormValues>({
|
||||||
initialValues: formikInitialValue,
|
initialValues: formikInitialValue,
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
validationSchema: formType === 'edit' ? UpdateFlockFormSchema : FlockFormSchema,
|
validationSchema:
|
||||||
|
formType === 'edit' ? UpdateFlockFormSchema : FlockFormSchema,
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
// reset error message
|
// reset error message
|
||||||
setFlockFormErrorMessage('');
|
setFlockFormErrorMessage('');
|
||||||
|
|||||||
+6
-2
@@ -1,10 +1,14 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
export const ProductCategoryFormSchema = Yup.object({
|
export const ProductCategoryFormSchema = Yup.object({
|
||||||
code: Yup.string().required('Kode wajib diisi!').max(3, 'Kode kategori produk melebihi 3 karakter!'),
|
code: Yup.string()
|
||||||
|
.required('Kode wajib diisi!')
|
||||||
|
.max(3, 'Kode kategori produk melebihi 3 karakter!'),
|
||||||
name: Yup.string().required('Nama wajib diisi!'),
|
name: Yup.string().required('Nama wajib diisi!'),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const UpdateProductCategoryFormSchema = ProductCategoryFormSchema;
|
export const UpdateProductCategoryFormSchema = ProductCategoryFormSchema;
|
||||||
|
|
||||||
export type ProductCategoryFormValues = Yup.InferType<typeof ProductCategoryFormSchema>;
|
export type ProductCategoryFormValues = Yup.InferType<
|
||||||
|
typeof ProductCategoryFormSchema
|
||||||
|
>;
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ interface ProductCategoryFormProps {
|
|||||||
initialValues?: ProductCategory;
|
initialValues?: ProductCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProductCategoryForm = ({ type = 'add', initialValues }: ProductCategoryFormProps) => {
|
const ProductCategoryForm = ({
|
||||||
|
type = 'add',
|
||||||
|
initialValues,
|
||||||
|
}: ProductCategoryFormProps) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const deleteModal = useModal();
|
const deleteModal = useModal();
|
||||||
|
|
||||||
@@ -77,7 +80,10 @@ const ProductCategoryForm = ({ type = 'add', initialValues }: ProductCategoryFor
|
|||||||
|
|
||||||
const formik = useFormik<ProductCategoryFormValues>({
|
const formik = useFormik<ProductCategoryFormValues>({
|
||||||
initialValues: formikInitialValues,
|
initialValues: formikInitialValues,
|
||||||
validationSchema: type === 'edit' ? UpdateProductCategoryFormSchema : ProductCategoryFormSchema,
|
validationSchema:
|
||||||
|
type === 'edit'
|
||||||
|
? UpdateProductCategoryFormSchema
|
||||||
|
: ProductCategoryFormSchema,
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
setFormErrorMessage('');
|
setFormErrorMessage('');
|
||||||
|
|
||||||
@@ -91,7 +97,10 @@ const ProductCategoryForm = ({ type = 'add', initialValues }: ProductCategoryFor
|
|||||||
await createProductCategoryHandler(payload);
|
await createProductCategoryHandler(payload);
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
await updateProductCategoryHandler(initialValues?.id as number, payload);
|
await updateProductCategoryHandler(
|
||||||
|
initialValues?.id as number,
|
||||||
|
payload
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,49 +5,50 @@ export const ProductFormSchema = Yup.object({
|
|||||||
brand: Yup.string().required('Merek wajib diisi!'),
|
brand: Yup.string().required('Merek wajib diisi!'),
|
||||||
sku: Yup.string().required('SKU wajib diisi!'),
|
sku: Yup.string().required('SKU wajib diisi!'),
|
||||||
uom: Yup.object({
|
uom: Yup.object({
|
||||||
value: Yup.number().min(1).required(),
|
value: Yup.number().min(1).required(),
|
||||||
label: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
}).nullable(),
|
}).nullable(),
|
||||||
uom_id: Yup.number().required('Satuan wajib diisi!').typeError('Satuan wajib diisi!'),
|
uom_id: Yup.number()
|
||||||
|
.required('Satuan wajib diisi!')
|
||||||
|
.typeError('Satuan wajib diisi!'),
|
||||||
product_category: Yup.object({
|
product_category: Yup.object({
|
||||||
value: Yup.number().min(1).required(),
|
value: Yup.number().min(1).required(),
|
||||||
label: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
}).nullable(),
|
}).nullable(),
|
||||||
product_category_id: Yup.number()
|
product_category_id: Yup.number()
|
||||||
.required('Kategori produk wajib diisi!')
|
.required('Kategori produk wajib diisi!')
|
||||||
.typeError('Kategori produk wajib diisi!'),
|
.typeError('Kategori produk wajib diisi!'),
|
||||||
product_price: Yup.number()
|
product_price: Yup.number()
|
||||||
.required('Harga produk wajib diisi!')
|
.required('Harga produk wajib diisi!')
|
||||||
.typeError('Harga produk wajib diisi!')
|
.typeError('Harga produk wajib diisi!')
|
||||||
.min(0, 'Harga produk tidak boleh kurang dari 0!'),
|
.min(0, 'Harga produk tidak boleh kurang dari 0!'),
|
||||||
selling_price: Yup.number()
|
selling_price: Yup.number()
|
||||||
.required('Harga jual wajib diisi!')
|
.required('Harga jual wajib diisi!')
|
||||||
.typeError('Harga jual wajib diisi!')
|
.typeError('Harga jual wajib diisi!')
|
||||||
.min(0, 'Harga jual tidak boleh kurang dari 0!'),
|
.min(0, 'Harga jual tidak boleh kurang dari 0!'),
|
||||||
tax: Yup.number()
|
tax: Yup.number()
|
||||||
.required('Pajak wajib diisi!')
|
.required('Pajak wajib diisi!')
|
||||||
.typeError('Pajak wajib diisi!')
|
.typeError('Pajak wajib diisi!')
|
||||||
.min(0, 'Pajak tidak boleh kurang dari 0!')
|
.min(0, 'Pajak tidak boleh kurang dari 0!')
|
||||||
.max(100, 'Pajak tidak boleh lebih dari 100%!'),
|
.max(100, 'Pajak tidak boleh lebih dari 100%!'),
|
||||||
expiry_period: Yup.number()
|
expiry_period: Yup.number()
|
||||||
.required('Periode kadaluarsa wajib diisi!')
|
.required('Periode kadaluarsa wajib diisi!')
|
||||||
.typeError('Periode kadaluarsa wajib diisi!')
|
.typeError('Periode kadaluarsa wajib diisi!')
|
||||||
.min(0, 'Periode kadaluarsa tidak boleh kurang dari 0!'),
|
.min(0, 'Periode kadaluarsa tidak boleh kurang dari 0!'),
|
||||||
supplier: Yup.object({
|
supplier: Yup.object({
|
||||||
value: Yup.number().min(1).required(),
|
value: Yup.number().min(1).required(),
|
||||||
label: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
}).nullable(),
|
}).nullable(),
|
||||||
supplier_ids: Yup.array()
|
supplier_ids: Yup.array()
|
||||||
.of(Yup.number().typeError('Supplier tidak valid!'))
|
.of(Yup.number().typeError('Supplier tidak valid!'))
|
||||||
.min(1, 'Minimal harus ada 1 supplier!')
|
.min(1, 'Minimal harus ada 1 supplier!')
|
||||||
.required('Supplier wajib diisi!'),
|
.required('Supplier wajib diisi!'),
|
||||||
flags: Yup.array()
|
flags: Yup.array()
|
||||||
.of(Yup.string())
|
.of(Yup.string())
|
||||||
.min(1, 'Minimal harus ada 1 flag!')
|
.min(1, 'Minimal harus ada 1 flag!')
|
||||||
.required('Flag wajib diisi!'),
|
.required('Flag wajib diisi!'),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const UpdateProductFormSchema = ProductFormSchema;
|
export const UpdateProductFormSchema = ProductFormSchema;
|
||||||
|
|
||||||
export type ProductFormValues = Yup.InferType<typeof ProductFormSchema>;
|
export type ProductFormValues = Yup.InferType<typeof ProductFormSchema>;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ import {
|
|||||||
CreateProductPayload,
|
CreateProductPayload,
|
||||||
UpdateProductPayload,
|
UpdateProductPayload,
|
||||||
} from '@/types/api/master-data/product';
|
} from '@/types/api/master-data/product';
|
||||||
import { UomApi, ProductCategoryApi, SupplierApi, ProductApi } from '@/services/api/master-data';
|
import {
|
||||||
|
UomApi,
|
||||||
|
ProductCategoryApi,
|
||||||
|
SupplierApi,
|
||||||
|
ProductApi,
|
||||||
|
} from '@/services/api/master-data';
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
import { PRODUCT_FLAG_OPTIONS } from '@/config/constant';
|
import { PRODUCT_FLAG_OPTIONS } from '@/config/constant';
|
||||||
|
|
||||||
@@ -67,30 +72,37 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
[router]
|
[router]
|
||||||
);
|
);
|
||||||
|
|
||||||
const formikInitialValues = useMemo<ProductFormValues>(() => ({
|
const formikInitialValues = useMemo<ProductFormValues>(
|
||||||
name: initialValues?.name ?? '',
|
() => ({
|
||||||
brand: initialValues?.brand ?? '',
|
name: initialValues?.name ?? '',
|
||||||
sku: initialValues?.sku ?? '',
|
brand: initialValues?.brand ?? '',
|
||||||
uom: initialValues?.uom
|
sku: initialValues?.sku ?? '',
|
||||||
? { value: initialValues.uom.id, label: initialValues.uom.name }
|
uom: initialValues?.uom
|
||||||
: null,
|
? { value: initialValues.uom.id, label: initialValues.uom.name }
|
||||||
uom_id: initialValues?.uom?.id ?? 0,
|
: null,
|
||||||
product_category: initialValues?.product_category
|
uom_id: initialValues?.uom?.id ?? 0,
|
||||||
? { value: initialValues.product_category.id, label: initialValues.product_category.name }
|
product_category: initialValues?.product_category
|
||||||
: null,
|
? {
|
||||||
product_category_id: initialValues?.product_category?.id ?? 0,
|
value: initialValues.product_category.id,
|
||||||
product_price: initialValues?.product_price ?? 0,
|
label: initialValues.product_category.name,
|
||||||
selling_price: initialValues?.selling_price ?? 0,
|
}
|
||||||
tax: initialValues?.tax ?? 0,
|
: null,
|
||||||
expiry_period: initialValues?.expiry_period ?? 0,
|
product_category_id: initialValues?.product_category?.id ?? 0,
|
||||||
supplier: null, // not used for payload, just for UI
|
product_price: initialValues?.product_price ?? 0,
|
||||||
supplier_ids: initialValues?.suppliers?.map(s => s.id) ?? [],
|
selling_price: initialValues?.selling_price ?? 0,
|
||||||
flags: initialValues?.flags ?? [],
|
tax: initialValues?.tax ?? 0,
|
||||||
}), [initialValues]);
|
expiry_period: initialValues?.expiry_period ?? 0,
|
||||||
|
supplier: null, // not used for payload, just for UI
|
||||||
|
supplier_ids: initialValues?.suppliers?.map((s) => s.id) ?? [],
|
||||||
|
flags: initialValues?.flags ?? [],
|
||||||
|
}),
|
||||||
|
[initialValues]
|
||||||
|
);
|
||||||
|
|
||||||
const formik = useFormik<ProductFormValues>({
|
const formik = useFormik<ProductFormValues>({
|
||||||
initialValues: formikInitialValues,
|
initialValues: formikInitialValues,
|
||||||
validationSchema: type === 'edit' ? UpdateProductFormSchema : ProductFormSchema,
|
validationSchema:
|
||||||
|
type === 'edit' ? UpdateProductFormSchema : ProductFormSchema,
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
setProductFormErrorMessage('');
|
setProductFormErrorMessage('');
|
||||||
const payload: CreateProductPayload = {
|
const payload: CreateProductPayload = {
|
||||||
@@ -103,8 +115,12 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
selling_price: values.selling_price,
|
selling_price: values.selling_price,
|
||||||
tax: values.tax,
|
tax: values.tax,
|
||||||
expiry_period: values.expiry_period,
|
expiry_period: values.expiry_period,
|
||||||
supplier_ids: (values.supplier_ids ?? []).filter((id): id is number => typeof id === 'number'),
|
supplier_ids: (values.supplier_ids ?? []).filter(
|
||||||
flags: (values.flags ?? []).filter((f): f is string => typeof f === 'string'),
|
(id): id is number => typeof id === 'number'
|
||||||
|
),
|
||||||
|
flags: (values.flags ?? []).filter(
|
||||||
|
(f): f is string => typeof f === 'string'
|
||||||
|
),
|
||||||
};
|
};
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'add':
|
case 'add':
|
||||||
@@ -122,7 +138,10 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
// UOM
|
// UOM
|
||||||
const [uomSelectInputValue, setUomSelectInputValue] = useState('');
|
const [uomSelectInputValue, setUomSelectInputValue] = useState('');
|
||||||
const uomsUrl = `${UomApi.basePath}?${new URLSearchParams({ search: uomSelectInputValue ?? '' }).toString()}`;
|
const uomsUrl = `${UomApi.basePath}?${new URLSearchParams({ search: uomSelectInputValue ?? '' }).toString()}`;
|
||||||
const { data: uoms, isLoading: isLoadingUoms } = useSWR(uomsUrl, UomApi.getAllFetcher);
|
const { data: uoms, isLoading: isLoadingUoms } = useSWR(
|
||||||
|
uomsUrl,
|
||||||
|
UomApi.getAllFetcher
|
||||||
|
);
|
||||||
const uomOptions = isResponseSuccess(uoms)
|
const uomOptions = isResponseSuccess(uoms)
|
||||||
? uoms?.data.map((uom) => ({ value: uom.id, label: uom.name }))
|
? uoms?.data.map((uom) => ({ value: uom.id, label: uom.name }))
|
||||||
: [];
|
: [];
|
||||||
@@ -136,7 +155,10 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
// Product Category
|
// Product Category
|
||||||
const [categorySelectInputValue, setCategorySelectInputValue] = useState('');
|
const [categorySelectInputValue, setCategorySelectInputValue] = useState('');
|
||||||
const categoriesUrl = `${ProductCategoryApi.basePath}?${new URLSearchParams({ search: categorySelectInputValue ?? '' }).toString()}`;
|
const categoriesUrl = `${ProductCategoryApi.basePath}?${new URLSearchParams({ search: categorySelectInputValue ?? '' }).toString()}`;
|
||||||
const { data: categories, isLoading: isLoadingCategories } = useSWR(categoriesUrl, ProductCategoryApi.getAllFetcher);
|
const { data: categories, isLoading: isLoadingCategories } = useSWR(
|
||||||
|
categoriesUrl,
|
||||||
|
ProductCategoryApi.getAllFetcher
|
||||||
|
);
|
||||||
const categoryOptions = isResponseSuccess(categories)
|
const categoryOptions = isResponseSuccess(categories)
|
||||||
? categories?.data.map((cat) => ({ value: cat.id, label: cat.name }))
|
? categories?.data.map((cat) => ({ value: cat.id, label: cat.name }))
|
||||||
: [];
|
: [];
|
||||||
@@ -150,16 +172,22 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
// Supplier (multi select)
|
// Supplier (multi select)
|
||||||
const [supplierSelectInputValue, setSupplierSelectInputValue] = useState('');
|
const [supplierSelectInputValue, setSupplierSelectInputValue] = useState('');
|
||||||
const suppliersUrl = `${SupplierApi.basePath}?${new URLSearchParams({ search: supplierSelectInputValue ?? '' }).toString()}`;
|
const suppliersUrl = `${SupplierApi.basePath}?${new URLSearchParams({ search: supplierSelectInputValue ?? '' }).toString()}`;
|
||||||
const { data: suppliers, isLoading: isLoadingSuppliers } = useSWR(suppliersUrl, SupplierApi.getAllFetcher);
|
const { data: suppliers, isLoading: isLoadingSuppliers } = useSWR(
|
||||||
|
suppliersUrl,
|
||||||
|
SupplierApi.getAllFetcher
|
||||||
|
);
|
||||||
const supplierOptions = isResponseSuccess(suppliers)
|
const supplierOptions = isResponseSuccess(suppliers)
|
||||||
? suppliers?.data
|
? suppliers?.data
|
||||||
.filter((sup) => sup.category === 'SAPRONAK')
|
.filter((sup) => sup.category === 'SAPRONAK')
|
||||||
.map((sup) => ({ value: sup.id, label: sup.name }))
|
.map((sup) => ({ value: sup.id, label: sup.name }))
|
||||||
: [];
|
: [];
|
||||||
const supplierChangeHandler = (val: OptionType | OptionType[] | null) => {
|
const supplierChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||||
const arr = Array.isArray(val) ? val : val ? [val] : [];
|
const arr = Array.isArray(val) ? val : val ? [val] : [];
|
||||||
formik.setFieldTouched('supplier_ids', true);
|
formik.setFieldTouched('supplier_ids', true);
|
||||||
formik.setFieldValue('supplier_ids', arr.map((v) => (v as OptionType).value));
|
formik.setFieldValue(
|
||||||
|
'supplier_ids',
|
||||||
|
arr.map((v) => (v as OptionType).value)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteProductClickHandler = () => {
|
const deleteProductClickHandler = () => {
|
||||||
@@ -260,7 +288,10 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
options={categoryOptions}
|
options={categoryOptions}
|
||||||
onInputChange={setCategorySelectInputValue}
|
onInputChange={setCategorySelectInputValue}
|
||||||
isLoading={isLoadingCategories}
|
isLoading={isLoadingCategories}
|
||||||
isError={formik.touched.product_category_id && Boolean(formik.errors.product_category_id)}
|
isError={
|
||||||
|
formik.touched.product_category_id &&
|
||||||
|
Boolean(formik.errors.product_category_id)
|
||||||
|
}
|
||||||
errorMessage={formik.errors.product_category_id as string}
|
errorMessage={formik.errors.product_category_id as string}
|
||||||
isDisabled={type === 'detail'}
|
isDisabled={type === 'detail'}
|
||||||
isClearable
|
isClearable
|
||||||
@@ -274,7 +305,10 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
value={formik.values.product_price}
|
value={formik.values.product_price}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
isError={formik.touched.product_price && Boolean(formik.errors.product_price)}
|
isError={
|
||||||
|
formik.touched.product_price &&
|
||||||
|
Boolean(formik.errors.product_price)
|
||||||
|
}
|
||||||
errorMessage={formik.errors.product_price as string}
|
errorMessage={formik.errors.product_price as string}
|
||||||
readOnly={type === 'detail'}
|
readOnly={type === 'detail'}
|
||||||
/>
|
/>
|
||||||
@@ -287,7 +321,10 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
value={formik.values.selling_price}
|
value={formik.values.selling_price}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
isError={formik.touched.selling_price && Boolean(formik.errors.selling_price)}
|
isError={
|
||||||
|
formik.touched.selling_price &&
|
||||||
|
Boolean(formik.errors.selling_price)
|
||||||
|
}
|
||||||
errorMessage={formik.errors.selling_price as string}
|
errorMessage={formik.errors.selling_price as string}
|
||||||
readOnly={type === 'detail'}
|
readOnly={type === 'detail'}
|
||||||
/>
|
/>
|
||||||
@@ -313,7 +350,10 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
value={formik.values.expiry_period}
|
value={formik.values.expiry_period}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
isError={formik.touched.expiry_period && Boolean(formik.errors.expiry_period)}
|
isError={
|
||||||
|
formik.touched.expiry_period &&
|
||||||
|
Boolean(formik.errors.expiry_period)
|
||||||
|
}
|
||||||
errorMessage={formik.errors.expiry_period as string}
|
errorMessage={formik.errors.expiry_period as string}
|
||||||
readOnly={type === 'detail'}
|
readOnly={type === 'detail'}
|
||||||
/>
|
/>
|
||||||
@@ -321,12 +361,17 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
required
|
required
|
||||||
label='Supplier'
|
label='Supplier'
|
||||||
isMulti
|
isMulti
|
||||||
value={supplierOptions.filter(opt => formik.values.supplier_ids.includes(opt.value))}
|
value={supplierOptions.filter((opt) =>
|
||||||
|
formik.values.supplier_ids.includes(opt.value)
|
||||||
|
)}
|
||||||
onChange={supplierChangeHandler}
|
onChange={supplierChangeHandler}
|
||||||
options={supplierOptions}
|
options={supplierOptions}
|
||||||
onInputChange={setSupplierSelectInputValue}
|
onInputChange={setSupplierSelectInputValue}
|
||||||
isLoading={isLoadingSuppliers}
|
isLoading={isLoadingSuppliers}
|
||||||
isError={formik.touched.supplier_ids && Boolean(formik.errors.supplier_ids)}
|
isError={
|
||||||
|
formik.touched.supplier_ids &&
|
||||||
|
Boolean(formik.errors.supplier_ids)
|
||||||
|
}
|
||||||
errorMessage={formik.errors.supplier_ids as string}
|
errorMessage={formik.errors.supplier_ids as string}
|
||||||
isDisabled={type === 'detail'}
|
isDisabled={type === 'detail'}
|
||||||
isClearable
|
isClearable
|
||||||
@@ -335,10 +380,15 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
|
|||||||
required
|
required
|
||||||
label='Flags'
|
label='Flags'
|
||||||
isMulti
|
isMulti
|
||||||
value={PRODUCT_FLAG_OPTIONS.filter(opt => formik.values.flags.includes(opt.value))}
|
value={PRODUCT_FLAG_OPTIONS.filter((opt) =>
|
||||||
onChange={val => {
|
formik.values.flags.includes(opt.value)
|
||||||
|
)}
|
||||||
|
onChange={(val) => {
|
||||||
const arr = Array.isArray(val) ? val : val ? [val] : [];
|
const arr = Array.isArray(val) ? val : val ? [val] : [];
|
||||||
formik.setFieldValue('flags', arr.map((v) => (v as OptionType).value));
|
formik.setFieldValue(
|
||||||
|
'flags',
|
||||||
|
arr.map((v) => (v as OptionType).value)
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
options={PRODUCT_FLAG_OPTIONS}
|
options={PRODUCT_FLAG_OPTIONS}
|
||||||
isError={formik.touched.flags && Boolean(formik.errors.flags)}
|
isError={formik.touched.flags && Boolean(formik.errors.flags)}
|
||||||
|
|||||||
@@ -1,39 +1,42 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
export const SupplierFormSchema = Yup.object({
|
export const SupplierFormSchema = Yup.object({
|
||||||
name: Yup.string().required('Nama wajib diisi!'),
|
name: Yup.string().required('Nama wajib diisi!'),
|
||||||
alias: Yup.string()
|
alias: Yup.string()
|
||||||
.matches(/^[A-Za-z0-9]+$/, 'Alias hanya boleh berisi huruf dan angka tanpa spasi atau simbol!')
|
.matches(
|
||||||
|
/^[A-Za-z0-9]+$/,
|
||||||
|
'Alias hanya boleh berisi huruf dan angka tanpa spasi atau simbol!'
|
||||||
|
)
|
||||||
.max(5, 'Alias maksimal 5 karakter!')
|
.max(5, 'Alias maksimal 5 karakter!')
|
||||||
.required('Alias wajib diisi!'),
|
.required('Alias wajib diisi!'),
|
||||||
pic: Yup.string().required('PIC wajib diisi!'),
|
pic: Yup.string().required('PIC wajib diisi!'),
|
||||||
type: Yup.object({
|
type: Yup.object({
|
||||||
value: Yup.string().required(),
|
value: Yup.string().required(),
|
||||||
label: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
})
|
}).required('Tipe wajib diisi!'),
|
||||||
.required('Tipe wajib diisi!'),
|
category: Yup.object({
|
||||||
category: Yup.object({
|
value: Yup.string().required(),
|
||||||
value: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
label: Yup.string().required(),
|
}).required('Tipe wajib diisi!'),
|
||||||
})
|
hatchery: Yup.string().required('Hatchery wajib diisi!'),
|
||||||
.required('Tipe wajib diisi!'),
|
phone: Yup.string()
|
||||||
hatchery: Yup.string().required('Hatchery wajib diisi!'),
|
.matches(/^[0-9]+$/, 'Nomor telepon hanya boleh berisi angka!')
|
||||||
phone: Yup.string()
|
.min(10, 'Nomor telepon minimal 10 digit!')
|
||||||
.matches(/^[0-9]+$/, 'Nomor telepon hanya boleh berisi angka!')
|
.max(12, 'Nomor telepon maksimal 12 digit!')
|
||||||
.min(10, 'Nomor telepon minimal 10 digit!')
|
.required('Nomor telepon wajib diisi!'),
|
||||||
.max(12, 'Nomor telepon maksimal 12 digit!')
|
email: Yup.string()
|
||||||
.required('Nomor telepon wajib diisi!'),
|
.email('Format email tidak valid!')
|
||||||
email: Yup.string()
|
.required('Email wajib diisi!'),
|
||||||
.email('Format email tidak valid!')
|
address: Yup.string().required('Alamat wajib diisi!'),
|
||||||
.required('Email wajib diisi!'),
|
npwp: Yup.string()
|
||||||
address: Yup.string().required('Alamat wajib diisi!'),
|
.matches(/^[0-9]+$/, 'Nomor NPWP hanya boleh berisi angka!')
|
||||||
npwp: Yup.string()
|
.required('Nomor NPWP wajib diisi!'),
|
||||||
.matches(/^[0-9]+$/, 'Nomor NPWP hanya boleh berisi angka!')
|
account_number: Yup.string()
|
||||||
.required('Nomor NPWP wajib diisi!'),
|
.matches(/^[0-9]+$/, 'Nomor rekening hanya boleh berisi angka!')
|
||||||
account_number: Yup.string()
|
.required('Nomor rekening wajib diisi!'),
|
||||||
.matches(/^[0-9]+$/, 'Nomor rekening hanya boleh berisi angka!')
|
due_date: Yup.number()
|
||||||
.required('Nomor rekening wajib diisi!'),
|
.min(1, 'Tanggal jatuh tempo wajib diisi!')
|
||||||
due_date: Yup.number().min(1, 'Tanggal jatuh tempo wajib diisi!').required('Tanggal jatuh tempo wajib diisi!'),
|
.required('Tanggal jatuh tempo wajib diisi!'),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const UpdateSupplierFormSchema = SupplierFormSchema;
|
export const UpdateSupplierFormSchema = SupplierFormSchema;
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ const SupplierForm = ({
|
|||||||
// Setup State
|
// Setup State
|
||||||
const [supplierFormErrorMessage, setSupplierFormErrorMessage] = useState('');
|
const [supplierFormErrorMessage, setSupplierFormErrorMessage] = useState('');
|
||||||
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
||||||
const [hatcheryOptionsValues, setHatcheryOptionValues] = useState<OptionType[]>([]);
|
const [hatcheryOptionsValues, setHatcheryOptionValues] = useState<
|
||||||
|
OptionType[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
// -- Options data mapping
|
// -- Options data mapping
|
||||||
const typeOptions = TYPE_OPTIONS;
|
const typeOptions = TYPE_OPTIONS;
|
||||||
@@ -167,7 +169,7 @@ const SupplierForm = ({
|
|||||||
// Initialize Formik
|
// Initialize Formik
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
formikSetValues(formikInitialValues);
|
formikSetValues(formikInitialValues);
|
||||||
if(formType != 'add'){
|
if (formType != 'add') {
|
||||||
const hatcheryArrays = formikInitialValues.hatchery.split(',');
|
const hatcheryArrays = formikInitialValues.hatchery.split(',');
|
||||||
const hatcheryCreatedOptions = hatcheryArrays.map((item) => ({
|
const hatcheryCreatedOptions = hatcheryArrays.map((item) => ({
|
||||||
value: item,
|
value: item,
|
||||||
@@ -177,11 +179,13 @@ const SupplierForm = ({
|
|||||||
}
|
}
|
||||||
}, [formikSetValues, formikInitialValues, setHatcheryOptionValues]);
|
}, [formikSetValues, formikInitialValues, setHatcheryOptionValues]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const commaSeparatedValues = hatcheryOptionsValues.map((item) => item.value).join(',');
|
const commaSeparatedValues = hatcheryOptionsValues
|
||||||
|
.map((item) => item.value)
|
||||||
|
.join(',');
|
||||||
formikSetValues({
|
formikSetValues({
|
||||||
...formik.values,
|
...formik.values,
|
||||||
hatchery: commaSeparatedValues,
|
hatchery: commaSeparatedValues,
|
||||||
})
|
});
|
||||||
}, [hatcheryOptionsValues, formikSetValues]);
|
}, [hatcheryOptionsValues, formikSetValues]);
|
||||||
|
|
||||||
// Option Handler
|
// Option Handler
|
||||||
@@ -305,7 +309,9 @@ const SupplierForm = ({
|
|||||||
console.log(val); // pastikan val = array of { value, label }
|
console.log(val); // pastikan val = array of { value, label }
|
||||||
setHatcheryOptionValues(val as OptionType[]);
|
setHatcheryOptionValues(val as OptionType[]);
|
||||||
}}
|
}}
|
||||||
isError={formik.touched.hatchery && Boolean(formik.errors.hatchery)}
|
isError={
|
||||||
|
formik.touched.hatchery && Boolean(formik.errors.hatchery)
|
||||||
|
}
|
||||||
errorMessage={formik.errors.hatchery as string}
|
errorMessage={formik.errors.hatchery as string}
|
||||||
isDisabled={formType === 'detail'}
|
isDisabled={formType === 'detail'}
|
||||||
isClearable
|
isClearable
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import * as Yup from 'yup';
|
|||||||
export const ChickinFormSchema = Yup.object({
|
export const ChickinFormSchema = Yup.object({
|
||||||
chick_in_date: Yup.string().required('Tanggal masuk wajib diisi!'),
|
chick_in_date: Yup.string().required('Tanggal masuk wajib diisi!'),
|
||||||
note: Yup.string().required('Catatan wajib diisi!'),
|
note: Yup.string().required('Catatan wajib diisi!'),
|
||||||
quantity: Yup.number().min(1, 'Jumlah wajib diisi!').required('Jumlah wajib diisi!'),
|
quantity: Yup.number()
|
||||||
})
|
.min(1, 'Jumlah wajib diisi!')
|
||||||
|
.required('Jumlah wajib diisi!'),
|
||||||
|
});
|
||||||
|
|
||||||
export type ChickinFormValues = Yup.InferType<typeof ChickinFormSchema>;
|
export type ChickinFormValues = Yup.InferType<typeof ChickinFormSchema>;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ export const ProjectFlockFormSchema = Yup.object({
|
|||||||
value: Yup.string().required('Nilai Kategori wajib diisi!'),
|
value: Yup.string().required('Nilai Kategori wajib diisi!'),
|
||||||
label: Yup.string().required('Label Kategori wajib diisi!'),
|
label: Yup.string().required('Label Kategori wajib diisi!'),
|
||||||
}).nullable(),
|
}).nullable(),
|
||||||
category: Yup.string().oneOf(['GROWING', 'LAYING'], 'Kategori wajib diisi!')
|
category: Yup.string()
|
||||||
|
.oneOf(['GROWING', 'LAYING'], 'Kategori wajib diisi!')
|
||||||
.required('Kategori wajib diisi!'),
|
.required('Kategori wajib diisi!'),
|
||||||
|
|
||||||
// FCR
|
// FCR
|
||||||
|
|||||||
@@ -79,9 +79,8 @@ const ProjectFlockForm = ({
|
|||||||
const [isApprovedDisabled, setIsApprovedDisabled] = useState(
|
const [isApprovedDisabled, setIsApprovedDisabled] = useState(
|
||||||
initialValues?.approval.step_name == 'Pengajuan' ? false : true
|
initialValues?.approval.step_name == 'Pengajuan' ? false : true
|
||||||
);
|
);
|
||||||
const [isRejectedDisabled, setIsRejectedDisabled] = useState(
|
const [isRejectedDisabled, setIsRejectedDisabled] =
|
||||||
!isApprovedDisabled
|
useState(!isApprovedDisabled);
|
||||||
);
|
|
||||||
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
||||||
!isApprovedDisabled ? 'APPROVED' : 'REJECTED'
|
!isApprovedDisabled ? 'APPROVED' : 'REJECTED'
|
||||||
);
|
);
|
||||||
@@ -143,10 +142,11 @@ const ProjectFlockForm = ({
|
|||||||
search: '',
|
search: '',
|
||||||
location_id: selectedLocation == '' ? '0' : selectedLocation,
|
location_id: selectedLocation == '' ? '0' : selectedLocation,
|
||||||
}).toString()}`;
|
}).toString()}`;
|
||||||
const { data: kandang, isLoading: isLoadingKandang, mutate: refreshKandang} = useSWR(
|
const {
|
||||||
kandangUrl,
|
data: kandang,
|
||||||
KandangApi.getAllFetcher
|
isLoading: isLoadingKandang,
|
||||||
);
|
mutate: refreshKandang,
|
||||||
|
} = useSWR(kandangUrl, KandangApi.getAllFetcher);
|
||||||
|
|
||||||
const getPeriodFlocksUrl = `flocks/${selectedFlock}/periods`;
|
const getPeriodFlocksUrl = `flocks/${selectedFlock}/periods`;
|
||||||
|
|
||||||
@@ -207,10 +207,7 @@ const ProjectFlockForm = ({
|
|||||||
setOpenSelectKandangs(true);
|
setOpenSelectKandangs(true);
|
||||||
|
|
||||||
const newRowSelection = Object.fromEntries(
|
const newRowSelection = Object.fromEntries(
|
||||||
initialValues.kandangs.map((k: Kandang) => [
|
initialValues.kandangs.map((k: Kandang) => [k.id.toString(), true])
|
||||||
k.id.toString(),
|
|
||||||
true,
|
|
||||||
])
|
|
||||||
);
|
);
|
||||||
setRowSelection(newRowSelection);
|
setRowSelection(newRowSelection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,10 +38,13 @@ const ProjectFlockKandangTable = ({
|
|||||||
|
|
||||||
const allSelected =
|
const allSelected =
|
||||||
selectableRows.every((row) => row.getIsSelected()) &&
|
selectableRows.every((row) => row.getIsSelected()) &&
|
||||||
selectableRows.length != 0 && formType != 'detail';
|
selectableRows.length != 0 &&
|
||||||
|
formType != 'detail';
|
||||||
|
|
||||||
const someSelected =
|
const someSelected =
|
||||||
selectableRows.some((row) => row.getIsSelected()) && !allSelected && formType != 'detail';
|
selectableRows.some((row) => row.getIsSelected()) &&
|
||||||
|
!allSelected &&
|
||||||
|
formType != 'detail';
|
||||||
|
|
||||||
const toggleSelectableRows = () => {
|
const toggleSelectableRows = () => {
|
||||||
const shouldSelect = !allSelected;
|
const shouldSelect = !allSelected;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -320,9 +320,8 @@ const TransferToLayingsTable = () => {
|
|||||||
const confirmationModalApproveClickHandler = async () => {
|
const confirmationModalApproveClickHandler = async () => {
|
||||||
setIsApproveLoading(true);
|
setIsApproveLoading(true);
|
||||||
|
|
||||||
const bulkApproveResponse = await TransferToLayingApi.bulkApprove(
|
const bulkApproveResponse =
|
||||||
selectedRowIds
|
await TransferToLayingApi.bulkApprove(selectedRowIds);
|
||||||
);
|
|
||||||
|
|
||||||
if (isResponseSuccess(bulkApproveResponse)) {
|
if (isResponseSuccess(bulkApproveResponse)) {
|
||||||
refreshTransferToLayings();
|
refreshTransferToLayings();
|
||||||
@@ -350,9 +349,8 @@ const TransferToLayingsTable = () => {
|
|||||||
const confirmationModalRejectClickHandler = async () => {
|
const confirmationModalRejectClickHandler = async () => {
|
||||||
setIsRejectLoading(true);
|
setIsRejectLoading(true);
|
||||||
|
|
||||||
const bulkRejectResponse = await TransferToLayingApi.bulkReject(
|
const bulkRejectResponse =
|
||||||
selectedRowIds
|
await TransferToLayingApi.bulkReject(selectedRowIds);
|
||||||
);
|
|
||||||
|
|
||||||
if (isResponseSuccess(bulkRejectResponse)) {
|
if (isResponseSuccess(bulkRejectResponse)) {
|
||||||
refreshTransferToLayings();
|
refreshTransferToLayings();
|
||||||
@@ -477,7 +475,9 @@ const TransferToLayingsTable = () => {
|
|||||||
placeholder='Cari TransferToLaying'
|
placeholder='Cari TransferToLaying'
|
||||||
value={tableFilterState.search}
|
value={tableFilterState.search}
|
||||||
onChange={searchChangeHandler}
|
onChange={searchChangeHandler}
|
||||||
className={{ wrapper: 'sm:max-w-3xs' }}
|
className={{
|
||||||
|
wrapper: 'sm:max-w-3xs',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -490,7 +490,9 @@ const TransferToLayingsTable = () => {
|
|||||||
placeholder='Masukkan tanggal transfer'
|
placeholder='Masukkan tanggal transfer'
|
||||||
value={tableFilterState.transferDate}
|
value={tableFilterState.transferDate}
|
||||||
onChange={transferDateChangeHandler}
|
onChange={transferDateChangeHandler}
|
||||||
className={{ wrapper: 'col-span-12 sm:col-span-3' }}
|
className={{
|
||||||
|
wrapper: 'col-span-12 sm:col-span-3',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SelectInput
|
<SelectInput
|
||||||
|
|||||||
@@ -105,10 +105,13 @@ export class BaseApiService<T, CreatePayloadGeneric, UpdatePayloadGeneric> {
|
|||||||
|
|
||||||
const url = options?.params
|
const url = options?.params
|
||||||
? `${urlBase}?${new URLSearchParams(
|
? `${urlBase}?${new URLSearchParams(
|
||||||
Object.entries(options.params).reduce((acc, [key, value]) => {
|
Object.entries(options.params).reduce(
|
||||||
if (value !== undefined) acc[key] = String(value);
|
(acc, [key, value]) => {
|
||||||
return acc;
|
if (value !== undefined) acc[key] = String(value);
|
||||||
}, {} as Record<string, string>)
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, string>
|
||||||
|
)
|
||||||
)}`
|
)}`
|
||||||
: urlBase;
|
: urlBase;
|
||||||
|
|
||||||
|
|||||||
+19
-19
@@ -1,27 +1,27 @@
|
|||||||
import { BaseMetadata, CreatedUser } from "@/types/api/api-general";
|
import { BaseMetadata, CreatedUser } from '@/types/api/api-general';
|
||||||
|
|
||||||
export type BaseCustomer = {
|
export type BaseCustomer = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
pic_id: number;
|
pic_id: number;
|
||||||
pic: CreatedUser;
|
pic: CreatedUser;
|
||||||
type: string;
|
type: string;
|
||||||
address: string;
|
address: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
email: string;
|
email: string;
|
||||||
account_number: string;
|
account_number: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type Customer = BaseMetadata & BaseCustomer;
|
export type Customer = BaseMetadata & BaseCustomer;
|
||||||
|
|
||||||
export type CreateCustomerPayload = {
|
export type CreateCustomerPayload = {
|
||||||
name: string;
|
name: string;
|
||||||
pic_id: number;
|
pic_id: number;
|
||||||
type: string;
|
type: string;
|
||||||
address: string;
|
address: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
email: string;
|
email: string;
|
||||||
account_number: string;
|
account_number: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type UpdateCustomerPayload = CreateCustomerPayload;
|
export type UpdateCustomerPayload = CreateCustomerPayload;
|
||||||
+29
-29
@@ -1,38 +1,38 @@
|
|||||||
import { BaseMetadata } from '@/types/api/api-general';
|
import { BaseMetadata } from '@/types/api/api-general';
|
||||||
|
|
||||||
export type BaseSupplier = {
|
export type BaseSupplier = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
alias: string;
|
alias: string;
|
||||||
pic: string;
|
pic: string;
|
||||||
type: string;
|
type: string;
|
||||||
category: string;
|
category: string;
|
||||||
hatchery: string;
|
hatchery: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
email: string;
|
email: string;
|
||||||
address: string;
|
address: string;
|
||||||
npwp: string;
|
npwp: string;
|
||||||
account_number: string;
|
account_number: string;
|
||||||
due_date: number;
|
due_date: number;
|
||||||
balance?: number;
|
balance?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type Supplier = BaseMetadata & BaseSupplier;
|
export type Supplier = BaseMetadata & BaseSupplier;
|
||||||
|
|
||||||
export type CreateSupplierPayload = {
|
export type CreateSupplierPayload = {
|
||||||
name: string;
|
name: string;
|
||||||
alias: string;
|
alias: string;
|
||||||
pic: string;
|
pic: string;
|
||||||
type: string;
|
type: string;
|
||||||
category: string;
|
category: string;
|
||||||
hatchery: string;
|
hatchery: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
email: string;
|
email: string;
|
||||||
address: string;
|
address: string;
|
||||||
npwp: string;
|
npwp: string;
|
||||||
account_number: string;
|
account_number: string;
|
||||||
due_date: number;
|
due_date: number;
|
||||||
balance?: number;
|
balance?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type UpdateSupplierPayload = CreateSupplierPayload;
|
export type UpdateSupplierPayload = CreateSupplierPayload;
|
||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
import { BaseApproval, BaseMetadata } from "@/types/api/api-general";
|
import { BaseApproval, BaseMetadata } from '@/types/api/api-general';
|
||||||
import { ProjectFlockKandang } from "@/types/api/production/project-flock-kandang";
|
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
||||||
|
|
||||||
export type BaseChickin = {
|
export type BaseChickin = {
|
||||||
id?: number;
|
id?: number;
|
||||||
@@ -8,7 +8,7 @@ export type BaseChickin = {
|
|||||||
note?: string;
|
note?: string;
|
||||||
project_flock_kandang?: ProjectFlockKandang;
|
project_flock_kandang?: ProjectFlockKandang;
|
||||||
approval: BaseApproval;
|
approval: BaseApproval;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type Chickin = BaseMetadata & BaseChickin;
|
export type Chickin = BaseMetadata & BaseChickin;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ export type CreateChickinPayload = {
|
|||||||
chick_in_date: string;
|
chick_in_date: string;
|
||||||
note: string;
|
note: string;
|
||||||
quantity?: number;
|
quantity?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type UpdateChickinPayload = CreateChickinPayload & {
|
export type UpdateChickinPayload = CreateChickinPayload & {
|
||||||
id: number;
|
id: number;
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
import { Kandang } from "@/type/master-data/kandang";
|
import { Kandang } from '@/type/master-data/kandang';
|
||||||
import { ProjectFlock } from "@/types/api/production/project-flock";
|
import { ProjectFlock } from '@/types/api/production/project-flock';
|
||||||
|
|
||||||
export type BaseProjectFlockKandang = {
|
export type BaseProjectFlockKandang = {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -8,11 +8,11 @@ export type BaseProjectFlockKandang = {
|
|||||||
kandang: Kandang;
|
kandang: Kandang;
|
||||||
project_flock: ProjectFlock;
|
project_flock: ProjectFlock;
|
||||||
available_quantity?: number;
|
available_quantity?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type ProjectFlockKandang = BaseProjectFlockKandang;
|
export type ProjectFlockKandang = BaseProjectFlockKandang;
|
||||||
|
|
||||||
export type LookupProjectFlockKandangPayload = {
|
export type LookupProjectFlockKandangPayload = {
|
||||||
project_flock_id: number;
|
project_flock_id: number;
|
||||||
kandang_id: number;
|
kandang_id: number;
|
||||||
}
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user