@@ -7,6 +7,7 @@ import WarningModal from '../../components/application/WarningModal'
77import { ApplicationDetailsSkeleton } from '../../skeletons/applicationDetailsSkeleton' ;
88import axiosClient from '../../redux/actions/axiosconfig'
99import { getStatusClass } from "../../components/application/ApplicationStatus" ;
10+ import { IoClose } from "react-icons/io5" ;
1011
1112
1213interface Application {
@@ -25,6 +26,7 @@ interface Application {
2526 title :string
2627 } ,
2728 status :string ,
29+ comment :string ,
2830 resume :string ,
2931 essay :string ,
3032 createdAt : string
@@ -36,6 +38,9 @@ const ApplicationDetails = () => {
3638 const [ isLoading , setIsLoading ] = useState ( true ) ;
3739 const [ application , setApplication ] = useState < Application | null > ( null )
3840 const [ status , setStatus ] = useState ( "" )
41+ const [ toggleModal , setToggleModal ] = useState ( false )
42+ const [ comment , setComment ] = useState ( "" )
43+ const [ error , setError ] = useState ( "" )
3944
4045 const getJobApplication = async ( ) => {
4146 const query = `query GetOneJobApplication($input: SingleJobApplicationInput!) {
@@ -55,6 +60,7 @@ const ApplicationDetails = () => {
5560 title
5661 }
5762 status
63+ comment
5864 essay
5965 resume
6066 createdAt
@@ -94,6 +100,12 @@ const ApplicationDetails = () => {
94100 if ( ! status ) {
95101 return
96102 }
103+
104+ if ( status === 'rejected' && ! comment ) {
105+ setError ( 'Comment can not be empty' )
106+ return
107+ }
108+
97109 const toastId = toast . loading ( 'Updating status...' ) ;
98110 try {
99111 const mutation = `mutation ChangeApplicationStatus($input: StatusInput!) {
@@ -113,6 +125,7 @@ const ApplicationDetails = () => {
113125 title
114126 }
115127 status
128+ comment
116129 essay
117130 resume
118131 createdAt
@@ -126,7 +139,8 @@ const ApplicationDetails = () => {
126139 variables :{
127140 input :{
128141 applicationId :params . appId ,
129- status : status
142+ status : status ,
143+ comment : comment
130144 }
131145 }
132146 } ,
@@ -140,6 +154,8 @@ const ApplicationDetails = () => {
140154
141155 toast . success ( 'Status updated successfully' )
142156 setApplication ( response . data . data . changeApplicationStatus )
157+ setToggleModal ( false )
158+ setComment ( "" )
143159 } catch ( err ) {
144160 toast . dismiss ( toastId ) ;
145161 toast . error ( 'Failed to update status' )
@@ -154,6 +170,11 @@ const ApplicationDetails = () => {
154170 } , [ ] )
155171
156172 useEffect ( ( ) => {
173+ if ( status === 'rejected' ) {
174+ setToggleModal ( true )
175+ return
176+ }
177+
157178 if ( status && status !== application ?. status ) {
158179 ( async ( ) => {
159180 await updateStatus ( )
@@ -164,6 +185,20 @@ const ApplicationDetails = () => {
164185
165186 return (
166187 < >
188+ { toggleModal && < div className = "fixed top-0 left-0 flex items-center justify-center w-full h-screen bg-black bg-opacity-50 z-50" >
189+ < div className = "w-80 flex flex-col gap-4 rounded-md items-center bg-primary" >
190+ < div className = "flex py-2 items-center justify-between w-[90%]" >
191+ < h2 className = "text-white" > Reject Applicant</ h2 >
192+ < IoClose color = "white" size = { 20 } onClick = { ( ) => { setStatus ( "" ) ; setToggleModal ( false ) } } />
193+ </ div >
194+ < div className = "flex gap-2 flex-col w-[90%]" >
195+ < label className = "text-white text-sm" > Comment</ label >
196+ < textarea className = "w-full p-1 rounded-sm h-32 bg-transparent border border-white text-white" onChange = { ( e ) => setComment ( e . target . value ) } > </ textarea >
197+ < div className = "text-sm text-red-500" > { error } </ div >
198+ </ div >
199+ < button disabled = { ! comment } className = { `rounded-md flex items-center justify-center bg-green ${ comment ? 'opacity-100 cursor-pointer' : 'opacity-70 cursor-not-allowed' } text-white px-4 py-1 mb-6` } onClick = { updateStatus } > Submit</ button >
200+ </ div >
201+ </ div > }
167202 < div className = "flex flex-col min-w-full items-center dark:bg-dark-frame-bg min-h-screen" >
168203 < div className = "w-full max-w-6xl mt-10 p-6" >
169204 { isLoading ? (
@@ -181,18 +216,19 @@ const ApplicationDetails = () => {
181216 < p className = "text-gray-500 dark:text-gray-300" > < span className = "font-medium" > Gender: </ span > { application . userId ?. gender } </ p >
182217 < p className = "text-gray-500 dark:text-gray-300" > < span className = "font-medium" > Date of Submission:</ span > { application . createdAt } </ p >
183218 < p className = "text-gray-500 dark:text-gray-300 font-medium" > Resume:{ " " } < a href = { application . resume } target = "_blank" rel = "noreferrer noopener" className = "text-blue-500 font-normal hover:underline" > View Resume </ a > </ p >
184- < div className = "flex flex-col gap-4" >
185- < h2 className = "text-lg text-white" > Interest essay:</ h2 >
186- < div className = "text-white" dangerouslySetInnerHTML = { { __html :application . essay } } > </ div >
187- </ div >
188219 < div className = "flex items-center gap-2 text-white" >
189- < span className = "font-medium" > Status:</ span >
220+ < span className = "font-medium text-gray-500 dark:text-gray-300 " > Status:</ span >
190221 < div className = { `px-3 h-7 flex items-center justify-center rounded-full text-sm ${ getStatusClass ( application . status ) } ` } > { application . status } </ div >
191222 </ div >
223+ { application . comment && < p className = "text-gray-500 dark:text-gray-300" > < span className = "font-medium" > Comment:</ span > { application . comment } </ p > }
192224 </ div >
193225 < div className = "space-y-4" >
194- < h3 className = "uppercase text-gray-800 dark:text-white font-bold" > Job Post</ h3 >
195- < p className = "text-gray-500 dark:text-gray-300" > < span className = "font-medium" > Title: </ span > { application . jobId ?. title } </ p >
226+ < h3 className = "uppercase text-gray-800 dark:text-white font-bold invisible" > Candidate Information</ h3 >
227+ < p className = "text-gray-500 dark:text-gray-300" > < span className = "font-medium" > Job Title: </ span > { application . jobId ?. title } </ p >
228+ < div className = "flex flex-col gap-4 text-gray-500 dark:text-gray-300" >
229+ < h2 className = "text-base font-medium" > Interest essay:</ h2 >
230+ < div dangerouslySetInnerHTML = { { __html :application . essay } } > </ div >
231+ </ div >
196232 </ div >
197233 </ div >
198234 </ div >
@@ -204,11 +240,10 @@ const ApplicationDetails = () => {
204240 id = ""
205241 value = { status }
206242 onChange = { ( e ) => setStatus ( e . target . value ) }
207- disabled = { isLoading }
208- className = " bg-[#10292C] flex items-center text-white justify-center dark:bg-white hover:bg-[#1f544cef] dark:text-zinc-700 font-bold py-2 px-4 rounded"
243+ disabled = { isLoading || application ?. status === 'rejected' }
244+ className = { ` bg-[#10292C] flex items-center text-white justify-center dark:bg-white ${ application ?. status === 'rejected' ? 'opacity-70 cursor-not-allowed' : 'opacity-100 cursor-pointer' } hover:bg-[#1f544cef] dark:text-zinc-700 font-bold py-2 px-4 rounded ml-8` }
209245 >
210246 < option defaultChecked value = "" > Update status</ option >
211- < option value = 'submitted' > Submitted</ option >
212247 < option value = 'under-review' > Under Review</ option >
213248 < option value = 'accepted' > Accepted</ option >
214249 < option value = 'rejected' > Rejected</ option >
0 commit comments