@@ -45,7 +45,8 @@ type Consent = { purpose: string; policy_version: string | null; status: string;
|
||||
|
||||
export default function InterestDetail({ interest, history = [], assignees = [], consents = [] }: { interest: Interest; history?: Transition[]; assignees?: Assignee[]; consents?: Consent[] }) {
|
||||
const form = useForm({ status: interest.status, note: "", next_action: interest.next_action ?? "", next_action_due_at: interest.next_action_due_at?.slice(0, 10) ?? "", assigned_to: interest.assigned_to?.toString() ?? "" });
|
||||
const consentForm = useForm({ reason: "" });
|
||||
const contactConsentForm = useForm({ reason: "" });
|
||||
const sharingConsentForm = useForm({ reason: "" });
|
||||
const rows: [string, string | number | null][] = [
|
||||
["Nome", interest.full_name],
|
||||
["Email", interest.email],
|
||||
@@ -111,15 +112,26 @@ export default function InterestDetail({ interest, history = [], assignees = [],
|
||||
{consent.withdrawn_at && <p className="text-sm">Revogado {dateTime(consent.withdrawn_at)}</p>}
|
||||
</article>
|
||||
))}
|
||||
{consents.some((consent) => consent.purpose === "respond_to_interest" && consent.status === "granted") && (
|
||||
<form className="max-w-sm space-y-3" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
contactConsentForm.patch(`/management/interests/${interest.id}/consent/contact`);
|
||||
}}>
|
||||
<Field label="Motivo do pedido de revogação" error={contactConsentForm.errors.reason}>
|
||||
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={contactConsentForm.data.reason} onChange={(event) => contactConsentForm.setData("reason", event.target.value)} />
|
||||
</Field>
|
||||
<button className={button} disabled={contactConsentForm.processing}>Revogar autorização de contacto</button>
|
||||
</form>
|
||||
)}
|
||||
{consents.some((consent) => consent.purpose === "share_contact_with_proponent" && consent.status === "granted") && (
|
||||
<form className="max-w-sm space-y-3" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
consentForm.patch(`/management/interests/${interest.id}/consent/proponent`);
|
||||
sharingConsentForm.patch(`/management/interests/${interest.id}/consent/proponent`);
|
||||
}}>
|
||||
<Field label="Motivo do pedido de revogação" error={consentForm.errors.reason}>
|
||||
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={consentForm.data.reason} onChange={(event) => consentForm.setData("reason", event.target.value)} />
|
||||
<Field label="Motivo do pedido de revogação" error={sharingConsentForm.errors.reason}>
|
||||
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={sharingConsentForm.data.reason} onChange={(event) => sharingConsentForm.setData("reason", event.target.value)} />
|
||||
</Field>
|
||||
<button className={button} disabled={consentForm.processing}>Revogar autorização de partilha</button>
|
||||
<button className={button} disabled={sharingConsentForm.processing}>Revogar autorização de partilha</button>
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user