change matched table layout
This commit is contained in:
@@ -32,7 +32,6 @@ type UpdateStatusHandler = (id: number, status: MatchStatus) => Promise<boolean>
|
||||
export default function CaseViolation({ selectedViolation, updateStatusHandler }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler }) {
|
||||
const t = useTranslations('Global');
|
||||
const queryClient = useQueryClient();
|
||||
const [showCreateCase, setShowCreateCase] = useState(false);
|
||||
const [localViolation, setLocalViolation] = useState<ViolationFileDetail>(selectedViolation);
|
||||
const [state, formAction, isPending] = useActionState(createCase, undefined);
|
||||
|
||||
@@ -61,8 +60,6 @@ export default function CaseViolation({ selectedViolation, updateStatusHandler }
|
||||
}));
|
||||
|
||||
updateStatusHandler(selectedViolation.id, newStatus);
|
||||
|
||||
setShowCreateCase(false);
|
||||
} else if (state && !state.success) {
|
||||
console.log(state.errorMessage);
|
||||
if (state.errorMessage?.server) {
|
||||
@@ -73,144 +70,121 @@ export default function CaseViolation({ selectedViolation, updateStatusHandler }
|
||||
}
|
||||
}, [state, updateStatusHandler, selectedViolation.id]);
|
||||
|
||||
function toggleForm() {
|
||||
setShowCreateCase(!showCreateCase);
|
||||
}
|
||||
|
||||
if (!ENABLED_STATUSES.includes(localViolation.status)) {
|
||||
return (
|
||||
<div className="violation-info-case">
|
||||
{!showCreateCase ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action btn-case"
|
||||
onClick={toggleForm}
|
||||
>
|
||||
{t('create-case')}
|
||||
</button>
|
||||
) : (
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action btn-case"
|
||||
onClick={toggleForm}
|
||||
<div className="note-form">
|
||||
<form action={formAction}>
|
||||
<input type="hidden" name="violationId" value={localViolation.id} />
|
||||
<div
|
||||
className="note-form-flex"
|
||||
>
|
||||
{t('cancel')}
|
||||
</button>
|
||||
|
||||
<div className="note-form">
|
||||
<form action={formAction}>
|
||||
<input type="hidden" name="violationId" value={localViolation.id} />
|
||||
<div
|
||||
className="note-form-flex"
|
||||
<section
|
||||
className="note-form-group"
|
||||
>
|
||||
<label
|
||||
className="note-case-label"
|
||||
htmlFor="caseTitle"
|
||||
>
|
||||
<section
|
||||
className="note-form-group"
|
||||
{/* {t('case-name')} */}
|
||||
Название претензии
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="caseTitle"
|
||||
className="note-case-input"
|
||||
placeholder={t('fill-title-of-the-case') + '...'}
|
||||
/>
|
||||
{state?.errorMessage?.caseTitle && (
|
||||
<p
|
||||
className="text-sm text-red-500"
|
||||
>
|
||||
<label
|
||||
className="note-case-label"
|
||||
htmlFor="caseTitle"
|
||||
>
|
||||
{t('case-name')}
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="caseTitle"
|
||||
className="note-case-input"
|
||||
placeholder={t('fill-title-of-the-case') + '...'}
|
||||
/>
|
||||
{state?.errorMessage?.caseTitle && (
|
||||
<p
|
||||
className="text-sm text-red-500"
|
||||
>
|
||||
{
|
||||
state?.errorMessage?.caseTitle.split('&').map((e, index) => {
|
||||
return (
|
||||
<span key={index}>
|
||||
{t(e)}
|
||||
<br />
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<section
|
||||
className="note-form-group"
|
||||
>
|
||||
<label
|
||||
className="note-case-label"
|
||||
htmlFor="amount"
|
||||
>
|
||||
{t('amount-of-damage')}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="amount"
|
||||
className="note-case-input"
|
||||
placeholder={t('enter-the-amount-of-damage') + '...'}
|
||||
/>
|
||||
{state?.errorMessage?.amount && (
|
||||
<p
|
||||
className="text-sm text-red-500"
|
||||
>
|
||||
{
|
||||
state?.errorMessage?.amount.split('&').map((e, index) => {
|
||||
return (
|
||||
<span key={index}>
|
||||
{t(e)}
|
||||
<br />
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section
|
||||
className="note-textarea-wrapper"
|
||||
{
|
||||
state?.errorMessage?.caseTitle.split('&').map((e, index) => {
|
||||
return (
|
||||
<span key={index}>
|
||||
{t(e)}
|
||||
<br />
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<section
|
||||
className="note-form-group"
|
||||
>
|
||||
<label
|
||||
className="note-case-label"
|
||||
htmlFor="amount"
|
||||
>
|
||||
<textarea
|
||||
name="note"
|
||||
className="note-textarea"
|
||||
placeholder={t('fill-text-of-the-case') + '...'}
|
||||
{t('amount-of-damage')}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
name="amount"
|
||||
className="note-case-input"
|
||||
placeholder={t('enter-the-amount-of-damage') + '...'}
|
||||
/>
|
||||
{state?.errorMessage?.amount && (
|
||||
<p
|
||||
className="text-sm text-red-500"
|
||||
>
|
||||
</textarea>
|
||||
{state?.errorMessage?.textArea && (
|
||||
<p
|
||||
className="text-sm text-red-500"
|
||||
>
|
||||
{
|
||||
state?.errorMessage?.textArea.split('&').map((e, index) => {
|
||||
return (
|
||||
<span key={index}>
|
||||
{t(e)}
|
||||
<br />
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<div
|
||||
className="flex gap-3"
|
||||
>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn-small btn-primary-small"
|
||||
disabled={isPending}
|
||||
>
|
||||
{t('submit-violation')}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{
|
||||
state?.errorMessage?.amount.split('&').map((e, index) => {
|
||||
return (
|
||||
<span key={index}>
|
||||
{t(e)}
|
||||
<br />
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<section
|
||||
className="note-textarea-wrapper"
|
||||
>
|
||||
<textarea
|
||||
name="note"
|
||||
className="note-textarea"
|
||||
placeholder={t('fill-text-of-the-case') + '...'}
|
||||
>
|
||||
</textarea>
|
||||
{state?.errorMessage?.textArea && (
|
||||
<p
|
||||
className="text-sm text-red-500"
|
||||
>
|
||||
{
|
||||
state?.errorMessage?.textArea.split('&').map((e, index) => {
|
||||
return (
|
||||
<span key={index}>
|
||||
{t(e)}
|
||||
<br />
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<div
|
||||
className="button-actions"
|
||||
>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn-small btn-primary-small"
|
||||
disabled={isPending}
|
||||
>
|
||||
{t('submit-violation')}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
@@ -237,22 +211,124 @@ export default function CaseViolation({ selectedViolation, updateStatusHandler }
|
||||
{caseInfo.body.content.map((item: CaseInfo) => {
|
||||
return (
|
||||
<div key={item.id}>
|
||||
<h3 className="mb-3">
|
||||
{t('complaint-Information')}
|
||||
</h3>
|
||||
<div className="complaint-details">
|
||||
<p><strong>ID:</strong> {item.id}</p>
|
||||
<p><strong>{t('name')}:</strong> {item.name}</p>
|
||||
<p><strong>{t('description')}:</strong> {item.description}</p>
|
||||
<p><strong>{t('amount')}:</strong> {item.amount}</p>
|
||||
<p><strong>{t('priority')}:</strong> {item.priority}</p>
|
||||
<p><strong>{t('type')}:</strong> {item.type}</p>
|
||||
<p><strong>{t('lawyer')}:</strong> {item.lawyer || t('not-assigned')}</p>
|
||||
<p><strong>{t('violation-id')}:</strong> {item.violationId}</p>
|
||||
<p><strong>{t('date-of-creation')}:</strong> {item.createdAt ? `${formatDate(item.createdAt)}: ${formatDateTime(item.createdAt)}` : '---'}</p>
|
||||
<p><strong>{t('date-of-update')}:</strong> {item.createdAt ? `${formatDate(item.createdAt)}: ${formatDateTime(item.createdAt)}` : '---'}</p>
|
||||
{/* <div className="complaint-details">
|
||||
<div><strong>ID:</strong> {item.id}</div>
|
||||
<div><strong>{t('name')}:</strong>
|
||||
<br />
|
||||
{item.name}
|
||||
</div>
|
||||
<div><strong>{t('description')}:</strong> {item.description}</div>
|
||||
<div><strong>{t('amount')}:</strong> {item.amount}</div>
|
||||
<div><strong>{t('priority')}:</strong> {item.priority}</div>
|
||||
<div><strong>{t('type')}:</strong> {item.type}</div>
|
||||
<div><strong>{t('lawyer')}:</strong> {item.lawyer || t('not-assigned')}</div>
|
||||
<div><strong>{t('violation-id')}:</strong> {item.violationId}</div>
|
||||
<div><strong>{t('date-of-creation')}:</strong> {item.createdAt ? `${formatDate(item.createdAt)}: ${formatDateTime(item.createdAt)}` : '---'}</div>
|
||||
<div><strong>{t('date-of-update')}:</strong> {item.createdAt ? `${formatDate(item.createdAt)}: ${formatDateTime(item.createdAt)}` : '---'}</div>
|
||||
{item.content && <p><strong>{t('content')}:</strong> {item.content}</p>}
|
||||
</div> */}
|
||||
|
||||
|
||||
<div className="complaint-details">
|
||||
<div
|
||||
className="complaint-details-item"
|
||||
>
|
||||
<strong>ID:</strong> {item.id}
|
||||
</div>
|
||||
<div
|
||||
className="complaint-details-item"
|
||||
>
|
||||
<span
|
||||
className="complaint-details-title"
|
||||
>
|
||||
{t('status')}:
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
className="complaint-details-text"
|
||||
>
|
||||
{item.type}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="complaint-details-item"
|
||||
>
|
||||
<span
|
||||
className="complaint-details-title"
|
||||
>
|
||||
{t('date-of-creation')}:
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
className="complaint-details-text"
|
||||
>
|
||||
{item.createdAt ? `${formatDate(item.createdAt)}: ${formatDateTime(item.createdAt)}` : '---'}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="complaint-details-item"
|
||||
>
|
||||
<span
|
||||
className="complaint-details-title"
|
||||
>
|
||||
{t('date-of-update')}:
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
className="complaint-details-text"
|
||||
>
|
||||
{item.updatedAt ? `${formatDate(item.updatedAt)}: ${formatDateTime(item.updatedAt)}` : '---'}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="complaint-details-item"
|
||||
>
|
||||
<span
|
||||
className="complaint-details-title"
|
||||
>
|
||||
{t('description')}:
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
className="complaint-details-text"
|
||||
>
|
||||
{item.description}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="complaint-details-item"
|
||||
>
|
||||
<span
|
||||
className="complaint-details-title"
|
||||
>
|
||||
{t('amount-of-damage')}:
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
className="complaint-details-text"
|
||||
>
|
||||
{item.amount}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="complaint-details-item"
|
||||
>
|
||||
<span
|
||||
className="complaint-details-title"
|
||||
>
|
||||
{t('lawyer')}:
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
className="complaint-details-text"
|
||||
>
|
||||
{item.lawyer}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user