diff --git a/app/api/search/route.js b/app/api/search/route.js
index f96747d..6f3912f 100644
--- a/app/api/search/route.js
+++ b/app/api/search/route.js
@@ -12,7 +12,7 @@ export async function GET(request) {
}
const data = { query, searchBy: 0 };
- const response = await fetchDataViaPost(url.toString(), data);
+ const response = await fetchDataViaPost(url.toString(), data, true);
if (!response) {
return NextResponse.json({ message: "Bad request" }, { status: 400 });
}
diff --git a/app/api/utils.js b/app/api/utils.js
index 3d44158..5c6b1ee 100644
--- a/app/api/utils.js
+++ b/app/api/utils.js
@@ -4,7 +4,10 @@ export const HEADERS = {
"Content-Type": "application/json; charset=UTF-8",
};
-export const fetchDataViaGet = async (url) => {
+export const fetchDataViaGet = async (url, API_V2) => {
+ if (API_V2) {
+ HEADERS["API-Version"] = "v2";
+ }
try {
const response = await fetch(url, {
headers: HEADERS,
@@ -19,7 +22,10 @@ export const fetchDataViaGet = async (url) => {
}
};
-export const fetchDataViaPost = async (url, body) => {
+export const fetchDataViaPost = async (url, body, API_V2) => {
+ if (API_V2) {
+ HEADERS["API-Version"] = "v2";
+ }
try {
const response = await fetch(url, {
method: "POST",
@@ -66,3 +72,11 @@ export function getJWT() {
export function removeJWT() {
localStorage.removeItem("JWT");
}
+
+export function numberDeclension(number, one, two, five) {
+ if (number > 10 && [11, 12, 13, 14].includes(number%100)) return five;
+ let last_num = number%10;
+ if (last_num == 1) return one;
+ if ([2,3,4].includes(last_num)) return two;
+ if ([5,6,7,8,9, 0].includes(last_num)) return five;
+}
diff --git a/app/components/RelatedSection/RelatedSection.jsx b/app/components/RelatedSection/RelatedSection.jsx
new file mode 100644
index 0000000..2154764
--- /dev/null
+++ b/app/components/RelatedSection/RelatedSection.jsx
@@ -0,0 +1,41 @@
+import { numberDeclension } from "@/app/api/utils";
+import Link from "next/link";
+
+export const RelatedSection = (props) => {
+ const declension = numberDeclension(
+ props.release_count,
+ "релиз",
+ "релиза",
+ "релизов"
+ );
+ return (
+
+ {props.release_count} {declension} во франшизе
+ Перейти
+ );
+ })}
+
{props.name_ru}
+