-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Refactor/#337/applicant
- Loading branch information
Showing
3 changed files
with
103 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Button, { buttonSize } from "@/components/_common/Button"; | ||
import { AlertModal } from "@/components/_common/Modal"; | ||
import { useManageApplicant } from "./hooks/useManageApplicant"; | ||
|
||
const ApplicantButtons = ({ | ||
applicationId, | ||
steadyId, | ||
}: { | ||
applicationId: string; | ||
steadyId: string; | ||
}) => { | ||
const { handleClickAccept, handleClickReject } = useManageApplicant({ | ||
applicationId, | ||
steadyId, | ||
}); | ||
|
||
return ( | ||
<> | ||
<AlertModal | ||
trigger={ | ||
<Button className={`${buttonSize.sm} bg-st-red text-st-white`}> | ||
거절 | ||
</Button> | ||
} | ||
actionButton={ | ||
<Button | ||
className={`${buttonSize.sm} bg-st-red text-st-white`} | ||
onClick={handleClickReject} | ||
> | ||
거절 | ||
</Button> | ||
} | ||
> | ||
<div className="text-18 font-bold">거절 하시겠습니까?</div> | ||
</AlertModal> | ||
<AlertModal | ||
trigger={ | ||
<Button className={`${buttonSize.sm} bg-st-green text-st-white`}> | ||
승인 | ||
</Button> | ||
} | ||
actionButton={ | ||
<Button | ||
className={`${buttonSize.sm} bg-st-green text-st-white`} | ||
onClick={handleClickAccept} | ||
> | ||
승인 | ||
</Button> | ||
} | ||
> | ||
<div className="text-18 font-bold">승인 하시겠습니까?</div> | ||
</AlertModal> | ||
</> | ||
); | ||
}; | ||
|
||
export default ApplicantButtons; |
37 changes: 37 additions & 0 deletions
37
src/components/containers/applicant/hooks/useManageApplicant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useRouter } from "next/navigation"; | ||
import { useQueryClient } from "@tanstack/react-query"; | ||
import changeApplicationStatus from "@/services/application/changeApplicationStatus"; | ||
import { getApplicantListKey } from "@/constants/queryKeys"; | ||
|
||
export const useManageApplicant = ({ | ||
applicationId, | ||
steadyId, | ||
}: { | ||
applicationId: string; | ||
steadyId: string; | ||
}) => { | ||
const router = useRouter(); | ||
const queryClient = useQueryClient(); | ||
|
||
const handleClickAccept = async () => { | ||
await changeApplicationStatus(applicationId, { | ||
status: "ACCEPTED", | ||
}); | ||
await queryClient.invalidateQueries({ | ||
queryKey: getApplicantListKey(steadyId), | ||
}); | ||
router.replace(`/steady/applicant/${steadyId}`); | ||
}; | ||
|
||
const handleClickReject = async () => { | ||
await changeApplicationStatus(applicationId, { | ||
status: "REJECTED", | ||
}); | ||
await queryClient.invalidateQueries({ | ||
queryKey: getApplicantListKey(steadyId), | ||
}); | ||
router.replace(`/steady/applicant/${steadyId}`); | ||
}; | ||
|
||
return { handleClickAccept, handleClickReject }; | ||
}; |