add max lenght validation for create complaint/claim
This commit is contained in:
@@ -89,6 +89,7 @@ export const createComplaintSchema = z
|
|||||||
textArea: z
|
textArea: z
|
||||||
.string()
|
.string()
|
||||||
.min(6, { error: 'text-area-error-fill-complaint-text' })
|
.min(6, { error: 'text-area-error-fill-complaint-text' })
|
||||||
|
.max(2000, {error: 'text-area-error-complaint-text-too-long'})
|
||||||
.trim(),
|
.trim(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -97,10 +98,12 @@ export const createCaseSchema = z
|
|||||||
textArea: z
|
textArea: z
|
||||||
.string()
|
.string()
|
||||||
.min(6, { error: 'fill-text-of-the-case' })
|
.min(6, { error: 'fill-text-of-the-case' })
|
||||||
|
.max(2000, {error: 'claim-text-must-not-exceed-2000-characters'})
|
||||||
.trim(),
|
.trim(),
|
||||||
caseTitle: z
|
caseTitle: z
|
||||||
.string()
|
.string()
|
||||||
.min(6, { error: 'fill-title-of-the-case' })
|
.min(6, { error: 'fill-title-of-the-case' })
|
||||||
|
.max(300, {error: 'claim-title-must-not-exceed-300-characters'})
|
||||||
.trim(),
|
.trim(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
import { ViolationFileDetail } from '@/app/hooks/react-query/useFileViolations';
|
import { ViolationFileDetail } from '@/app/hooks/react-query/useFileViolations';
|
||||||
import { useActionState, useEffect, useState } from 'react';
|
import { useActionState, useEffect, useState } from 'react';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { createComplaint, fetchComplainInfo } from '@/app/actions/violationActions';
|
import { createComplaint, fetchComplainInfo, MatchStatus } from '@/app/actions/violationActions';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { MatchStatus } from '@/app/actions/violationActions';
|
|
||||||
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
||||||
|
|
||||||
interface complaintInfo {
|
interface complaintInfo {
|
||||||
@@ -25,7 +24,6 @@ type UpdateStatusHandler = (id: number, status: MatchStatus) => Promise<boolean>
|
|||||||
|
|
||||||
export default function CaseComplaint({ selectedViolation, updateStatusHandler }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler }) {
|
export default function CaseComplaint({ selectedViolation, updateStatusHandler }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler }) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
const [localViolation, setLocalViolation] = useState<ViolationFileDetail>(selectedViolation);
|
const [localViolation, setLocalViolation] = useState<ViolationFileDetail>(selectedViolation);
|
||||||
const [noteText, setNoteText] = useState('');
|
const [noteText, setNoteText] = useState('');
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
import { ViolationFileDetail } from '@/app/hooks/react-query/useFileViolations';
|
import { ViolationFileDetail } from '@/app/hooks/react-query/useFileViolations';
|
||||||
import { useEffect, useState, useActionState } from 'react';
|
import { useEffect, useState, useActionState } from 'react';
|
||||||
import { fetchCaseInfo, MatchStatus, createCase } from '@/app/actions/violationActions';
|
import { fetchCaseInfo, createCase, MatchStatus } from '@/app/actions/violationActions';
|
||||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
||||||
@@ -31,7 +31,6 @@ type UpdateStatusHandler = (id: number, status: MatchStatus) => Promise<boolean>
|
|||||||
|
|
||||||
export default function CaseViolation({ selectedViolation, updateStatusHandler }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler }) {
|
export default function CaseViolation({ selectedViolation, updateStatusHandler }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler }) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [localViolation, setLocalViolation] = useState<ViolationFileDetail>(selectedViolation);
|
const [localViolation, setLocalViolation] = useState<ViolationFileDetail>(selectedViolation);
|
||||||
const [state, formAction, isPending] = useActionState(createCase, undefined);
|
const [state, formAction, isPending] = useActionState(createCase, undefined);
|
||||||
|
|
||||||
|
|||||||
@@ -394,6 +394,7 @@
|
|||||||
"deselect": "Deselect",
|
"deselect": "Deselect",
|
||||||
"select-all": "Select all",
|
"select-all": "Select all",
|
||||||
"text-area-error-fill-complaint-text": "Fill out the complaint text",
|
"text-area-error-fill-complaint-text": "Fill out the complaint text",
|
||||||
|
"text-area-error-complaint-text-too-long": "The complaint text must not exceed 2000 characters",
|
||||||
"to-view-a-file-match-click-on-the-card-from-the-list": "To view a file match, click on the card from the list",
|
"to-view-a-file-match-click-on-the-card-from-the-list": "To view a file match, click on the card from the list",
|
||||||
"insufficient-funds-to-receive-payment": "Insufficient funds to receive payment",
|
"insufficient-funds-to-receive-payment": "Insufficient funds to receive payment",
|
||||||
"not-found-payout-method": "Not found payout method",
|
"not-found-payout-method": "Not found payout method",
|
||||||
@@ -420,6 +421,8 @@
|
|||||||
"text-of-the-case": "Text of the case",
|
"text-of-the-case": "Text of the case",
|
||||||
"fill-text-of-the-case": "Fill the case text",
|
"fill-text-of-the-case": "Fill the case text",
|
||||||
"fill-title-of-the-case": "Fill the case title",
|
"fill-title-of-the-case": "Fill the case title",
|
||||||
|
"claim-title-must-not-exceed-300-characters": "The claim title must not exceed 300 characters",
|
||||||
|
"claim-text-must-not-exceed-2000-characters": "The text of the claim must not exceed 2000 characters",
|
||||||
"enter-the-amount-of-damage": "Enter the amount of damage",
|
"enter-the-amount-of-damage": "Enter the amount of damage",
|
||||||
"download-all": "Download all",
|
"download-all": "Download all",
|
||||||
"selected-files": "Selected files",
|
"selected-files": "Selected files",
|
||||||
|
|||||||
@@ -394,6 +394,7 @@
|
|||||||
"deselect": "Снять выделение",
|
"deselect": "Снять выделение",
|
||||||
"select-all": "Выбрать все",
|
"select-all": "Выбрать все",
|
||||||
"text-area-error-fill-complaint-text": "Заполните текст жалобы",
|
"text-area-error-fill-complaint-text": "Заполните текст жалобы",
|
||||||
|
"text-area-error-complaint-text-too-long": "Текст жалобы не должен превышать 2000 символов",
|
||||||
"to-view-a-file-match-click-on-the-card-from-the-list": "Для просмотра совпадения по файлу нажмите на карточку из списка",
|
"to-view-a-file-match-click-on-the-card-from-the-list": "Для просмотра совпадения по файлу нажмите на карточку из списка",
|
||||||
"insufficient-funds-to-receive-payment": "Недостаточно средств для получения выплаты",
|
"insufficient-funds-to-receive-payment": "Недостаточно средств для получения выплаты",
|
||||||
"not-found-payout-method": "Метод выплаты не найден",
|
"not-found-payout-method": "Метод выплаты не найден",
|
||||||
@@ -420,6 +421,8 @@
|
|||||||
"text-of-the-case": "Текст претензии",
|
"text-of-the-case": "Текст претензии",
|
||||||
"fill-text-of-the-case": "Заполните текст претензии",
|
"fill-text-of-the-case": "Заполните текст претензии",
|
||||||
"fill-title-of-the-case": "Заполните название претензии",
|
"fill-title-of-the-case": "Заполните название претензии",
|
||||||
|
"claim-title-must-not-exceed-300-characters": "Название претензии не должно превышать 300 символов",
|
||||||
|
"claim-text-must-not-exceed-2000-characters": "Текст претензии не должен превышать 2000 символов",
|
||||||
"enter-the-amount-of-damage": "Введите сумму ущерба",
|
"enter-the-amount-of-damage": "Введите сумму ущерба",
|
||||||
"download-all": "Скачать все",
|
"download-all": "Скачать все",
|
||||||
"selected-files": "Выбрано файлов",
|
"selected-files": "Выбрано файлов",
|
||||||
|
|||||||
Reference in New Issue
Block a user