rename functions
This commit is contained in:
@@ -162,7 +162,7 @@ export async function fetchViolationStats() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getFileViolations(fileId: string, page: number, status?: string, violationId?: string) {
|
||||
export async function getFileMatches(fileId: string, page: number, status?: string, violationId?: string) {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
@@ -497,28 +497,19 @@ export async function updateMatchStatus(id: number, status: MatchStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchCaseInfo(id: number) {
|
||||
export async function fetchClaimInfo(id: number) {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
method: 'POST',
|
||||
/* body: JSON.stringify({
|
||||
version: 1,
|
||||
msg_id: 30017,
|
||||
message_body: {
|
||||
action: 'get_byId',
|
||||
token: token,
|
||||
id: id
|
||||
}
|
||||
}), */
|
||||
body: JSON.stringify({
|
||||
version: 1,
|
||||
msg_id: 30017,
|
||||
message_body: {
|
||||
action: 'get_all',
|
||||
token: token,
|
||||
pageSize: 10,
|
||||
pageSize: 1,
|
||||
pageNumber: 0,
|
||||
sortBy: "createdAt",
|
||||
sortDir: "desc",
|
||||
@@ -564,7 +555,7 @@ interface caseBody {
|
||||
errorMessage?: Record<string, string> | null
|
||||
}
|
||||
|
||||
export async function createCase(
|
||||
export async function createClaim(
|
||||
state: caseBody | undefined,
|
||||
formData: FormData
|
||||
): Promise<caseBody> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getFileViolations } from '@/app/actions/violationActions';
|
||||
import { getFileMatches } from '@/app/actions/violationActions';
|
||||
|
||||
export interface ViolationFileDetail {
|
||||
id: number;
|
||||
@@ -28,7 +28,7 @@ export const useFileViolations = (id: string, page: number, status?: string, vio
|
||||
return useQuery({
|
||||
queryKey: ['fileViolations', id, page, status, violationId],
|
||||
queryFn: () => {
|
||||
return getFileViolations(id, page, status, violationId)
|
||||
return getFileMatches(id, page, status, violationId)
|
||||
},
|
||||
select: (data: ViolationFile | null) => {
|
||||
if (!data) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { ViolationFileDetail } from '@/app/hooks/react-query/useFileViolations';
|
||||
import { useEffect, useActionState, SetStateAction } from 'react';
|
||||
import { fetchCaseInfo, createCase, MatchStatus } from '@/app/actions/violationActions';
|
||||
import { fetchClaimInfo, createClaim, MatchStatus } from '@/app/actions/violationActions';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { toast } from 'sonner';
|
||||
@@ -37,11 +37,11 @@ export default function CaseViolation({ selectedViolation, updateStatusHandler,
|
||||
}
|
||||
) {
|
||||
const t = useTranslations('Global');
|
||||
const [state, formAction, isPending] = useActionState(createCase, undefined);
|
||||
const [state, formAction, isPending] = useActionState(createClaim, undefined);
|
||||
|
||||
const { data: caseInfo, isLoading: isLoadingCase } = useQuery({
|
||||
queryKey: ['caseInfo', selectedViolation.id],
|
||||
queryFn: () => fetchCaseInfo(selectedViolation.id),
|
||||
queryFn: () => fetchClaimInfo(selectedViolation.id),
|
||||
select: (data) => {
|
||||
if (data) {
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user