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