오류류
This commit is contained in:
parent
dedc797c53
commit
0a8e8c52e2
@ -42,12 +42,11 @@ router.post(
|
||||
}
|
||||
);
|
||||
|
||||
// Update carMng
|
||||
// Update
|
||||
router.put(
|
||||
"/carmngUpdate/:id",
|
||||
"/Update/:id",
|
||||
[
|
||||
param("id").isUUID().withMessage("유효한 ID가 필요합니다"),
|
||||
body("car_code").optional().notEmpty().withMessage("car 코드가 필요합니다"),
|
||||
body("oem_id").optional().notEmpty().withMessage("고객사가 필요합니다"),
|
||||
body("companyId").optional().isUUID().withMessage("유효한 회사 ID가 필요합니다"),
|
||||
validate,
|
||||
@ -70,7 +69,7 @@ router.put(
|
||||
});
|
||||
}
|
||||
|
||||
const updatedcarMng = await Service.updateCarMng(req.params.id, req.body, req.user);
|
||||
const updatedcarMng = await Service.update(req.params.id, req.body, req.user);
|
||||
res.json(updatedcarMng);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
@ -80,7 +79,7 @@ router.put(
|
||||
|
||||
// Delete CarMng
|
||||
router.delete(
|
||||
"/carmngDelete/:id",
|
||||
"/Delete/:id",
|
||||
[
|
||||
param("id").isUUID().withMessage("유효한 ID가 필요합니다"),
|
||||
validate,
|
||||
|
@ -113,13 +113,13 @@ class ContractWbsService {
|
||||
return ResultData;
|
||||
}
|
||||
|
||||
async updateCarMng(id, updateData, currentUser) {
|
||||
async update(id, updateData, currentUser) {
|
||||
const { roleId, ...carMngFields } = updateData;
|
||||
|
||||
const carMng = await ContractWbs.findByPk(id);
|
||||
if (!carMng) throw new Error("CarMng not found");
|
||||
|
||||
// company_admin은 특정 필드를 수정할 수 없음 (예: role을 super_admin으로 변경 불가)
|
||||
// company_admin 권한 체크
|
||||
if (currentUser.role === "company_admin") {
|
||||
if (updateData.role && updateData.role === "super_admin") {
|
||||
throw new Error("super_admin 역할을 부여할 수 없습니다");
|
||||
@ -127,7 +127,13 @@ class ContractWbsService {
|
||||
updateData.companyId = currentUser.companyId;
|
||||
}
|
||||
|
||||
const updatedCarMng = await ContractWbs.update(carMngFields);
|
||||
// where 조건을 포함하여 업데이트
|
||||
await ContractWbs.update(carMngFields, {
|
||||
where: { id: id }
|
||||
});
|
||||
|
||||
// 업데이트된 데이터 조회
|
||||
const updatedCarMng = await ContractWbs.findByPk(id);
|
||||
|
||||
if (roleId) {
|
||||
const role = await Role.findOne({
|
||||
|
@ -47,7 +47,7 @@ const Page = () => {
|
||||
});
|
||||
return {
|
||||
...data,
|
||||
contractWbss: data.resultData.map((wbs: contractWbs) => ({ // resultData 사용
|
||||
resultData: data.resultData.map((wbs: contractWbs) => ({ // resultData 사용
|
||||
...wbs,
|
||||
})),
|
||||
};
|
||||
@ -86,7 +86,7 @@ const Page = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["carMngs"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["contractWbs"] }); // carMngs에서 contractWbs로 수정
|
||||
setIsOpen(false);
|
||||
toast({
|
||||
title: "영업 WBS 생성",
|
||||
@ -104,25 +104,25 @@ const Page = () => {
|
||||
|
||||
// Update user mutation
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: async (carData: Partial<contractWbs>) => {
|
||||
mutationFn: async (contractWbsData: Partial<contractWbs>) => {
|
||||
const { data } = await api.put<contractWbs>(
|
||||
`/api/v1/app/contractwbs/carmngUpdate/${carData.id}`,
|
||||
carData
|
||||
`/api/v1/app/contractwbs/Update/${contractWbsData.id}`,
|
||||
contractWbsData
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["carMngs"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["contractWbs"] }); // carMngs에서 contractWbs로 수정
|
||||
setIsOpen(false);
|
||||
setEditingUser(null);
|
||||
toast({
|
||||
title: "차종 수정",
|
||||
description: "차종 정보가 수정되었습니다.",
|
||||
title: "영업 WBS 수정",
|
||||
description: "영업 WBS 정보가 수정되었습니다.",
|
||||
});
|
||||
},
|
||||
onError: (error: AxiosError) => {
|
||||
toast({
|
||||
title: "차종 수정 실패",
|
||||
title: "영업 WBS 수정 실패",
|
||||
description: (error.response?.data as { message: string }).message,
|
||||
variant: "destructive",
|
||||
});
|
||||
@ -132,10 +132,10 @@ const Page = () => {
|
||||
// Delete user mutation
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
await api.delete(`/api/v1/app/contractwbs/carmngDelete/${id}`);
|
||||
await api.delete(`/api/v1/app/contractwbs/Delete/${id}`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["carMngs"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["contractWbs"] }); // carMngs에서 contractWbs로 수정
|
||||
toast({
|
||||
title: "영업 WBS 삭제",
|
||||
description: "영업 WBS가 삭제되었습니다.",
|
||||
@ -163,7 +163,7 @@ const Page = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "oem.oem_name", // 중첩 객체 접근 방식 확인
|
||||
header: "고객사명",
|
||||
header: "고객사",
|
||||
meta: {
|
||||
width: "120px",
|
||||
textAlign: "center",
|
||||
@ -179,31 +179,35 @@ const Page = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: "car_code",
|
||||
header: "차종코드",
|
||||
header: "WBS",
|
||||
meta: {
|
||||
width: "120px",
|
||||
textAlign: "center",
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "code.code_name",
|
||||
header: "차종grade",
|
||||
accessorKey: "writer",
|
||||
header: "등록자",
|
||||
meta: {
|
||||
width: "120px",
|
||||
textAlign: "center",
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "car_desc",
|
||||
header: "설명",
|
||||
accessorKey: "updatedAt",
|
||||
header: "등록일",
|
||||
meta: {
|
||||
width: "200px",
|
||||
textAlign: "center",
|
||||
},
|
||||
cell: ({ row }) => {
|
||||
const date = new Date(row.original.updatedAt);
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "isActive",
|
||||
header: "활성화",
|
||||
header: "상태",
|
||||
meta: {
|
||||
width: "100px",
|
||||
textAlign: "center",
|
||||
|
@ -19,5 +19,4 @@ export interface PaginatedResponse {
|
||||
total: number;
|
||||
totalPages: number;
|
||||
currentPage: number;
|
||||
resultData: contractWbs[]; // contractWbss가 아닌 resultData로 수정
|
||||
}
|
||||
resultData: contractWbs[];
|
Loading…
Reference in New Issue
Block a user