From 28a1852de8c3cad0333f92f371414e7455cc5135 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 2 May 2026 17:04:59 +0700 Subject: [PATCH 1/7] fix: adjust stock, depletion, and egg select input --- .../recording/form/RecordingForm.schema.ts | 72 ++++++++++--- .../recording/form/RecordingForm.tsx | 102 +++++++++--------- src/types/api/production/recording.d.ts | 2 + 3 files changed, 107 insertions(+), 69 deletions(-) diff --git a/src/components/pages/production/recording/form/RecordingForm.schema.ts b/src/components/pages/production/recording/form/RecordingForm.schema.ts index e4cf7a49..51d176f1 100644 --- a/src/components/pages/production/recording/form/RecordingForm.schema.ts +++ b/src/components/pages/production/recording/form/RecordingForm.schema.ts @@ -5,6 +5,7 @@ import { CreateLayingRecordingPayload, CreateEggPayload, } from '@/types/api/production/recording'; +import { getProductWarehouseOptionLabel } from '@/lib/product-warehouse'; type RecordingGrowingFormSchemaType = { record_date: string; @@ -29,11 +30,19 @@ type RecordingGrowingFormSchemaType = { } | null; project_flock_kandang_id: number; stocks: { - product_warehouse_id: number; + product_warehouse_id: + | { + value: number; + label: string; + } + | undefined; qty: number | string; }[]; depletions: { - product_warehouse_id?: number; + product_warehouse_id?: { + value: number; + label: string; + }; source_product_warehouse_id?: number; qty?: number | string; }[]; @@ -41,34 +50,48 @@ type RecordingGrowingFormSchemaType = { type RecordingLayingFormSchemaType = RecordingGrowingFormSchemaType & { eggs: { - product_warehouse_id?: number; + product_warehouse_id?: { + value: number; + label: string; + }; qty?: number | string; weight?: number | string; }[]; }; export type StockSchema = { - product_warehouse_id: number; + product_warehouse_id: { + value: number; + label: string; + }; qty: number | string; }; export type DepletionSchema = { - product_warehouse_id?: number; + product_warehouse_id?: { + value: number; + label: string; + }; source_product_warehouse_id?: number; qty?: number | string; }; export type EggSchema = { - product_warehouse_id?: number; + product_warehouse_id?: { + value: number; + label: string; + }; qty?: number | string; weight?: number | string; }; const StockObjectSchema: Yup.ObjectSchema = Yup.object({ - product_warehouse_id: Yup.number() + product_warehouse_id: Yup.object({ + value: Yup.number().min(1).required(), + label: Yup.string().required(), + }) .required('Produk wajib diisi!') - .min(1, 'Produk wajib diisi!') - .typeError('Produk harus berupa angka!'), + .typeError('Produk wajib diisi!'), qty: Yup.number() .required('Jumlah penggunaan wajib diisi!') .moreThan(0, 'Jumlah penggunaan harus lebih dari 0!') @@ -76,7 +99,10 @@ const StockObjectSchema: Yup.ObjectSchema = Yup.object({ }); const DepletionObjectSchema: Yup.ObjectSchema = Yup.object({ - product_warehouse_id: Yup.number() + product_warehouse_id: Yup.object({ + value: Yup.number().min(1).required(), + label: Yup.string().required(), + }) .optional() .typeError('Depletions harus berupa angka!'), source_product_warehouse_id: Yup.number() @@ -88,7 +114,10 @@ const DepletionObjectSchema: Yup.ObjectSchema = Yup.object({ }); const EggObjectSchema: Yup.ObjectSchema = Yup.object({ - product_warehouse_id: Yup.number() + product_warehouse_id: Yup.object({ + value: Yup.number().min(1).required(), + label: Yup.string().required(), + }) .optional() .typeError('Kondisi telur harus berupa angka!'), qty: Yup.number().optional().typeError('Jumlah telur harus berupa angka!'), @@ -248,14 +277,17 @@ export const getRecordingGrowingFormInitialValues = ( initialValues?.project_flock?.project_flock_kandang_id ?? 0, stocks: initialValues?.stocks?.map((stock) => ({ - product_warehouse_id: stock.product_warehouse_id, + product_warehouse_id: { + value: stock.product_warehouse_id, + label: getProductWarehouseOptionLabel(stock.product_warehouse), + }, qty: (stock as { qty?: number; usage_amount?: number }).qty || (stock as { qty?: number; usage_amount?: number }).usage_amount || '', })) ?? [ { - product_warehouse_id: 0, + product_warehouse_id: undefined, qty: '', }, ], @@ -263,13 +295,16 @@ export const getRecordingGrowingFormInitialValues = ( ( depletion: NonNullable[0] ) => ({ - product_warehouse_id: depletion.product_warehouse_id, + product_warehouse_id: { + value: Number(depletion.product_warehouse_id ?? 0), + label: getProductWarehouseOptionLabel(depletion.product_warehouse), + }, source_product_warehouse_id: depletion.source_product_warehouse_id, qty: depletion.qty, }) ) ?? [ { - product_warehouse_id: 0, + product_warehouse_id: undefined, qty: '', }, ], @@ -281,12 +316,15 @@ export const getRecordingLayingFormInitialValues = ( ...getRecordingGrowingFormInitialValues(initialValues), eggs: initialValues?.eggs?.map((egg: CreateEggPayload) => ({ - product_warehouse_id: egg.product_warehouse_id, + product_warehouse_id: { + value: Number(egg.product_warehouse_id ?? 0), + label: getProductWarehouseOptionLabel(egg.product_warehouse), + }, qty: egg.qty, weight: egg.weight, })) ?? [ { - product_warehouse_id: 0, + product_warehouse_id: undefined, qty: '', weight: '', }, diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index 3b584cfe..ec56bba7 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -522,7 +522,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { ? values.depletions ?.filter((d) => d.product_warehouse_id && d.qty) .map((depletion) => ({ - product_warehouse_id: depletion.product_warehouse_id!, + product_warehouse_id: depletion.product_warehouse_id?.value ?? 0, ...(depletion.source_product_warehouse_id && { source_product_warehouse_id: depletion.source_product_warehouse_id, @@ -533,13 +533,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const stocks = recordingRestriction.canEditStock ? (values.stocks ?? []) - .filter((s) => s.product_warehouse_id && s.qty) + .filter((s) => s.product_warehouse_id?.value && s.qty) .map((stock) => ({ // In migration mode, product_warehouse_id field holds product.id; // send it as product_id so the backend auto-creates the warehouse entry. ...(isMigrationMode - ? { product_id: stock.product_warehouse_id } - : { product_warehouse_id: stock.product_warehouse_id }), + ? { product_id: stock.product_warehouse_id?.value } + : { product_warehouse_id: stock.product_warehouse_id?.value }), qty: Number(stock.qty) || 0, })) : []; @@ -561,9 +561,9 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const createLayingPayload = useCallback( (values: RecordingLayingFormValues) => { const depletions = values.depletions - ?.filter((d) => d.product_warehouse_id && d.qty) + ?.filter((d) => d.product_warehouse_id?.value && d.qty) .map((depletion) => ({ - product_warehouse_id: depletion.product_warehouse_id!, + product_warehouse_id: depletion.product_warehouse_id?.value ?? 0, ...(depletion.source_product_warehouse_id && { source_product_warehouse_id: depletion.source_product_warehouse_id, }), @@ -573,7 +573,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const eggs = values.eggs ?.filter((e) => e.product_warehouse_id && e.qty && e.weight) .map((egg) => ({ - product_warehouse_id: egg.product_warehouse_id!, + product_warehouse_id: egg.product_warehouse_id?.value ?? 0, qty: Number(egg.qty) || 0, weight: typeof egg.weight === 'number' @@ -583,11 +583,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const stocks = recordingRestriction.canEditStock ? values.stocks - .filter((s) => s.product_warehouse_id && s.qty) + .filter((s) => s.product_warehouse_id?.value && s.qty) .map((stock) => ({ ...(isMigrationMode - ? { product_id: stock.product_warehouse_id } - : { product_warehouse_id: stock.product_warehouse_id }), + ? { product_id: stock.product_warehouse_id?.value } + : { product_warehouse_id: stock.product_warehouse_id?.value }), qty: Number(stock.qty) || 0, })) : []; @@ -1283,8 +1283,12 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { // product_warehouse object returned by the API. if (isMigrationMode && type === 'edit' && initialValues?.stocks?.length) { baseValues.stocks = initialValues.stocks.map((stock) => ({ - product_warehouse_id: - stock.product_warehouse?.product_id ?? stock.product_warehouse_id, + product_warehouse_id: { + value: Number( + stock.product_warehouse?.product_id ?? stock.product_warehouse_id + ), + label: getProductWarehouseOptionLabel(stock.product_warehouse), + }, qty: stock.usage_amount ?? '', })); } @@ -1438,8 +1442,12 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { formik.setFieldValue( 'stocks', initialValues.stocks.map((stock) => ({ - product_warehouse_id: - stock.product_warehouse?.product_id ?? stock.product_warehouse_id, + product_warehouse_id: { + value: Number( + stock.product_warehouse?.product_id ?? stock.product_warehouse_id + ), + label: getProductWarehouseOptionLabel(stock.product_warehouse), + }, qty: stock.usage_amount ?? '', })) ); @@ -1462,7 +1470,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { (stockIdx: number) => { if ((type as 'add' | 'edit' | 'detail') === 'detail') return null; const stock = formik.values.stocks?.[stockIdx]; - if (!stock || !stock.product_warehouse_id) return null; + if (!stock || !stock.product_warehouse_id?.value) return null; return null; }, [formik.values.stocks, type] @@ -1492,13 +1500,17 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const getStockUsageAdornment = useCallback( (stockIdx: number) => { const stock = formik.values.stocks?.[stockIdx]; - if (!stock || !stock.product_warehouse_id) return null; + if (!stock || !stock.product_warehouse_id?.value) return null; const isDetail = (type as 'add' | 'edit' | 'detail') === 'detail'; - const availableStock = getAvailableStock(stock.product_warehouse_id); + const availableStock = getAvailableStock( + stock.product_warehouse_id.value + ); const requestedUsage = Number(stock.qty) || 0; const remainingStock = availableStock - requestedUsage; - const { pendingQty } = getStockPendingInfo(stock.product_warehouse_id); + const { pendingQty } = getStockPendingInfo( + stock.product_warehouse_id.value + ); if (isDetail) { if (pendingQty > 0) { @@ -1605,10 +1617,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return ( idx !== currentIdx && s.product_warehouse_id && - s.product_warehouse_id !== 0 + s.product_warehouse_id.value !== 0 ); }) - .map((s) => s.product_warehouse_id) || []; + .map((s) => s.product_warehouse_id?.value) || []; return unifiedStockProducts.filter( (opt) => !selectedProductIds.includes(Number(opt.value)) @@ -1625,10 +1637,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return ( idx !== currentIdx && d.product_warehouse_id && - d.product_warehouse_id !== 0 + d.product_warehouse_id.value !== 0 ); }) - .map((d) => d.product_warehouse_id) || []; + .map((d) => d.product_warehouse_id?.value) || []; return depletionProducts.filter( (opt) => !selectedProductIds.includes(Number(opt.value)) @@ -1645,10 +1657,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return ( idx !== currentIdx && e.product_warehouse_id && - e.product_warehouse_id !== 0 + e.product_warehouse_id.value !== 0 ); }) - .map((e) => e.product_warehouse_id) || []; + .map((e) => e.product_warehouse_id?.value) || []; return eggProducts.filter( (opt) => !selectedProductIds.includes(Number(opt.value)) @@ -1694,7 +1706,9 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { isError: touchedField && Boolean(errorField?.[column]), errorMessage: touchedField && errorField?.[column] - ? (errorField[column] as string) + ? errorField[column] instanceof Object + ? (errorField[column] as OptionType)?.label + : (errorField[column] as string) : '', }; }; @@ -2901,20 +2915,15 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { - product.value === stock.product_warehouse_id - ) || null - } + key={`stock-product-${idx}-${stock.product_warehouse_id?.value}`} + value={stock.product_warehouse_id} onInputChange={setStockInputValue} onChange={(selectedOption) => { const option = selectedOption as OptionType | null; formik.setFieldValue( `stocks.${idx}.product_warehouse_id`, - option?.value || 0 + option ); }} options={getAvailableStockProductOptions(idx)} @@ -2950,9 +2959,9 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { } isClearable={type !== 'detail'} inputPrefix={ - stock.product_warehouse_id + stock.product_warehouse_id?.value ? getProductFlagBadgeAdornment( - stock.product_warehouse_id + stock.product_warehouse_id.value ) : undefined } @@ -2988,7 +2997,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { inputSuffix={ stock.product_warehouse_id ? getProductUomSuffix( - stock.product_warehouse_id, + stock.product_warehouse_id.value, 'stock' ) : null @@ -3181,19 +3190,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { )} - product.value === - depletion.product_warehouse_id - ) || null - } + value={depletion.product_warehouse_id} onChange={(selectedOption) => { const option = selectedOption as OptionType | null; formik.setFieldValue( `depletions.${idx}.product_warehouse_id`, - option?.value || 0 + option ); }} options={getAvailableDepletionProductOptions(idx)} @@ -3256,7 +3259,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { inputSuffix={ depletion.product_warehouse_id ? getProductUomSuffix( - depletion.product_warehouse_id, + depletion.product_warehouse_id.value, 'depletion' ) : null @@ -3434,18 +3437,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { )} - product.value === egg.product_warehouse_id - ) || null - } + value={egg.product_warehouse_id} onChange={(selectedOption) => { const option = selectedOption as OptionType | null; formik.setFieldValue( `eggs.${idx}.product_warehouse_id`, - option?.value || 0 + option ); }} options={getAvailableEggProductOptions(idx)} diff --git a/src/types/api/production/recording.d.ts b/src/types/api/production/recording.d.ts index 04392ae4..98f56058 100644 --- a/src/types/api/production/recording.d.ts +++ b/src/types/api/production/recording.d.ts @@ -117,6 +117,7 @@ export type CreateGrowingRecordingPayload = { product_warehouse_id?: number; source_product_warehouse_id?: number; qty?: number; + product_warehouse?: ProductWarehouse; }[]; }; @@ -124,6 +125,7 @@ export type CreateEggPayload = { product_warehouse_id?: number; qty?: number; weight?: number; + product_warehouse?: ProductWarehouse; }; export type CreateLayingRecordingPayload = CreateGrowingRecordingPayload & { From 31cea258a72e7f7f03d8665c2645e791073ad583 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Mon, 4 May 2026 09:48:46 +0700 Subject: [PATCH 2/7] fix: adjust delete click handler --- src/components/pages/purchase/PurchaseTable.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/pages/purchase/PurchaseTable.tsx b/src/components/pages/purchase/PurchaseTable.tsx index facc7079..781fb2cf 100644 --- a/src/components/pages/purchase/PurchaseTable.tsx +++ b/src/components/pages/purchase/PurchaseTable.tsx @@ -409,10 +409,17 @@ const PurchaseTable = () => { setIsDeleteLoading(true); try { - await PurchaseApi.delete(selectedPurchase?.id as number); - refreshPurchaseRequests(); - deleteModal.closeModal(); - toast.success('Berhasil menghapus data permintaan pembelian!'); + const deleteResponse = await PurchaseApi.delete( + selectedPurchase?.id as number + ); + + if (isResponseSuccess(deleteResponse)) { + refreshPurchaseRequests(); + deleteModal.closeModal(); + toast.success('Berhasil menghapus data permintaan pembelian!'); + } else { + toast.error(deleteResponse?.message ?? 'Gagal menghapus data!'); + } } catch { toast.error('Gagal menghapus data permintaan pembelian!'); } From 8869c9df2c4fa4a7c733ae42d97bd5c445a70695 Mon Sep 17 00:00:00 2001 From: MacBook Air M1 Date: Mon, 4 May 2026 12:20:20 +0700 Subject: [PATCH 3/7] adjust get detail recording --- .../recording/form/RecordingForm.tsx | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index ec56bba7..9a7e11b6 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -636,21 +636,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { rawData: stockProductsPW, isLoadingOptions: isLoadingStockProductsPW, loadMore: loadMoreStockProductsPW, - } = useSelect( - isMigrationMode ? null : ProductWarehouseApi.basePath, - 'id', - 'product.name', - 'search', - { - flags: 'PAKAN,OVK', - limit: '100', - available_only: 'false', - location_id: stockProductsLocationId, - ...(selectedKandangId - ? { kandang_id: selectedKandangId.toString() } - : {}), - } - ); + } = useSelect(ProductWarehouseApi.basePath, 'id', 'product.name', 'search', { + flags: 'PAKAN,OVK', + limit: '100', + available_only: 'false', + location_id: stockProductsLocationId, + ...(selectedKandangId ? { kandang_id: selectedKandangId.toString() } : {}), + }); const { setInputValue: setStockMasterInputValue, From 4e58f20ba3c104b80c66f3b76741551ea8a1b356 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Mon, 4 May 2026 14:15:57 +0700 Subject: [PATCH 4/7] fix: set timeout to 1 minute --- src/services/http/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/http/client.ts b/src/services/http/client.ts index c9fbfe2c..64bf9680 100644 --- a/src/services/http/client.ts +++ b/src/services/http/client.ts @@ -5,7 +5,7 @@ import { RequestOptions } from '@/services/http/base'; import { redirectToSSO } from '@/lib/auth-helper'; const BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL ?? ''; -const axiosClient = axios.create({ baseURL: BASE_URL, timeout: 30_000 }); +const axiosClient = axios.create({ baseURL: BASE_URL, timeout: 60_000 }); axiosClient.interceptors.response.use( (response) => response, @@ -38,7 +38,7 @@ export async function httpClient( method: opts.method ?? 'GET', params: opts.query, data: opts.body, - timeout: opts.timeoutMs ?? 30_000, + timeout: opts.timeoutMs ?? 60_000, withCredentials: isCookieAuth && !isBearerAuth, responseType: opts.responseType, headers: { From a5f1a6ea75c5c9b15d93da2bca364a797f2696f7 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Mon, 4 May 2026 14:19:14 +0700 Subject: [PATCH 5/7] fix: order select input options in ascending manner --- .../components/pages/dashboard/Dashboard.tsx | 5 ++- .../ListDailyChecklistContent.tsx | 5 ++- .../employee/MasterEmployeeContent.tsx | 5 ++- .../kandang/MasterKandangContent.tsx | 10 ++++-- .../reports/DailyChecklistReportsContent.tsx | 36 +++++++++++++------ 5 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/figma-make/components/pages/dashboard/Dashboard.tsx b/src/figma-make/components/pages/dashboard/Dashboard.tsx index 36b04cf6..3cf8a9b7 100644 --- a/src/figma-make/components/pages/dashboard/Dashboard.tsx +++ b/src/figma-make/components/pages/dashboard/Dashboard.tsx @@ -89,7 +89,10 @@ export function Dashboard() { options: kandangOptions, loadMore: loadMoreKandang, isLoadingMore: isLoadingMoreKandang, - } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name'); + } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name', 'search', { + order_by: 'asc', + sort_by: 'name', + }); const handleKandangScroll = (e: React.UIEvent) => { const target = e.target as HTMLDivElement; diff --git a/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx b/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx index ae00d17a..64f716c1 100644 --- a/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx +++ b/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx @@ -110,7 +110,10 @@ export function ListDailyChecklistContent() { options: kandangOptions, isLoadingMore: isLoadingMoreKandang, loadMore: loadMoreKandang, - } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name'); + } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name', 'search', { + order_by: 'asc', + sort_by: 'name', + }); const checklistList = isResponseSuccess(checklistListRes) ? checklistListRes.data || [] diff --git a/src/figma-make/components/pages/master-data/employee/MasterEmployeeContent.tsx b/src/figma-make/components/pages/master-data/employee/MasterEmployeeContent.tsx index 37c81057..572317e0 100644 --- a/src/figma-make/components/pages/master-data/employee/MasterEmployeeContent.tsx +++ b/src/figma-make/components/pages/master-data/employee/MasterEmployeeContent.tsx @@ -96,7 +96,10 @@ export function MasterEmployeeContent() { options: kandangOptions, loadMore: loadMoreKandang, isLoadingMore: isLoadingMoreKandang, - } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name'); + } = useSelect(DailyChecklistKandangApi.basePath, 'id', 'name', 'search', { + order_by: 'asc', + sort_by: 'name', + }); const handleKandangScroll = (e: React.UIEvent) => { const target = e.target as HTMLDivElement; diff --git a/src/figma-make/components/pages/master-data/kandang/MasterKandangContent.tsx b/src/figma-make/components/pages/master-data/kandang/MasterKandangContent.tsx index 33de94e4..da733edb 100644 --- a/src/figma-make/components/pages/master-data/kandang/MasterKandangContent.tsx +++ b/src/figma-make/components/pages/master-data/kandang/MasterKandangContent.tsx @@ -368,7 +368,9 @@ export function MasterKandangContent() { name='search' placeholder='Cari kandang...' value={tableFilterState.search} - onChange={(e) => updateFilter('search', e.target.value)} + onChange={(e) => + updateFilter('search', e.target.value, true) + } className={{ wrapper: 'w-full sm:w-[280px] border-gray-200', inputWrapper: 'px-3 py-2 h-fit rounded-md', @@ -383,7 +385,11 @@ export function MasterKandangContent() { From b19099cea220544cefc384db9b8d25ec2bc15a16 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Mon, 4 May 2026 16:23:35 +0700 Subject: [PATCH 6/7] fix: takeout export button --- .../project-flock/ProjectFlockTable.tsx | 89 ++----------------- 1 file changed, 8 insertions(+), 81 deletions(-) diff --git a/src/components/pages/production/project-flock/ProjectFlockTable.tsx b/src/components/pages/production/project-flock/ProjectFlockTable.tsx index f74787f1..d497fac0 100644 --- a/src/components/pages/production/project-flock/ProjectFlockTable.tsx +++ b/src/components/pages/production/project-flock/ProjectFlockTable.tsx @@ -11,7 +11,6 @@ import { useModal } from '@/components/Modal'; import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes'; import Table from '@/components/Table'; -import Dropdown from '@/components/Dropdown'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; import { cn, formatDate } from '@/lib/helper'; import { AreaApi, KandangApi, LocationApi } from '@/services/api/master-data'; @@ -44,6 +43,7 @@ import { import Modal from '@/components/Modal'; import SelectInputRadio from '@/components/input/SelectInputRadio'; import ButtonFilter from '@/components/helper/ButtonFilter'; +import NumberInput from '@/components/input/NumberInput'; const RowOptionsMenu = ({ props, @@ -211,8 +211,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { ); const [isDeleteLoading, setIsDeleteLoading] = useState(false); const [isApproveLoading, setIsApproveLoading] = useState(false); - const [isLoadingExportingToExcel, setIsLoadingExportingToExcel] = - useState(false); + const { isChickinApproveModalOpen, isChickinApproveLoading, @@ -327,14 +326,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { [] ); - const periodOptions = useMemo( - () => [ - { value: '1', label: 'Periode 1' }, - { value: '2', label: 'Periode 2' }, - ], - [] - ); - // ===== FILTER HELPERS ===== const areaValue = useMemo(() => { if (!formik.values.area_id) return null; @@ -393,13 +384,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { ); }, [formik.values.category, categoryOptions]); - const periodValue = useMemo(() => { - if (!formik.values.period) return null; - return ( - periodOptions.find((opt) => opt.value === formik.values.period) || null - ); - }, [formik.values.period, periodOptions]); - // ===== FILTER DEPENDENCY HANDLERS ===== const handleFilterAreaChange = (area: OptionType | null) => { const areaId = area?.value ? String(area.value) : undefined; @@ -813,14 +797,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { [] ); - const exportToExcelHandler = async () => { - setIsLoadingExportingToExcel(true); - - toast.error('Not implemented yet!'); - - setIsLoadingExportingToExcel(false); - }; - const bulkApproveClickHandler = () => { setApprovalAction('APPROVED'); confirmModal.openModal(); @@ -1020,51 +996,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { onClick={handleFilterModalOpen} className='px-3 py-2.5' /> - - -
- - - Export - -
- - -
- - } - > - -
@@ -1393,18 +1324,14 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { isClearable={true} /> - { - if (!Array.isArray(val)) { - formik.setFieldValue('period', val?.value || null); - } - }} + name='period' + placeholder='Masukkan Periode' + value={formik.values.period ?? ''} + onChange={formik.handleChange} + onBlur={formik.handleBlur} className={{ wrapper: 'w-full' }} - isClearable /> From 3945142966882ed6a324cbf59206275b4e623a17 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Mon, 4 May 2026 16:24:21 +0700 Subject: [PATCH 7/7] fix: add formikFlockSource to useEffect dependencies to set flock source raw data --- .../transfer-to-laying/TransferToLayingFormModal.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx index 91a56085..a1d30d5a 100644 --- a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx +++ b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx @@ -223,6 +223,8 @@ const TransferToLayingFormModal = () => { }, }); + const { flockSource: formikFlockSource } = formik.values; + const { formErrorList, close, handleFormSubmit } = useFormikErrorList(formik); const [selectedFlockSourceRawData, setSelectedFlockSourceRawData] = useState< @@ -455,13 +457,13 @@ const TransferToLayingFormModal = () => { useEffect(() => { if (isResponseSuccess(flockSourceRawData)) { - const selectedFlockSourceRawData = flockSourceRawData.data.find( + const currentSelectedFlockSourceRawData = flockSourceRawData.data.find( (item) => item.id === formik.values.flockSource?.value ); - setSelectedFlockSourceRawData(selectedFlockSourceRawData); + setSelectedFlockSourceRawData(currentSelectedFlockSourceRawData); } - }, [flockSourceRawData]); + }, [flockSourceRawData, formikFlockSource]); useEffect(() => { formik.setFieldValue('totalQuantity', totalTransferedChicken); @@ -625,6 +627,7 @@ const TransferToLayingFormModal = () => { >
{ />