[apps/cs] feat: 설문 삭제 기능 추가 (CS_UT02050106)
This commit is contained in:
@@ -45,6 +45,10 @@ export class SurveyApiService implements SurveyService {
|
||||
await client.put(`${ENDPOINT.CMS_SERVICE.SURVEY}/${srvySn}`, data);
|
||||
}
|
||||
|
||||
public async deleteSurvey(srvySn: number): Promise<void> {
|
||||
await client.delete(`${ENDPOINT.CMS_SERVICE.SURVEY}/${srvySn}`);
|
||||
}
|
||||
|
||||
public async getQuestionList(params: QuestionParams): Promise<QuestionList> {
|
||||
const response = await client.get<QuestionList>(
|
||||
`${ENDPOINT.CMS_SERVICE.SURVEY_QUESTION}`,
|
||||
|
||||
@@ -29,6 +29,13 @@ function DetailPage({ srvySn }: { srvySn: string }) {
|
||||
queryFn: () => SurveyApi.getSurveyInfo(parseInt(srvySn)),
|
||||
});
|
||||
|
||||
const { mutateAsync: deleteSurvey } = useMutationWrapper({
|
||||
mutationFn: () => SurveyApi.deleteSurvey(parseInt(srvySn)),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const postHistoryQuery = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POSTINGS, srvySn],
|
||||
queryFn: () =>
|
||||
@@ -77,6 +84,12 @@ function DetailPage({ srvySn }: { srvySn: string }) {
|
||||
},
|
||||
});
|
||||
|
||||
const handleDeleteSurvey = async () => {
|
||||
if (await confirm("삭제하시겠습니까?")) {
|
||||
deleteSurvey();
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeletePostingHistory = async () => {
|
||||
const data = postingTable.getFilteredSelectedRowModel().rows.map((row) => ({
|
||||
...row.original,
|
||||
@@ -101,7 +114,9 @@ function DetailPage({ srvySn }: { srvySn: string }) {
|
||||
<Button onClick={() => router.push(`${pathname}/modify`)}>
|
||||
수정
|
||||
</Button>
|
||||
<Button color="red">삭제</Button>
|
||||
<Button color="red" onClick={handleDeleteSurvey}>
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<ul className="flex flex-col">
|
||||
|
||||
Reference in New Issue
Block a user