fix: added view functionality to videos

This commit is contained in:
Atash03 2025-06-23 13:36:24 +05:00
parent 80d73faad4
commit a02b738012
2 changed files with 2 additions and 4 deletions

View File

@ -38,7 +38,7 @@ const InfoBlock = ({ video_id }: IProps) => {
const res = await axios.post(`https://turkmentv.gov.tm/v2/api/material/${video_id}/views/increment`); const res = await axios.post(`https://turkmentv.gov.tm/v2/api/material/${video_id}/views/increment`);
if (res.status === 200) { if (res.status === 200) {
materialsArray.push(video_id.toString()); materialsArray.push(video_id.toString());
setView(view + 1); setView(res.data.view);
} }
} }
localStorage.setItem('MHB_MATERIALS_ID', materialsArray.join(',')); localStorage.setItem('MHB_MATERIALS_ID', materialsArray.join(','));
@ -46,7 +46,7 @@ const InfoBlock = ({ video_id }: IProps) => {
const res = await axios.post(`https://turkmentv.gov.tm/v2/api/material/${video_id}/views/increment`); const res = await axios.post(`https://turkmentv.gov.tm/v2/api/material/${video_id}/views/increment`);
if (res.status === 200) { if (res.status === 200) {
localStorage.setItem('MHB_MATERIALS_ID', [video_id.toString()].join(',')); localStorage.setItem('MHB_MATERIALS_ID', [video_id.toString()].join(','));
setView(view + 1); setView(res.data.view);
} }
} }

View File

@ -1,8 +1,6 @@
import { Queries } from '@/api/queries'; import { Queries } from '@/api/queries';
import { useMutation, useQuery } from '@tanstack/react-query'; import { useMutation, useQuery } from '@tanstack/react-query';
import { data } from 'autoprefixer';
import axios from 'axios'; import axios from 'axios';
import { Loader } from 'lucide-react';
import React from 'react'; import React from 'react';
import { BiSolidLike, BiLike, BiSolidDislike, BiDislike } from 'react-icons/bi'; import { BiSolidLike, BiLike, BiSolidDislike, BiDislike } from 'react-icons/bi';
import { useLocalStorage } from 'usehooks-ts'; import { useLocalStorage } from 'usehooks-ts';