feat: implement delete confirmation dialog component for better UX refactor: update supplier and role index pages to utilize new form dialog and delete confirm dialog components feat: add reusable form dialog component for creating and editing entities feat: introduce filter popover component for enhanced filtering options in data tables feat: create image preview button component for displaying images with modal preview feat: add page header component for consistent page layout feat: implement row actions component for handling actions on table rows feat: add status badge component for displaying entity statuses feat: create toggle status component for easily toggling entity states feat: implement draft save hook for auto-saving form data feat: add server table hook for managing server-side pagination and filtering feat: create utility functions for formatting dates and numbers feat: add constants for month names and measurement units
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { createDraftStore } from '@/lib/draft-store';
|
|
|
|
export type RawMaterialDraftData = {
|
|
name: string;
|
|
unit: string;
|
|
isActive: boolean;
|
|
variants: Array<{
|
|
id?: number | null;
|
|
variant: string;
|
|
price: number;
|
|
stock: number;
|
|
photo?: string;
|
|
}>;
|
|
};
|
|
|
|
export const rawMaterialDraftStore =
|
|
createDraftStore<RawMaterialDraftData>('raw-material-draft');
|
|
|
|
export function saveRawMaterialDraft(
|
|
type: 'create' | 'edit',
|
|
data: RawMaterialDraftData,
|
|
userId?: number,
|
|
rawMaterialId?: number,
|
|
): boolean {
|
|
return rawMaterialDraftStore.save(type, data, userId, rawMaterialId);
|
|
}
|
|
|
|
export function loadRawMaterialDraft(
|
|
type: 'create' | 'edit',
|
|
userId?: number,
|
|
rawMaterialId?: number,
|
|
): RawMaterialDraftData | null {
|
|
return rawMaterialDraftStore.load(type, userId, rawMaterialId);
|
|
}
|
|
|
|
export function clearRawMaterialDraft(
|
|
type: 'create' | 'edit',
|
|
userId?: number,
|
|
rawMaterialId?: number,
|
|
): void {
|
|
rawMaterialDraftStore.clear(type, userId, rawMaterialId);
|
|
}
|