forked from Transparency/kgroad-frontend2
made like
This commit is contained in:
1 parent
16bb5a4a1a
commit
7a9ba30e8f
2 files changed
+45
-7
No files matched your search
@@ -1,20 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import "./ReportLike.scss";
|
||||
import Image from "next/image";
|
||||
import like from "./icons/like.svg";
|
||||
import { apiInstance } from "@/shared/config/apiConfig";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useSession } from "next-auth/react";
|
||||
|
||||
interface IReportLikeProps {
|
||||
count: number;
|
||||
report_id: number;
|
||||
}
|
||||
|
||||
const ReportLike: React.FC<IReportLikeProps> = ({
|
||||
count,
|
||||
report_id,
|
||||
}: IReportLikeProps) => {
|
||||
const likeReport = async () => {
|
||||
const res = await apiInstance.post("");
|
||||
const session = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
const getFans = async () => {
|
||||
const res = await apiInstance.get(
|
||||
`/report/${report_id}/get_fans`
|
||||
);
|
||||
|
||||
return res.data;
|
||||
};
|
||||
|
||||
const likeReport = async () => {
|
||||
const Authorization = `Bearer ${session?.data?.access_token}`;
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization,
|
||||
},
|
||||
};
|
||||
|
||||
// console.log(getFans());
|
||||
|
||||
const res = await apiInstance.post(
|
||||
`/report/${report_id}/like/`,
|
||||
{},
|
||||
config
|
||||
);
|
||||
|
||||
router.refresh();
|
||||
};
|
||||
|
||||
return (
|
||||
<button className="report-like">
|
||||
<button onClick={likeReport} className="report-like">
|
||||
<Image src={like} alt="Like Icon" />
|
||||
<span>{count}</span>
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user