diff --git a/client/index.html b/client/index.html index 85c7310..cdd081f 100644 --- a/client/index.html +++ b/client/index.html @@ -9,5 +9,49 @@
+ + + + + diff --git a/client/package.json b/client/package.json index 238c4fb..8b962b2 100644 --- a/client/package.json +++ b/client/package.json @@ -22,7 +22,6 @@ "react-rangeslider": "^2.2.0", "react-router-dom": "^6.18.0", "react-swipeable": "^7.0.1", - "react-yandex-metrika": "^2.6.0", "usehooks-ts": "^2.9.1", "zustand": "^4.4.6" }, diff --git a/client/public/videos/showreel_1080p_4000k_h264.mp4 b/client/public/videos/showreel_1080p_4000k_h264.mp4 index 3bed4a2..156467d 100644 Binary files a/client/public/videos/showreel_1080p_4000k_h264.mp4 and b/client/public/videos/showreel_1080p_4000k_h264.mp4 differ diff --git a/client/src/App.tsx b/client/src/App.tsx index e530ea7..95ad006 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -2,7 +2,6 @@ import "./App.css"; import "react-rangeslider/lib/index.css"; import "./components/RangeSlider.css"; -import { YMInitializer } from "react-yandex-metrika"; import IProject from "./types/IProject"; import api from "./utils/api"; import { useEffect, useState } from "react"; @@ -34,6 +33,7 @@ function App() { const [projects, setProjects] = useState([]); const [setModal] = useModalStore((state) => [state.setModal]); const [isShownAllProjects, setIsShownAllProjects] = useState(false); + const [isBuffering, setIsBuffering] = useState(true); async function getProjects() { try { @@ -52,7 +52,7 @@ function App() { }, []); return ( - <> +
@@ -104,66 +104,86 @@ function App() {
-
+
-
- - Помогаем
продавать{" "} -
{" "} - - проще
и{" "} - + + Продавайте недвижимость +
+ + проще и{" "} + + быстрее - {" "} -
- дороже -
-
+
+ +
{" "} + дороже + +
-

- Мы собрали статистику за 13 лет работы +

+

+ Мы собрали статистику{" "} + за 13 лет{" "} + работы
- с застройщиками, реализовав 31 проект + с застройщиками,{" "} + + реализовав 31 проект +

-
-

- Мы собрали статистику{" "} - за 13 лет{" "} - работы -
- с застройщиками,{" "} - - реализовав 31 проект - -

- -
- -
+
+
-

+

Graff.estate

@@ -409,7 +429,7 @@ function App() { title="ЖК «Айвазовский City»" location="Россия, Тюмень" background="/images/stream/aivaz.jpg" - link="https://stream.graff.tech/?build=Ivazowsky&location=a1" + link="https://stream.graff.tech/?build=IvazowskyDev&location=a1" />
@@ -754,19 +774,7 @@ function App() {
- - - +
); } diff --git a/client/src/components/Calc.tsx b/client/src/components/Calc.tsx index 9016144..7bf5f40 100644 --- a/client/src/components/Calc.tsx +++ b/client/src/components/Calc.tsx @@ -7,6 +7,7 @@ import ArrowRightIcon from "./icons/ArrowRightIcon"; import regionsData from "../assets/regionsData.json"; import { useEffect, useState } from "react"; import CloseIcon from "./icons/CloseIcon"; +import api from "../utils/api"; interface Region { id: number; @@ -17,9 +18,11 @@ interface Region { } function Calc() { - const [consultations, setConsultations] = useState(100); const [selectedRegion, setSelectedRegion] = useState(); - const [implementationPeriod, setImplementationPeriod] = useState(); + const [consultations, setConsultations] = useState(100); + const [implementationPeriod, setImplementationPeriod] = useState( + null! + ); const [oldImplementationPeriod, setOldImplementationPeriod] = useState(); const [monthlyIncome, setMonthlyIncome] = useState(); @@ -39,8 +42,23 @@ function Calc() { const [diffImplementationPeriodEnding, setDiffImplementationPeriodEnding] = useState(); + async function getRegionName() { + const result: any = await api.get("getRegionName").json(); + + if (result.error) { + setSelectedRegion(regionsData.find((region) => region.id === 11)); + return; + } + + const foundRegion = + regionsData.find((region) => region.name === result.regionName) || + regionsData.find((region) => region.id === 11); + + setSelectedRegion(foundRegion); + } + useEffect(() => { - setSelectedRegion(regionsData.find((region) => region.id === 11)); + getRegionName(); }, []); useEffect(() => { @@ -94,8 +112,6 @@ function Calc() { }, [monthlyIncome, oldMonthlyIncome]); useEffect(() => { - if (!implementationPeriod) return; - if (implementationPeriod > 10 && implementationPeriod < 15) { setOldImplementationPeriodEnding("месяцев"); return; @@ -160,21 +176,23 @@ function Calc() {
- region.id === 11)?.name} - options={regionsData.map((regionItem) => regionItem.name)} - handleSelect={(option) => { - const foundRegion = regionsData.find( - (region) => region.name === option - ); + {selectedRegion && ( + regionItem.name)} + handleSelect={(option) => { + const foundRegion = regionsData.find( + (region) => region.name === option + ); - if (foundRegion) { - setSelectedRegion(foundRegion); - } - }} - /> + if (foundRegion) { + setSelectedRegion(foundRegion); + } + }} + /> + )}

Установлены усредненные показатели по региону. diff --git a/client/src/components/CalcSelect.tsx b/client/src/components/CalcSelect.tsx index 0fddd1b..1fb8707 100644 --- a/client/src/components/CalcSelect.tsx +++ b/client/src/components/CalcSelect.tsx @@ -6,7 +6,7 @@ import { useOnClickOutside } from "usehooks-ts"; interface CalcSelectProps { label: string; placeholder: string; - defaultOption?: string; + defaultOption: string; options: string[]; handleSelect: (option: string) => void; } diff --git a/client/yarn.lock b/client/yarn.lock index 4bb54fb..91203b5 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -1491,11 +1491,6 @@ react-swipeable@^7.0.1: resolved "https://registry.yarnpkg.com/react-swipeable/-/react-swipeable-7.0.1.tgz#cd299f5986c5e4a7ee979839658c228f660e1e0c" integrity sha512-RKB17JdQzvECfnVj9yDZsiYn3vH0eyva/ZbrCZXZR0qp66PBRhtg4F9yJcJTWYT5Adadi+x4NoG53BxKHwIYLQ== -react-yandex-metrika@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/react-yandex-metrika/-/react-yandex-metrika-2.6.0.tgz#9c935c8c7ea5505e34391b9b3e86deb6d50053c9" - integrity sha512-8K4wExsNZtY3DTxh1G8a+zWH9Pg8fw23MJcoJ4I/562qrHRnh7L5nteq3lnNL58dnNQbuuHIRoGgMjIo+r1GjA== - react@^18.2.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" diff --git a/server/src/index.ts b/server/src/index.ts index b42f042..15061e0 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -5,6 +5,7 @@ import cors from "cors"; import mailRoute from "./routes/mail"; import projectRoute from "./routes/projects"; import uploadRoute from "./routes/upload"; +import getRegionNameRoute from "./routes/getRegionName"; connectDB(); @@ -17,6 +18,7 @@ app.use(cors({ origin: "*" })); app.use("/mail", mailRoute); app.use("/projects", projectRoute); app.use("/upload", uploadRoute); +app.use("/getRegionName", getRegionNameRoute); app.listen(port, () => { console.log(`Server is listening on port ${port}`); diff --git a/server/src/routes/getRegionName.ts b/server/src/routes/getRegionName.ts new file mode 100644 index 0000000..40a4c98 --- /dev/null +++ b/server/src/routes/getRegionName.ts @@ -0,0 +1,31 @@ +import { Router } from "express"; +import fs from "fs"; + +const router = Router(); + +router.get("/", async (req, res) => { + const ip = req.headers["x-forwarded-for"]; + + try { + const { countryCode, region, regionName }: any = await ( + await fetch(`http://ip-api.com/json/${ip}?lang=ru`) + ).json(); + + if (countryCode === "RU") { + fs.appendFileSync( + "./log.txt", + `${countryCode}-${region} (${regionName})\n` + ); + } + + res.json({ regionName }); + } catch (error) { + if (error instanceof Error) { + res.json({ error: error.message }); + } + } +}); + +const getRegionNameRoute = router; + +export default getRegionNameRoute;