This commit is contained in:
Vladislav Khorev 2024-09-08 14:14:05 +00:00
commit 32761ce479
2 changed files with 34 additions and 7 deletions

View File

@ -29,16 +29,18 @@ export async function generateMetadata({
}; };
} }
//<<<<<<< HEAD:src/app/[locale]/news/[id]/page.tsx
const NewsDetails = async ({ const NewsDetails = async ({
params, params,
}: { }: {
params: { id: string; новость: string }; params: { id: string; новость: string };
}) => { }) => {
//=======
//const NewsDetails = async ({ params }: { params: { id: string } }) => {
//>>>>>>> master:src/app/news/[id]/page.tsx
const getNewsById = async () => { const getNewsById = async () => {
const response = await apiInstance.get<INews>( const response = await apiInstance.get<INews>(`/news/${params.id}/`);
`/news/${params.id}/` console.log(response);
);
return response.data; return response.data;
}; };
@ -71,9 +73,9 @@ const NewsDetails = async ({
<Image src={calendar} alt="Calendar Icon" /> <Image src={calendar} alt="Calendar Icon" />
<p> <p>
{months[data.created_at.slice(5, 7)]}{" "} {months[data.created_at.slice(5, 7)]}{" "}
{data.created_at.slice(5, 7).slice(0, 1) === "0" {data.created_at.slice(8, 10) === "0"
? data.created_at.slice(6, 7) ? data.created_at.slice(9, 10)
: data.created_at.slice(5, 7)} : data.created_at.slice(8, 10)}
, {data.created_at.slice(0, 4)} , {data.created_at.slice(0, 4)}
</p> </p>
</div> </div>

View File

@ -0,0 +1,25 @@
"use client"
import React, { useEffect, useState } from 'react';
import { apiInstance } from "@/shared/config/apiConfig";
import { AxiosError } from "axios";
const GoogleAnalyticsWidget = async () => {
const getAnalytics = async () => {
try {
const response = await apiInstance.get("/report/google_analytics/");
return response.data;
} catch (error: unknown) {
if (error instanceof AxiosError) console.log(error.message);
}
};
const data = await getAnalytics();
return (
<div><p>Total cummulative visitors: {data.visitors}</p></div>
)
};
export default GoogleAnalyticsWidget;