Skip to content

Commit

Permalink
feat: 반영 안 되는 오류 픽스
Browse files Browse the repository at this point in the history
  • Loading branch information
JJIIIINN committed Dec 25, 2023
1 parent 7ec865e commit 5469037
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function App() {
keepPreviousData: true,
refetchOnWindowFocus: true,
refetchOnMount: true,
staleTime: 2000,
staleTime: 60000,
retry: 1,
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/Excel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Excel = () => {
{data && !data[excelTab]?.length ? (
<NoData />
) : (
<ExcelBody data={data!} />
<ExcelBody data={data!} refetch={refetch} />
)}
</Container>
);
Expand Down
14 changes: 12 additions & 2 deletions src/components/main/ExcelCashPaymentTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import ExcelValue from "./ExcelValue";
import { useEditExcelCash } from "../../utils/api/Allowance";
import { debounce } from "lodash";

const ExcelCashPaymentTabBody = ({ data }: { data: cashPaymentTabType }) => {
const ExcelCashPaymentTabBody = ({
data,
refetch,
}: {
data: cashPaymentTabType;
refetch: () => void;
}) => {
const { form, setForm, handleChange } = useForm({
address: "",
depositType: "",
Expand Down Expand Up @@ -39,7 +45,11 @@ const ExcelCashPaymentTabBody = ({ data }: { data: cashPaymentTabType }) => {
}, []);

const { id, ...rest } = form;
const { mutate } = useEditExcelCash({ id: data.id, excelLine: rest });
const { mutate } = useEditExcelCash({
id: data.id,
excelLine: rest,
refetch,
});

// eslint-disable-next-line react-hooks/exhaustive-deps
const editExcelForm = useCallback(
Expand Down
30 changes: 26 additions & 4 deletions src/components/main/ExcelMainBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ import NewComerHonorableAllowanceTabBody from "./NewComerHonorableAllowanceTabBo
import ExcelPaymentStoppedTabBody from "./ExcelPaymentStoppedTabBody";
import ExcelPaymentTargetTabBody from "./ExcelPaymentTargetTabBody";

const ExcelMainBody = ({ data }: { data: getExcelResponseDto }) => {
const ExcelMainBody = ({
data,
refetch,
}: {
data: getExcelResponseDto;
refetch: () => void;
}) => {
const { excelTab } = useExcelTabTypeState();
const { excelType } = useExcelTypeState();

Expand All @@ -32,6 +38,7 @@ const ExcelMainBody = ({ data }: { data: getExcelResponseDto }) => {
data &&
data[excelTab].map((item, idx) => (
<NewComerWarVeteranTabBody
refetch={refetch}
key={idx}
data={item}
/>
Expand All @@ -42,6 +49,7 @@ const ExcelMainBody = ({ data }: { data: getExcelResponseDto }) => {
data &&
data[excelTab].map((item, idx) => (
<NewComerHonorableAllowanceTabBody
refetch={refetch}
key={idx}
data={item}
/>
Expand All @@ -52,6 +60,7 @@ const ExcelMainBody = ({ data }: { data: getExcelResponseDto }) => {
data &&
data[excelTab].map((item, idx) => (
<NewComerWarVeteranSpouseTabBody
refetch={refetch}
key={idx}
data={item}
/>
Expand All @@ -62,6 +71,7 @@ const ExcelMainBody = ({ data }: { data: getExcelResponseDto }) => {
data &&
data[excelTab].map((item, idx) => (
<NewComerWarVeteranTabBody
refetch={refetch}
key={idx}
data={item}
/>
Expand All @@ -72,21 +82,33 @@ const ExcelMainBody = ({ data }: { data: getExcelResponseDto }) => {
return (
data &&
data[excelTab].map((item, idx) => (
<ExcelPaymentStoppedTabBody key={idx} data={item} />
<ExcelPaymentStoppedTabBody
key={idx}
data={item}
refetch={refetch}
/>
))
);
case "paymentTargetTab":
return (
data &&
data[excelTab].map((item, idx) => (
<ExcelPaymentTargetTabBody key={idx} data={item} />
<ExcelPaymentTargetTabBody
key={idx}
data={item}
refetch={refetch}
/>
))
);
case "cashPaymentTab":
return (
data &&
data[excelTab].map((item, idx) => (
<ExcelCashPaymentTabBody key={idx} data={item} />
<ExcelCashPaymentTabBody
key={idx}
data={item}
refetch={refetch}
/>
))
);
}
Expand Down
8 changes: 7 additions & 1 deletion src/components/main/ExcelPaymentStoppedTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { useEditExcelStopped } from "../../utils/api/Allowance";

const ExcelPaymentStoppedTabBody = ({
data,
refetch,
}: {
data: paymentStoppedTabType;
refetch: () => void;
}) => {
const { form, setForm, handleChange } = useForm({
accountHolder: "",
Expand Down Expand Up @@ -51,7 +53,11 @@ const ExcelPaymentStoppedTabBody = ({
}, []);

const { id, ...rest } = form;
const { mutate } = useEditExcelStopped({ id: data.id, excelLine: rest });
const { mutate } = useEditExcelStopped({
id: data.id,
excelLine: rest,
refetch,
});

// eslint-disable-next-line react-hooks/exhaustive-deps
const editExcelForm = useCallback(
Expand Down
14 changes: 12 additions & 2 deletions src/components/main/ExcelPaymentTargetTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import ExcelValue from "./ExcelValue";
import { useEditExcelTarget } from "../../utils/api/Allowance";
import { debounce } from "lodash";

const ExcelPaymentTargetTabBody = ({ data }: { data: paymentTargetTabType }) => {
const ExcelPaymentTargetTabBody = ({
data,
refetch,
}: {
data: paymentTargetTabType;
refetch: () => void;
}) => {
const { form, setForm, handleChange } = useForm({
accountHolder: "",
address: "",
Expand Down Expand Up @@ -40,7 +46,11 @@ const ExcelPaymentTargetTabBody = ({ data }: { data: paymentTargetTabType }) =>
} = form;

const { id, ...rest } = form;
const { mutate } = useEditExcelTarget({ id: data.id, excelLine: rest });
const { mutate } = useEditExcelTarget({
id: data.id,
excelLine: rest,
refetch,
});

useEffect(() => {
setForm(data);
Expand Down
3 changes: 3 additions & 0 deletions src/components/main/NewComerHonorableAllowanceTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { useEditExcelNewcomer } from "../../utils/api/Allowance";

const NewComerHonorableAllowanceTabBody = ({
data,
refetch,
}: {
data: newComerTabType;
refetch: () => void;
}) => {
const { form, setForm, handleChange } = useForm({
accountHolder: "",
Expand Down Expand Up @@ -61,6 +63,7 @@ const NewComerHonorableAllowanceTabBody = ({
const { mutate } = useEditExcelNewcomer({
id: data.id,
excelLine: rest as any,
refetch,
});

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
3 changes: 3 additions & 0 deletions src/components/main/NewComerWarVeteranSpouseTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { useEditExcelNewcomer } from "../../utils/api/Allowance";
// 전입일 < 신청일
const NewComerWarVeteranSpouseTabBody = ({
data,
refetch,
}: {
data: newComerTabType;
refetch: () => void;
}) => {
const { form, setForm, handleChange } = useForm({
accountHolder: "",
Expand Down Expand Up @@ -60,6 +62,7 @@ const NewComerWarVeteranSpouseTabBody = ({
const { mutate } = useEditExcelNewcomer({
id: data.id,
excelLine: rest as any,
refetch,
});

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
9 changes: 8 additions & 1 deletion src/components/main/NewComerWarVeteranTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { newComerTabType } from "../../models/response";
import { useEditExcelNewcomer } from "../../utils/api/Allowance";
import { debounce } from "lodash";

const NewComerWarVeteranTabBody = ({ data }: { data: newComerTabType }) => {
const NewComerWarVeteranTabBody = ({
data,
refetch,
}: {
data: newComerTabType;
refetch: () => void;
}) => {
const { form, setForm, handleChange } = useForm({
id: 0,
serialNumber: "",
Expand Down Expand Up @@ -49,6 +55,7 @@ const NewComerWarVeteranTabBody = ({ data }: { data: newComerTabType }) => {
const { mutate } = useEditExcelNewcomer({
id: data.id,
excelLine: rest as any,
refetch
});

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
4 changes: 4 additions & 0 deletions src/models/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@ export interface userLoginRequestDto {

export interface editExcelTargetRequestDto {
excelLine: Omit<paymentTargetTabType, "id">;
refetch: () => void;
id: number;
}

export interface editExcelCashRequestDto {
excelLine: Omit<cashPaymentTabType, "id">;
refetch: () => void;
id: number;
}

export interface editExcelNewcomerRequestDto {
excelLine: Omit<newComerTabType, "id">;
refetch: () => void;
id: number;
}

export interface editExcelStoppedRequestDto {
excelLine: Omit<paymentStoppedTabType, "id">;
refetch: () => void;
id: number;
}
40 changes: 32 additions & 8 deletions src/utils/api/Allowance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,38 +97,62 @@ export const useExportExcel = (type: excelFileType) => {
export const useEditExcelTarget = ({
id,
excelLine,
refetch,
}: editExcelTargetRequestDto) => {
return useMutation(async () =>
instance.patch(`${path}/target/${id}`, excelLine)
return useMutation(
async () => instance.patch(`${path}/target/${id}`, excelLine),
{
onSuccess: () => {
refetch();
},
}
);
};

//보훈수당 엑셀 파일 수정-현금 지급
export const useEditExcelCash = ({
id,
excelLine,
refetch,
}: editExcelCashRequestDto) => {
return useMutation(async () =>
instance.patch(`${path}/cash/${id}`, excelLine)
return useMutation(
async () => instance.patch(`${path}/cash/${id}`, excelLine),
{
onSuccess: () => {
refetch();
},
}
);
};

//보훈수당 엑셀 파일 수정-신규자
export const useEditExcelNewcomer = ({
id,
excelLine,
refetch,
}: editExcelNewcomerRequestDto) => {
return useMutation(async () =>
instance.patch(`${path}/newcomer/${id}`, excelLine)
return useMutation(
async () => instance.patch(`${path}/newcomer/${id}`, excelLine),
{
onSuccess: () => {
refetch();
},
}
);
};

//보훈수당 엑셀 파일 수정-지급중지자
export const useEditExcelStopped = ({
id,
excelLine,
refetch,
}: editExcelStoppedRequestDto) => {
return useMutation(async () =>
instance.patch(`${path}/stopped/${id}`, excelLine)
return useMutation(
async () => instance.patch(`${path}/stopped/${id}`, excelLine),
{
onSuccess: () => {
refetch();
},
}
);
};

0 comments on commit 5469037

Please sign in to comment.