add max lenght validation for create complaint/claim
This commit is contained in:
@@ -89,6 +89,7 @@ export const createComplaintSchema = z
|
||||
textArea: z
|
||||
.string()
|
||||
.min(6, { error: 'text-area-error-fill-complaint-text' })
|
||||
.max(2000, {error: 'text-area-error-complaint-text-too-long'})
|
||||
.trim(),
|
||||
})
|
||||
|
||||
@@ -97,10 +98,12 @@ export const createCaseSchema = z
|
||||
textArea: z
|
||||
.string()
|
||||
.min(6, { error: 'fill-text-of-the-case' })
|
||||
.max(2000, {error: 'claim-text-must-not-exceed-2000-characters'})
|
||||
.trim(),
|
||||
caseTitle: z
|
||||
.string()
|
||||
.min(6, { error: 'fill-title-of-the-case' })
|
||||
.max(300, {error: 'claim-title-must-not-exceed-300-characters'})
|
||||
.trim(),
|
||||
})
|
||||
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
import { ViolationFileDetail } from '@/app/hooks/react-query/useFileViolations';
|
||||
import { useActionState, useEffect, useState } from 'react';
|
||||
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 { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { MatchStatus } from '@/app/actions/violationActions';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
||||
|
||||
interface complaintInfo {
|
||||
@@ -25,7 +24,6 @@ type UpdateStatusHandler = (id: number, status: MatchStatus) => Promise<boolean>
|
||||
|
||||
export default function CaseComplaint({ selectedViolation, updateStatusHandler }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler }) {
|
||||
const t = useTranslations('Global');
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const [localViolation, setLocalViolation] = useState<ViolationFileDetail>(selectedViolation);
|
||||
const [noteText, setNoteText] = useState('');
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import { ViolationFileDetail } from '@/app/hooks/react-query/useFileViolations';
|
||||
import { useEffect, useState, useActionState } from 'react';
|
||||
import { fetchCaseInfo, MatchStatus, createCase } from '@/app/actions/violationActions';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { fetchCaseInfo, createCase, MatchStatus } from '@/app/actions/violationActions';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { toast } from 'sonner';
|
||||
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 }) {
|
||||
const t = useTranslations('Global');
|
||||
const queryClient = useQueryClient();
|
||||
const [localViolation, setLocalViolation] = useState<ViolationFileDetail>(selectedViolation);
|
||||
const [state, formAction, isPending] = useActionState(createCase, undefined);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user