forked from Transparency/kgroad-frontend2
fixed bugs
This commit is contained in:
1 parent
d4c49a1061
commit
b0870824ba
35 files changed
+1225
-420
No files matched your search
@@ -6,38 +6,16 @@
|
||||
h2 {
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
gap: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1024px) {
|
||||
.news {
|
||||
&__list {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.news {
|
||||
gap: 30px;
|
||||
|
||||
&__list {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 550px) {
|
||||
.news {
|
||||
gap: 20px;
|
||||
|
||||
&__list {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-29
@@ -2,41 +2,20 @@ import "./News.scss";
|
||||
import Typography from "@/shared/ui/components/Typography/Typography";
|
||||
import { apiInstance } from "@/shared/config/apiConfig";
|
||||
import { INewsList } from "@/shared/types/news-type";
|
||||
import NewsCard from "@/entities/NewsCard/NewsCard";
|
||||
import NewsList from "@/widgets/NewsList/NewsList";
|
||||
|
||||
const News = async () => {
|
||||
const getNews = async () => {
|
||||
try {
|
||||
const response = await apiInstance.get<INewsList>("/news/");
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
return {
|
||||
results: [],
|
||||
};
|
||||
}
|
||||
const News = ({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: {
|
||||
["страница-новостей"]: string;
|
||||
};
|
||||
|
||||
const data = await getNews();
|
||||
}) => {
|
||||
return (
|
||||
<div className="news page-padding">
|
||||
<Typography element="h2">Новости</Typography>
|
||||
|
||||
<ul className="news__list">
|
||||
{data.results.map((news) => (
|
||||
<li key={news.id}>
|
||||
<NewsCard
|
||||
id={news.id}
|
||||
title={news.title}
|
||||
description={news.description}
|
||||
image={news.image}
|
||||
date={news.created_at}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<NewsList searchParams={searchParams} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
+3
-19
@@ -3,13 +3,7 @@ import Header from "@/widgets/Header/Header";
|
||||
import StatisticsSection from "@/widgets/StatisticsSection/StatisticsSection";
|
||||
import RatingSection from "@/widgets/RatingSection/RatingSection";
|
||||
import NewsSection from "@/widgets/NewsSection/NewsSection";
|
||||
|
||||
const DynamicMap = dynamic(
|
||||
() => import("@/widgets/MapSection/MapSection"),
|
||||
{
|
||||
ssr: false,
|
||||
}
|
||||
);
|
||||
import MapSection from "@/widgets/MapSection/MapSection";
|
||||
|
||||
const Home = async ({
|
||||
searchParams,
|
||||
@@ -25,18 +19,8 @@ const Home = async ({
|
||||
<div className="home">
|
||||
<Header />
|
||||
<StatisticsSection />
|
||||
<DynamicMap
|
||||
categories={searchParams["тип-дороги"]}
|
||||
queryMap={searchParams["поиск-на-карте"]}
|
||||
queryRating={searchParams["поиск-рейтинг"]}
|
||||
page={searchParams["страница-рейтинга"]}
|
||||
/>
|
||||
<RatingSection
|
||||
categories={searchParams["тип-дороги"]}
|
||||
queryMap={searchParams["поиск-на-карте"]}
|
||||
queryRating={searchParams["поиск-рейтинг"]}
|
||||
page={searchParams["страница-рейтинга"]}
|
||||
/>
|
||||
{/* <MapSection searchParams={searchParams} /> */}
|
||||
<RatingSection searchParams={searchParams} />
|
||||
<NewsSection />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -2,16 +2,43 @@ import Typography from "@/shared/ui/components/Typography/Typography";
|
||||
import "./Profile.scss";
|
||||
import ProfileNav from "@/widgets/ProfileNav/ProfileNav";
|
||||
import AuthGuard from "./AuthGuard";
|
||||
import { AxiosError } from "axios";
|
||||
import { apiInstance } from "@/shared/config/apiConfig";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authConfig } from "@/shared/config/authConfig";
|
||||
import { IProfile } from "@/shared/types/profile-type";
|
||||
|
||||
const Profile = ({
|
||||
const Profile = async ({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) => {
|
||||
const session = await getServerSession(authConfig);
|
||||
|
||||
const getProfile = async () => {
|
||||
const Authorization = `Bearer ${session?.access_token}`;
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization,
|
||||
},
|
||||
};
|
||||
try {
|
||||
const response = await apiInstance.get<{
|
||||
report_count: number;
|
||||
}>("/users/profile/", config);
|
||||
|
||||
return response.data;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof AxiosError) console.log(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const data = await getProfile();
|
||||
|
||||
return (
|
||||
<div className="profile page-padding">
|
||||
<Typography element="h2">Личный кабинет</Typography>
|
||||
<ProfileNav />
|
||||
<ProfileNav report_count={data?.report_count as number} />
|
||||
|
||||
<AuthGuard>{children}</AuthGuard>
|
||||
</div>
|
||||
|
||||
@@ -1,32 +1,14 @@
|
||||
import { apiInstance } from "@/shared/config/apiConfig";
|
||||
import { authConfig } from "@/shared/config/authConfig";
|
||||
import { IMyReportsList } from "@/shared/types/my-reports";
|
||||
import ProfileTable from "@/widgets/ProfileTable/ProfileTable";
|
||||
import { getServerSession } from "next-auth";
|
||||
import React from "react";
|
||||
|
||||
const MyReports = async () => {
|
||||
const session = await getServerSession(authConfig);
|
||||
|
||||
const getMyReports = async () => {
|
||||
const Authorization = `Bearer ${session?.access_token}`;
|
||||
const config = {
|
||||
headers: {
|
||||
Authorization,
|
||||
},
|
||||
};
|
||||
const res = await apiInstance.get<IMyReportsList>(
|
||||
"/users/reports/",
|
||||
config
|
||||
);
|
||||
|
||||
return res.data;
|
||||
};
|
||||
|
||||
const data: IMyReportsList = await getMyReports();
|
||||
const MyReports = async ({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { ["страница-обращений"]: string };
|
||||
}) => {
|
||||
return (
|
||||
<div>
|
||||
<ProfileTable reports={data} />
|
||||
<ProfileTable searchParams={searchParams} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -5,28 +5,15 @@ import { IStatistics } from "@/shared/types/statistics-type";
|
||||
import { AxiosError } from "axios";
|
||||
import StatisticsTable from "@/widgets/StatisticsTable/StatisticsTable";
|
||||
|
||||
const Statistics = async () => {
|
||||
const getStatistics = async (): Promise<IStatistics[] | string> => {
|
||||
try {
|
||||
const response = await apiInstance.get<IStatistics[]>(
|
||||
"/report/city/stats/"
|
||||
);
|
||||
|
||||
return response.data;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof AxiosError) {
|
||||
return error.message;
|
||||
} else {
|
||||
return "Произошла непредвиденная ошибк";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const data = await getStatistics();
|
||||
const Statistics = ({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { ["поиск-населенного-пункта"]: string };
|
||||
}) => {
|
||||
return (
|
||||
<div className="statistics page-padding">
|
||||
<Typography element="h2">Статистика</Typography>
|
||||
<StatisticsTable firstData={data} />
|
||||
<StatisticsTable searchParams={searchParams} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -5,30 +5,11 @@ import { AxiosError } from "axios";
|
||||
import { IUserRatings } from "@/shared/types/user-rating-type";
|
||||
import VolunteersTable from "@/widgets/VolunteersTable/VolunteersTable";
|
||||
|
||||
const Volunteers = async () => {
|
||||
const getVolunteers = async (): Promise<
|
||||
IUserRatings[] | string
|
||||
> => {
|
||||
try {
|
||||
const response = await apiInstance.get<IUserRatings[]>(
|
||||
"/report/user_ratings/"
|
||||
);
|
||||
|
||||
return response.data;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof AxiosError) {
|
||||
return error.message;
|
||||
} else {
|
||||
return "Произошла непредвиденная ошибк";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const data = await getVolunteers();
|
||||
const Volunteers = () => {
|
||||
return (
|
||||
<div className="volunteers page-padding">
|
||||
<Typography element="h2">Волонтеры</Typography>
|
||||
<VolunteersTable firstData={data} />
|
||||
<VolunteersTable />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user