+ {type !== 'add' && (
+
+
- {nonstockFormErrorMessage && (
-
-
- {nonstockFormErrorMessage}
+ {type !== 'edit' && (
+
+ )}
)}
- >
- )}
-
-
+
+ {type !== 'detail' && (
+
+
+
+
+
+ )}
+
+
+ {nonstockFormErrorMessage && (
+
+
+ {nonstockFormErrorMessage}
+
+ )}
+
+
+
+ {type !== 'add' && (
+
+ )}
+ >
);
};
diff --git a/src/config/constant.ts b/src/config/constant.ts
index 870002bf..bbdd3f48 100644
--- a/src/config/constant.ts
+++ b/src/config/constant.ts
@@ -1,145 +1,155 @@
-export const MAIN_DRAWER_LINKS = [
- {
- title: 'Dashboard',
- link: '/dashboard',
- icon: 'gg:chart',
- },
+type MAIN_DRAWER_MENU = {
+ title: string;
+ link: string;
+ icon: string;
+ submenu?: MAIN_DRAWER_MENU[];
+};
- {
- title: 'Persediaan',
- link: '/inventory',
- icon: 'mdi:warehouse',
- submenu: [
- {
- title: 'Product',
- link: '/inventory/product',
- icon: 'mdi:package-variant-closed',
- },
- {
- title: 'Penyesuaian Stok',
- link: '/inventory/adjustment',
- icon: 'mdi:database-edit',
- },
- {
- title: 'Transfer Stok',
- link: '/inventory/movement',
- icon: 'mdi:swap-horizontal',
- },
- ],
- },
+export const MAIN_DRAWER_LINKS: MAIN_DRAWER_MENU[] = [
+ {
+ title: 'Dashboard',
+ link: '/dashboard',
+ icon: 'gg:chart',
+ },
- {
- title: 'Master Data',
- link: '/master-data',
- icon: 'majesticons:data-line',
- submenu: [
- {
- title: 'Product',
- link: '/master-data/product',
- icon: 'fluent-mdl2:product-variant',
- },
- {
- title: 'Product Category',
- link: '/master-data/product-category',
- icon: 'carbon:categories',
- },
- {
- title: 'Bank',
- link: '/master-data/bank',
- icon: 'mdi:bank-outline',
- },
- {
- title: 'Area',
- link: '/master-data/area',
- icon: 'majesticons:map-marker-area-line',
- },
- {
- title: 'Location',
- link: '/master-data/location',
- icon: 'mingcute:location-line',
- },
- {
- title: 'Kandang',
- link: '/master-data/kandang',
- icon: 'mdi:farm-home-outline',
- },
- {
- title: 'Warehouse',
- link: '/master-data/warehouse',
- icon: 'hugeicons:warehouse',
- },
- {
- title: 'Customer',
- link: '/master-data/customer',
- icon: 'ix:customer',
- },
- {
- title: 'UOM',
- link: '/master-data/uom',
- icon: 'lsicon:measure-outline',
- },
- {
- title: 'Non-Stock',
- link: '/master-data/nonstock',
- icon: 'fluent:box-32-regular',
- },
- {
- title: 'FCR',
- link: '/master-data/FCR',
- icon: 'fluent:food-chicken-leg-16-regular',
- },
- {
- title: 'Supplier',
- link: '/master-data/supplier',
- icon: 'material-symbols:add-business-outline-rounded',
- },
- ],
- },
+ {
+ title: 'Persediaan',
+ link: '/inventory',
+ icon: 'mdi:warehouse',
+ submenu: [
+ {
+ title: 'Product',
+ link: '/inventory/product',
+ icon: 'mdi:package-variant-closed',
+ },
+ {
+ title: 'Penyesuaian Stok',
+ link: '/inventory/adjustment',
+ icon: 'mdi:database-edit',
+ },
+ {
+ title: 'Transfer Stok',
+ link: '/inventory/movement',
+ icon: 'mdi:swap-horizontal',
+ },
+ ],
+ },
+
+ {
+ title: 'Master Data',
+ link: '/master-data',
+ icon: 'majesticons:data-line',
+ submenu: [
+ {
+ title: 'Product',
+ link: '/master-data/product',
+ icon: 'fluent-mdl2:product-variant',
+ },
+ {
+ title: 'Product Category',
+ link: '/master-data/product-category',
+ icon: 'carbon:categories',
+ },
+ {
+ title: 'Bank',
+ link: '/master-data/bank',
+ icon: 'mdi:bank-outline',
+ },
+ {
+ title: 'Area',
+ link: '/master-data/area',
+ icon: 'majesticons:map-marker-area-line',
+ },
+ {
+ title: 'Location',
+ link: '/master-data/location',
+ icon: 'mingcute:location-line',
+ },
+ {
+ title: 'Kandang',
+ link: '/master-data/kandang',
+ icon: 'mdi:farm-home-outline',
+ },
+ {
+ title: 'Warehouse',
+ link: '/master-data/warehouse',
+ icon: 'hugeicons:warehouse',
+ },
+ {
+ title: 'Customer',
+ link: '/master-data/customer',
+ icon: 'ix:customer',
+ },
+ {
+ title: 'UOM',
+ link: '/master-data/uom',
+ icon: 'lsicon:measure-outline',
+ },
+ {
+ title: 'Non-Stock',
+ link: '/master-data/nonstock',
+ icon: 'fluent:box-32-regular',
+ },
+ {
+ title: 'FCR',
+ link: '/master-data/fcr',
+ icon: 'fluent:food-chicken-leg-16-regular',
+ },
+ {
+ title: 'Supplier',
+ link: '/master-data/supplier',
+ icon: 'material-symbols:add-business-outline-rounded',
+ },
+ ],
+ },
] as const;
export const ROWS_OPTIONS = [
- {
- label: '10',
- value: 10,
- },
- {
- label: '20',
- value: 20,
- },
- {
- label: '50',
- value: 50,
- },
- {
- label: '100',
- value: 100,
- },
+ {
+ label: '10',
+ value: 10,
+ },
+ {
+ label: '20',
+ value: 20,
+ },
+ {
+ label: '50',
+ value: 50,
+ },
+ {
+ label: '100',
+ value: 100,
+ },
];
export const WAREHOUSE_TYPE_OPTIONS = [
- {
- label: 'AREA',
- value: 'AREA',
- },
- {
- label: 'LOKASI',
- value: 'LOKASI',
- },
- {
- label: 'KANDANG',
- value: 'KANDANG',
- },
+ {
+ label: 'AREA',
+ value: 'AREA',
+ },
+ {
+ label: 'LOKASI',
+ value: 'LOKASI',
+ },
+ {
+ label: 'KANDANG',
+ value: 'KANDANG',
+ },
];
export const PRODUCT_FLAG_OPTIONS = [
- {label: 'DOC', value: 'DOC'},
- {label: 'PAKAN', value: 'PAKAN'},
- {label: 'PRE-STARTER', value: 'PRE-STARTER'},
- {label: 'STARTER', value: 'STARTER'},
- {label: 'FINISHER', value: 'FINISHER'},
- {label: 'OVK', value: 'OVK'},
- {label: 'OBAT', value: 'OBAT'},
- {label: 'VITAMIN', value: 'VITAMIN'},
- {label: 'KIMIA', value: 'KIMIA'},
+ { label: 'DOC', value: 'DOC' },
+ { label: 'PAKAN', value: 'PAKAN' },
+ { label: 'PRE-STARTER', value: 'PRE-STARTER' },
+ { label: 'STARTER', value: 'STARTER' },
+ { label: 'FINISHER', value: 'FINISHER' },
+ { label: 'OVK', value: 'OVK' },
+ { label: 'OBAT', value: 'OBAT' },
+ { label: 'VITAMIN', value: 'VITAMIN' },
+ { label: 'KIMIA', value: 'KIMIA' },
];
+export const SUPPLIER_FLAG_OPTIONS = [
+ { label: 'EKSPEDISI', value: 'EKSPEDISI' },
+];
diff --git a/src/services/api/master-data.ts b/src/services/api/master-data.ts
index 7429b8ef..259bff8b 100644
--- a/src/services/api/master-data.ts
+++ b/src/services/api/master-data.ts
@@ -39,6 +39,21 @@ import {
Supplier,
UpdateSupplierPayload,
} from '@/types/api/master-data/supplier';
+import {
+ CreateNonstockPayload,
+ Nonstock,
+ UpdateNonstockPayload,
+} from '@/types/api/master-data/nonstock';
+import {
+ Bank,
+ CreateBankPayload,
+ UpdateBankPayload,
+} from '@/types/api/master-data/bank';
+import {
+ CreateFcrPayload,
+ Fcr,
+ UpdateFcrPayload,
+} from '@/types/api/master-data/fcr';
export const UomApi = new BaseApiService<
Uom,
@@ -86,4 +101,22 @@ export const SupplierApi = new BaseApiService<
Supplier,
CreateSupplierPayload,
UpdateSupplierPayload
->('/master-data/suppliers');
\ No newline at end of file
+>('/master-data/suppliers');
+
+export const NonstockApi = new BaseApiService<
+ Nonstock,
+ CreateNonstockPayload,
+ UpdateNonstockPayload
+>('/master-data/nonstocks');
+
+export const BankApi = new BaseApiService<
+ Bank,
+ CreateBankPayload,
+ UpdateBankPayload
+>('/master-data/banks');
+
+export const FcrApi = new BaseApiService<
+ Fcr,
+ CreateFcrPayload,
+ UpdateFcrPayload
+>('/master-data/fcrs');
diff --git a/src/services/api/master-data/nonstock.ts b/src/services/api/master-data/nonstock.ts
deleted file mode 100644
index 7340e37b..00000000
--- a/src/services/api/master-data/nonstock.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-import axios from 'axios';
-import { httpClient } from '@/services/http/client';
-
-import {
- CreateNonstockPayload,
- DeleteNonstockResponse,
- NonstockResponse,
- UpdateNonstockPayload,
-} from '@/types/api/master-data/nonstock';
-
-export const getNonstock = async (nonstockId: number) => {
- try {
- const getNonstockRes = await httpClient
(
- `/master-data/nonstocks/${nonstockId}`
- );
-
- return getNonstockRes;
- } catch (error: unknown) {
- if (axios.isAxiosError(error)) {
- return error.response?.data;
- }
-
- return undefined;
- }
-};
-
-export const createNonstock = async (payload: CreateNonstockPayload) => {
- try {
- const createNonstockRes = await httpClient(
- '/master-data/nonstocks',
- {
- method: 'POST',
- body: payload,
- }
- );
-
- return createNonstockRes;
- } catch (error: unknown) {
- if (axios.isAxiosError(error)) {
- return error.response?.data;
- }
-
- return undefined;
- }
-};
-
-export const updateNonstock = async (
- nonstockId: number,
- payload: UpdateNonstockPayload
-) => {
- try {
- const updateNonstockRes = await httpClient(
- `/master-data/nonstocks/${nonstockId}`,
- {
- method: 'PATCH',
- body: payload,
- }
- );
-
- return updateNonstockRes;
- } catch (error: unknown) {
- if (axios.isAxiosError(error)) {
- return error.response?.data;
- }
-
- return undefined;
- }
-};
-
-export const deleteNonstock = async (nonstockId: number) => {
- try {
- const deleteNonstockRes = await httpClient(
- `/master-data/nonstocks/${nonstockId}`,
- {
- method: 'DELETE',
- }
- );
-
- return deleteNonstockRes;
- } catch (error) {
- if (axios.isAxiosError(error)) {
- return error.response?.data;
- }
-
- return undefined;
- }
-};
diff --git a/src/types/api/api-general.d.ts b/src/types/api/api-general.d.ts
index 8a4c4de7..6a3fc6be 100644
--- a/src/types/api/api-general.d.ts
+++ b/src/types/api/api-general.d.ts
@@ -53,3 +53,16 @@ export type BaseMetadata = {
export type Override = Omit &
Overrides;
+
+export type flags =
+ | 'PAKAN'
+ | 'OBAT'
+ | 'VITAMIN'
+ | 'KIMIA'
+ | 'EKSPEDISI'
+ | 'IS_ACTIVE'
+ | 'DOC'
+ | 'PRE-STARTER'
+ | 'STARTER'
+ | 'FINISHER'
+ | 'OVK';
diff --git a/src/types/api/master-data/bank.d.ts b/src/types/api/master-data/bank.d.ts
new file mode 100644
index 00000000..0b23b446
--- /dev/null
+++ b/src/types/api/master-data/bank.d.ts
@@ -0,0 +1,20 @@
+import { BaseMetadata } from '@/types/api/api-general';
+
+export type BaseBank = {
+ id: number;
+ name: string;
+ alias: string;
+ owner?: string;
+ account_number: string;
+};
+
+export type Bank = BaseMetadata & BaseBank;
+
+export type CreateBankPayload = {
+ name: string;
+ alias: string;
+ account_number: string;
+ owner?: string;
+};
+
+export type UpdateBankPayload = CreateBankPayload;
diff --git a/src/types/api/master-data/fcr.d.ts b/src/types/api/master-data/fcr.d.ts
new file mode 100644
index 00000000..45ad25e5
--- /dev/null
+++ b/src/types/api/master-data/fcr.d.ts
@@ -0,0 +1,30 @@
+import { BaseMetadata } from '@/types/api/api-general';
+
+export type BaseFcr = {
+ id: number;
+ name: string;
+};
+
+export type FcrStandard = {
+ id: number;
+ weight: number;
+ fcr_number: number;
+ mortality: number;
+};
+
+export type Fcr = BaseMetadata & BaseFcr;
+
+export type FcrWithStandards = Fcr & {
+ fcr_standards: FcrStandard[];
+};
+
+export type CreateFcrPayload = {
+ name: string;
+ fcr_standards: {
+ weight: number;
+ fcr_number: number;
+ mortality: number;
+ }[];
+};
+
+export type UpdateFcrPayload = CreateFcrPayload;
diff --git a/src/types/api/master-data/nonstock.d.ts b/src/types/api/master-data/nonstock.d.ts
index 682f7852..e4e79d8e 100644
--- a/src/types/api/master-data/nonstock.d.ts
+++ b/src/types/api/master-data/nonstock.d.ts
@@ -1,18 +1,23 @@
-import { BaseApiResponse } from '@/types/api/api-general';
+import { BaseApiResponse, BaseMetadata, flags } from '@/types/api/api-general';
+import { BaseUom } from '@/types/api/master-data/uom';
+import { BaseSupplier } from '@/types/api/master-data/supplier';
-export type Nonstock = {
+export type BaseNonstock = {
id: number;
name: string;
+ uom_id: number;
+ uom: BaseUom;
+ suppliers: BaseSupplier[];
+ flags: flags[];
};
+export type Nonstock = BaseMetadata & BaseNonstock;
+
export type CreateNonstockPayload = {
name: string;
+ uom_id: number;
+ supplier_ids: number[];
+ flags: flags[];
};
export type UpdateNonstockPayload = CreateNonstockPayload;
-
-export type NonstockResponse = BaseApiResponse;
-
-export type NonstocksResponse = BaseApiResponse;
-
-export type DeleteNonstockResponse = BaseApiResponse;