add save text for claims/complaints form while validation error
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use server'
|
||||
|
||||
import { getSessionData } from '@/app/actions/session';
|
||||
import { API_BASE_URL, createComplaintSchema, createCaseSchema } from '@/app/actions/definitions';
|
||||
import { API_BASE_URL, createComplaintSchema, createClaimSchema } from '@/app/actions/definitions';
|
||||
|
||||
export async function getViolationSearchStatus() {
|
||||
const token = await getSessionData('token');
|
||||
@@ -560,6 +560,7 @@ export async function fetchCaseInfo(id: number) {
|
||||
interface caseBody {
|
||||
previousText: string,
|
||||
previousCaseTitle: string,
|
||||
previousAmount: string,
|
||||
violationID: string | null,
|
||||
success: boolean,
|
||||
errorMessage?: Record<string, string> | null
|
||||
@@ -576,7 +577,7 @@ export async function createCase(
|
||||
const caseTitle = formData.get('caseTitle') as string || '';
|
||||
const amount = formData.get('amount') as string || '';
|
||||
|
||||
const validatedFields = createCaseSchema.safeParse({
|
||||
const validatedFields = createClaimSchema.safeParse({
|
||||
textArea,
|
||||
caseTitle
|
||||
});
|
||||
@@ -598,6 +599,7 @@ export async function createCase(
|
||||
violationID: violationId,
|
||||
previousText: textArea,
|
||||
previousCaseTitle: caseTitle,
|
||||
previousAmount: amount,
|
||||
success: false,
|
||||
errorMessage: errors
|
||||
}
|
||||
@@ -634,6 +636,7 @@ export async function createCase(
|
||||
violationID: violationId,
|
||||
previousCaseTitle: caseTitle,
|
||||
previousText: textArea,
|
||||
previousAmount: amount,
|
||||
success: true
|
||||
};
|
||||
} else {
|
||||
@@ -654,6 +657,7 @@ export async function createCase(
|
||||
violationID: violationId,
|
||||
previousText: textArea,
|
||||
previousCaseTitle: caseTitle,
|
||||
previousAmount: amount,
|
||||
success: false,
|
||||
errorMessage: errors
|
||||
}
|
||||
@@ -665,6 +669,7 @@ export async function createCase(
|
||||
violationID: violationId,
|
||||
previousText: textArea,
|
||||
previousCaseTitle: caseTitle,
|
||||
previousAmount: amount,
|
||||
success: false,
|
||||
errorMessage: errors
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user