From 5b0dc3d0b9746c2577e5cbbacfba509a7e667fad Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 23 Jan 2024 23:20:43 +0100 Subject: [PATCH] website --- public/locales/de/translation.json | 21 ++++-- public/locales/en/translation.json | 21 ++++-- src/Components/AppRoutes/index.js | 10 +++ src/Components/SideMenu/index.js | 11 ++- src/Pages/Store/Calendar/index.js | 6 +- src/Pages/Store/Website/index.js | 113 +++++++++++++++++++++++++++++ src/utils.js | 26 +++---- 7 files changed, 174 insertions(+), 34 deletions(-) create mode 100644 src/Pages/Store/Website/index.js diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 4fef097..98e2e79 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -67,19 +67,19 @@ }, "sideMenu": { "overview": "Übersicht", - "website": { - "title": "Website", - "colorPalette": "Farbpalette", - "banner": "Banner", - "socials": "Soziale Netzwerke" - }, "store": { "titleSingular": "Geschäft", "titlePlural": "Geschäfte", "settings": "Einstellungen", "employees": "Mitarbeiter", "services": "Dienstleistungen", - "calendar": "Kalender" + "calendar": "Kalender", + "website": { + "title": "Website", + "colorPalette": "Farbpalette", + "banner": "Banner", + "socials": "Soziale Netzwerke" + } }, "support": "Unterstützung", "feedback": "Feedback" @@ -182,5 +182,12 @@ }, "storeSettings": { "pageTitle": "Einstellungen" + }, + "storeWebsite": { + "noWebsite": { + "title": "Sie haben noch keine Website erstellt", + "subTitle": "Jetzt loslegen und Ihre Website erstellen.", + "button": "Website erstellen" + } } } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index ddb3492..1362aa3 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -67,19 +67,19 @@ }, "sideMenu": { "overview": "Overview", - "website": { - "title": "Website", - "colorPalette": "Color palette", - "banner": "Banner", - "socials": "Socials" - }, "store": { "titleSingular": "Store", "titlePlural": "Stores", "settings": "Settings", "employees": "Employees", "services": "Services", - "calendar": "Calendar" + "calendar": "Calendar", + "website": { + "title": "Website", + "colorPalette": "Color palette", + "banner": "Banner", + "socials": "Socials" + } }, "support": "Support", "feedback": "Feedback" @@ -185,5 +185,12 @@ }, "storeSettings": { "pageTitle": "Settings" + }, + "storeWebsite": { + "noWebsite": { + "title": "You have not yet created a website", + "subTitle": "Get started now and create your website.", + "button": "Create website" + } } } diff --git a/src/Components/AppRoutes/index.js b/src/Components/AppRoutes/index.js index f116cb3..625e700 100644 --- a/src/Components/AppRoutes/index.js +++ b/src/Components/AppRoutes/index.js @@ -12,6 +12,7 @@ const StoreEmployees = lazy(() => import("../../Pages/Store/Employees")); const StoreServices = lazy(() => import("../../Pages/Store/Services")); const StoreCalendar = lazy(() => import("../../Pages/Store/Calendar")); const StoreCalendarAuth = lazy(() => import("../../Pages/Store/Calendar/Auth")); +const StoreWebsite = lazy(() => import("../../Pages/Store/Website")); //const Support = lazy(() => import("../../Pages/Support")); //const Feedback = lazy(() => import("../../Pages/Feedback")); const UserProfile = lazy(() => import("../../Pages/UserProfile")); @@ -75,6 +76,15 @@ export default function AppRoutes({ userSession, setUserSession }) { } /> + + + + } + /> + , + key: `${Constants.ROUTE_PATHS.STORE.WEBSITE}/${store.store_id}`, + }); + } + stores.children.push(groupStore); }); diff --git a/src/Pages/Store/Calendar/index.js b/src/Pages/Store/Calendar/index.js index f5f4eca..37932de 100644 --- a/src/Pages/Store/Calendar/index.js +++ b/src/Pages/Store/Calendar/index.js @@ -1,16 +1,13 @@ import { Button, Card, - Checkbox, Col, Form, - Popconfirm, Result, Row, Space, Spin, Switch, - Typography, } from "antd"; import { useTranslation } from "react-i18next"; import { @@ -19,7 +16,7 @@ import { getUserSessionFromLocalStorage, myFetch, } from "../../../utils"; -import { Suspense, useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import MyCenteredContainer from "../../../Components/MyContainer"; import { MyCalendarMaxFutureBookingDaysFormInput, @@ -32,7 +29,6 @@ import { } from "../../../Components/MyRequestStateItem"; import MyModal, { MyModalCloseConfirmButtonFooter, - MyModalCloseSaveButtonFooter, } from "../../../Components/MyModal"; import { useParams } from "react-router-dom"; diff --git a/src/Pages/Store/Website/index.js b/src/Pages/Store/Website/index.js new file mode 100644 index 0000000..b59f72d --- /dev/null +++ b/src/Pages/Store/Website/index.js @@ -0,0 +1,113 @@ +import { useEffect, useState } from "react"; +import { myFetch } from "../../../utils"; +import { useParams } from "react-router-dom"; +import MyCenteredContainer from "../../../Components/MyContainer"; +import { Button, Card, Result, Spin, Tabs } from "antd"; +import { useTranslation } from "react-i18next"; + +export default function Website() { + const { storeId } = useParams(); + const { t } = useTranslation(); + + const [isRequesting, setIsRequesting] = useState(true); + const [website, setWebsite] = useState({}); + + useEffect(() => { + myFetch(`/website/${storeId}`, "GET") + .then((res) => { + console.log(res); + + setIsRequesting(false); + }) + .catch((err) => { + setIsRequesting(false); + + if (err === 404) setWebsite(null); + + console.log(err); + }); + }, []); + + if (isRequesting) { + return ( + + + + ); + } + + if (!website) { + return ; + } + + return ( +
+

Website

+ + + ({ + label: item, + key: item, + content:
Test
, + }))} + /> +
+
+ ); +} + +function NoWebsiteCreateOne({ setWebsite }) { + const { t } = useTranslation(); + const { storeId } = useParams(); + + const [isRequesting, setIsRequesting] = useState(false); + + const handleCreateWebsite = () => { + setIsRequesting(true); + + myFetch("/website", "POST", { + storeId, + }) + .then((res) => { + console.log(res); + + setWebsite({}); + }) + .catch((err) => { + setIsRequesting(false); + + console.log(err); + }); + }; + + return ( + + + {t("storeWebsite.noWebsite.button")} + + } + /> + + ); +} diff --git a/src/utils.js b/src/utils.js index 400bf3f..6060d83 100644 --- a/src/utils.js +++ b/src/utils.js @@ -9,24 +9,24 @@ import { v4 as uuidv4 } from "uuid"; const wssProtocol = window.location.protocol === "https:" ? "wss://" : "ws://"; let apiAddress = ""; -let staticContentAddress = ""; -let wsAddress = ""; +// let staticContentAddress = ""; +// let wsAddress = ""; if (window.location.hostname === "localhost" && window.location.port === "") { // for docker container testing on localhost apiAddress = "http://localhost/api/v1"; - staticContentAddress = "http://localhost/api/"; - wsAddress = "ws://localhost/ws"; + // staticContentAddress = "http://localhost/api/"; + // wsAddress = "ws://localhost/ws"; } else if (window.location.hostname === "localhost") { // programming on localhost - apiAddress = "http://localhost:50250/api/v1"; - staticContentAddress = "http://localhost:50050/"; - wsAddress = "ws://localhost:50050/ws"; + apiAddress = "http://localhost:50128/api/v1"; + // staticContentAddress = "http://localhost:50050/"; + // wsAddress = "ws://localhost:50050/ws"; } else { // production apiAddress = `${window.location.protocol}//${window.location.hostname}/api/v1`; - staticContentAddress = `${window.location.protocol}//${window.location.hostname}/api/`; - wsAddress = `${wssProtocol}${window.location.hostname}/ws`; + //staticContentAddress = `${window.location.protocol}//${window.location.hostname}/api/`; + // wsAddress = `${wssProtocol}${window.location.hostname}/ws`; } export const Constants = { @@ -37,20 +37,18 @@ export const Constants = { }, TEXT_EMPTY_PLACEHOLDER: "-/-", API_ADDRESS: apiAddress, - STATIC_CONTENT_ADDRESS: staticContentAddress, - WS_ADDRESS: wsAddress, + //STATIC_CONTENT_ADDRESS: staticContentAddress, + // WS_ADDRESS: wsAddress, EMBED_CALENDAR_ADDRESS: "https://calendar.ex.umbach.dev/embed/?id=", ROUTE_PATHS: { OVERVIEW: "/", - WEBSITE_COLOR_PALETTE: "/website/color-palette", - WEBSITE_SOCIALS: "/website/socials", - WEBSITE_BANNER: "/website/banner", STORE: { SETTINGS: "/store/settings", EMPLOYEES: "/store/employees", SERVICES: "/store/services", CALENDAR: "/store/calendar", CALENDAR_AUTH: "/store/calendar/auth", + WEBSITE: "/store/website", }, FEEDBACK: "/feedback", SUPPORT: "/support",