feat: common code group management (separate table + CRUD)
This commit is contained in:
+25
-1
@@ -328,11 +328,35 @@ export function setupMocks(instance: AxiosInstance) {
|
||||
return [200, { success: true, message: 'OK', data: result }];
|
||||
});
|
||||
|
||||
// Shared group store derived from codes
|
||||
const getGroups = () => [...new Set(s.commonCodes.map((c: any) => c.groupCode))];
|
||||
|
||||
mock.onGet('/common-codes/groups').reply(() => {
|
||||
const groups = [...new Set(s.commonCodes.map((c: any) => c.groupCode))];
|
||||
const groupCodes = getGroups();
|
||||
const groups = groupCodes.map((gc: string, i: number) => ({
|
||||
id: i + 1,
|
||||
groupCode: gc,
|
||||
groupName: gc.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, (c: string) => c.toUpperCase()),
|
||||
description: `${gc} management`,
|
||||
sortOrder: i + 1,
|
||||
}));
|
||||
return [200, { success: true, message: 'OK', data: groups }];
|
||||
});
|
||||
|
||||
mock.onPost('/common-codes/groups').reply((config) => {
|
||||
const body = JSON.parse(config.data);
|
||||
return [200, { success: true, message: '그룹 생성 완료', data: { id: Date.now(), ...body } }];
|
||||
});
|
||||
|
||||
mock.onPut(/\/common-codes\/groups\/.+/).reply((config) => {
|
||||
const body = JSON.parse(config.data);
|
||||
return [200, { success: true, message: '그룹 수정 완료', data: { ...JSON.parse(config.data), groupCode: config.url?.split('/').pop() } }];
|
||||
});
|
||||
|
||||
mock.onDelete(/\/common-codes\/groups\/.+/).reply((config) => {
|
||||
return [200, { success: true, message: '그룹 삭제 완료', data: null }];
|
||||
});
|
||||
|
||||
mock.onPost('/common-codes').reply((config) => {
|
||||
const body = JSON.parse(config.data);
|
||||
const newCode = { codeId: Date.now(), ...body };
|
||||
|
||||
Reference in New Issue
Block a user