fix complaints/violations/matches statistick
This commit is contained in:
@@ -71,7 +71,7 @@ export default async function Page({
|
||||
>
|
||||
<FilePageFileInfo fileInfo={fileInfo} />
|
||||
{/* <FilePageActions /> */}
|
||||
<ViolationPpageFileStatistic />
|
||||
<ViolationPpageFileStatistic id={id} />
|
||||
</div>
|
||||
<div>
|
||||
<FilePageViolationsList
|
||||
|
||||
@@ -209,8 +209,9 @@ export async function fetchViolationAnalyticStatistic(group: 'domain' | 'tld') {
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchViolationStatistic() {
|
||||
export async function fetchViolationStatistic(id: string) {
|
||||
const token = await getSessionData('token');
|
||||
console.log(`fileId => ${id}`)
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
@@ -220,6 +221,7 @@ export async function fetchViolationStatistic() {
|
||||
msg_id: 30010,
|
||||
message_body: {
|
||||
token: token,
|
||||
file_id: id
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
@@ -230,6 +232,7 @@ export async function fetchViolationStatistic() {
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
console.log(parsed);
|
||||
|
||||
if (parsed?.message_body) {
|
||||
return parsed?.message_body;
|
||||
|
||||
@@ -10,11 +10,11 @@ export interface UseViolationStatistic {
|
||||
total_law_cases: number
|
||||
}
|
||||
|
||||
export const useViolationStatistic = () => {
|
||||
export const useViolationStatistic = (id: string) => {
|
||||
return useQuery({
|
||||
queryKey: ['violationStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchViolationStatistic()
|
||||
return fetchViolationStatistic(id)
|
||||
},
|
||||
select: (data: UseViolationStatistic | null) => {
|
||||
if (!data) {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import { useViolationStatistic } from '@/app/hooks/react-query/useViolationStatistic';
|
||||
|
||||
export default function FilePpageFileStatistic() {
|
||||
const { data: violationStatistic } = useViolationStatistic();
|
||||
export default function FilePageFileStatistic({ id }: { id: string }) {
|
||||
const { data: violationStatistic } = useViolationStatistic(id);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -30,7 +30,7 @@ export default function FilePpageFileStatistic() {
|
||||
className="stat-mini-value"
|
||||
style={{ 'color': '#d97706' }}
|
||||
>
|
||||
{(violationStatistic?.in_progress_violations ? violationStatistic?.in_progress_violations : 0) + (violationStatistic?.in_progress_violations ? violationStatistic?.total_law_cases : 0)}
|
||||
{violationStatistic?.in_progress_violations ? violationStatistic?.in_progress_violations : 0}
|
||||
</div>
|
||||
<div className="stat-mini-label">В работе</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user