-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #356 from hotosm/feat/regulators-approval-flow
Feat: Enhancements to Regulators Approval Flow on project creation
- Loading branch information
Showing
10 changed files
with
261 additions
and
115 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
75 changes: 75 additions & 0 deletions
75
src/frontend/src/components/RegulatorsApprovalPage/Description/ApprovalSection.tsx
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,75 @@ | ||
import { Button } from '@Components/RadixComponents/Button'; | ||
import { regulatorComment } from '@Services/createproject'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { useState } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { toast } from 'react-toastify'; | ||
|
||
const ApprovalSection = () => { | ||
const { id } = useParams(); | ||
const [comment, setComment] = useState(''); | ||
const { mutate: commentToProject, isLoading } = useMutation< | ||
any, | ||
any, | ||
any, | ||
unknown | ||
>({ | ||
mutationFn: regulatorComment, | ||
onSuccess: () => { | ||
toast.success('Responded successfully'); | ||
}, | ||
onError: (err: any) => { | ||
toast.error(err?.response?.data?.detail || err?.message || ''); | ||
}, | ||
}); | ||
|
||
const handleApprovalStatus = (status: string) => { | ||
commentToProject({ | ||
regulator_comment: comment, | ||
regulator_approval_status: status, | ||
projectId: id, | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
{' '} | ||
<div className="naxatw-mt-6 naxatw-flex naxatw-flex-col naxatw-gap-1"> | ||
<p className="naxatw-text-[0.875rem] naxatw-font-semibold naxatw-leading-normal naxatw-tracking-[0.0175rem]"> | ||
Comment | ||
</p> | ||
<textarea | ||
value={comment} | ||
onChange={e => setComment(e.target.value)} | ||
placeholder="Comment" | ||
name="" | ||
id="" | ||
cols={4} | ||
className="naxatw-w-full naxatw-rounded-md naxatw-border naxatw-border-gray-800 naxatw-p-1" | ||
/> | ||
</div> | ||
<div className="naxatw-flex naxatw-items-start naxatw-justify-start naxatw-gap-2"> | ||
<Button | ||
variant="outline" | ||
onClick={() => handleApprovalStatus('REJECTED')} | ||
className="naxatw-border-red naxatw-font-primary naxatw-text-red" | ||
isLoading={isLoading} | ||
disabled={isLoading} | ||
> | ||
Reject | ||
</Button> | ||
<Button | ||
variant="ghost" | ||
onClick={() => handleApprovalStatus('APPROVED')} | ||
className="naxatw-bg-red naxatw-font-primary naxatw-text-white" | ||
isLoading={isLoading} | ||
disabled={isLoading} | ||
> | ||
Accept | ||
</Button> | ||
</div>{' '} | ||
</> | ||
); | ||
}; | ||
|
||
export default ApprovalSection; |
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
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
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
Oops, something went wrong.