feat(FE-42): add Product Category API and form validation schema

This commit is contained in:
rstubryan
2025-10-07 18:56:58 +07:00
parent 4f0e02a93b
commit 3cac49725f
3 changed files with 37 additions and 0 deletions
@@ -0,0 +1,10 @@
import * as Yup from 'yup';
export const ProductCategoryFormSchema = Yup.object({
code: Yup.string().required('Kode wajib diisi!').max(3, 'Kode kategori produk melebihi 3 karakter!'),
name: Yup.string().required('Nama wajib diisi!'),
});
export const UpdateProductCategoryFormSchema = ProductCategoryFormSchema;
export type ProductCategoryFormValues = Yup.InferType<typeof ProductCategoryFormSchema>;
+11
View File
@@ -24,6 +24,11 @@ import {
UpdateWarehousePayload,
Warehouse,
} from '@/types/api/master-data/warehouse';
import {
CreateProductCategoryPayload,
ProductCategory,
UpdateProductCategoryPayload,
} from '@/types/api/master-data/product-category';
export const UomApi = new BaseApiService<
Uom,
@@ -54,3 +59,9 @@ export const WarehouseApi = new BaseApiService<
CreateWarehousePayload,
UpdateWarehousePayload
>('/master-data/warehouses');
export const ProductCategoryApi = new BaseApiService<
ProductCategory,
CreateProductCategoryPayload,
UpdateProductCategoryPayload
>('/master-data/product-categories');
+16
View File
@@ -0,0 +1,16 @@
import { BaseMetadata } from '@/types/api/api-general';
export type BaseProductCategory = {
id: number;
code: string;
name: string;
};
export type ProductCategory = BaseMetadata & BaseProductCategory;
export type CreateProductCategoryPayload = {
code: string;
name: string;
};
export type UpdateProductCategoryPayload = CreateProductCategoryPayload;