removed website
parent
2cb4ae0492
commit
ad4b653c40
|
@ -8,6 +8,7 @@ import Verification from "../../Pages/Verification";
|
|||
// Lazy-loaded components
|
||||
const Authentication = lazy(() => import("../../Pages/Authentication"));
|
||||
const Dashboard = lazy(() => import("../../Pages/Dashboard"));
|
||||
const PaymentPlan = lazy(() => import("../../Pages/PaymentPlan"));
|
||||
const PageNotFound = lazy(() => import("../../Pages/PageNotFound"));
|
||||
const PageInDevelopment = lazy(() => import("../../Pages/PageInDevelopment"));
|
||||
const StoreSettings = lazy(() => import("../../Pages/Store/Settings"));
|
||||
|
@ -15,7 +16,6 @@ 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"));
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export default function PaymentPlan() {
|
||||
return <h1>test</h1>;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
export default function Banner() {
|
||||
return (
|
||||
<>
|
||||
<h1>Banner</h1>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
export default function ColorPalette() {
|
||||
return <h1>ColorPalette</h1>;
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
export default function General() {
|
||||
return <h1>General</h1>;
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
import { lazy, useEffect, useState } from "react";
|
||||
import { isDevelopmentEnv, myFetch } from "../../../utils";
|
||||
import { useParams } from "react-router-dom";
|
||||
import MyCenteredContainer from "../../../Components/MyContainer";
|
||||
import { Button, Card, Result, Spin, Tabs, notification } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { MySupsenseFallback } from "../../../Components/MySupsenseFallback";
|
||||
import PageInDevelopment from "../../PageInDevelopment";
|
||||
|
||||
const General = lazy(() => import("./General"));
|
||||
const Banner = lazy(() => import("./Banner"));
|
||||
const ColorPalette = lazy(() => import("./ColorPalette"));
|
||||
|
||||
export default function Website() {
|
||||
const { storeId } = useParams();
|
||||
const { t } = useTranslation();
|
||||
const [notificationApi, notificationContextHolder] =
|
||||
notification.useNotification();
|
||||
|
||||
const [isRequesting, setIsRequesting] = useState(true);
|
||||
const [website, setWebsite] = useState({});
|
||||
|
||||
const [activeTab, setActiveTab] = useState(0);
|
||||
|
||||
const tabItems = [
|
||||
{
|
||||
label: t("storeWebsite.tabs.general"),
|
||||
children: <General />,
|
||||
},
|
||||
{
|
||||
label: t("storeWebsite.tabs.banner"),
|
||||
children: <Banner />,
|
||||
},
|
||||
{
|
||||
label: t("storeWebsite.tabs.colorPalette"),
|
||||
children: <ColorPalette />,
|
||||
},
|
||||
].map((item, index) => {
|
||||
return {
|
||||
key: index,
|
||||
...item,
|
||||
children: (
|
||||
<MySupsenseFallback spinnerCentered={false}>
|
||||
{item.children}
|
||||
</MySupsenseFallback>
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
myFetch({
|
||||
url: `/website/${storeId}`,
|
||||
method: "GET",
|
||||
notificationApi: notificationApi,
|
||||
t: t,
|
||||
})
|
||||
.then(() => setIsRequesting(false))
|
||||
.catch((err) => {
|
||||
setIsRequesting(false);
|
||||
|
||||
if (err === 404) setWebsite(null);
|
||||
|
||||
console.log(err);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (!isDevelopmentEnv()) return <PageInDevelopment />;
|
||||
|
||||
if (isRequesting) {
|
||||
return (
|
||||
<MyCenteredContainer>
|
||||
<Spin size="large" />
|
||||
</MyCenteredContainer>
|
||||
);
|
||||
}
|
||||
|
||||
if (!website) {
|
||||
return <NoWebsiteCreateOne setWebsite={setWebsite} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{notificationContextHolder}
|
||||
|
||||
<Card>
|
||||
<Tabs
|
||||
defaultActiveKey={0}
|
||||
items={tabItems}
|
||||
activeKey={activeTab}
|
||||
onChange={(key) => setActiveTab(key)}
|
||||
/>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function NoWebsiteCreateOne({ setWebsite }) {
|
||||
const { t } = useTranslation();
|
||||
const [notificationApi, notificationContextHolder] =
|
||||
notification.useNotification();
|
||||
|
||||
const { storeId } = useParams();
|
||||
|
||||
const [isRequesting, setIsRequesting] = useState(false);
|
||||
|
||||
const handleCreateWebsite = () => {
|
||||
setIsRequesting(true);
|
||||
|
||||
myFetch({
|
||||
url: "/website",
|
||||
method: "POST",
|
||||
body: {
|
||||
storeId,
|
||||
},
|
||||
notificationApi: notificationApi,
|
||||
t: t,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
|
||||
setWebsite({});
|
||||
})
|
||||
.catch((err) => {
|
||||
setIsRequesting(false);
|
||||
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<MyCenteredContainer>
|
||||
{notificationContextHolder}
|
||||
|
||||
<Result
|
||||
status="404"
|
||||
title={t("storeWebsite.noWebsite.title")}
|
||||
subTitle={t("storeWebsite.noWebsite.subTitle")}
|
||||
extra={
|
||||
<Button
|
||||
type="primary"
|
||||
loading={isRequesting}
|
||||
onClick={handleCreateWebsite}
|
||||
>
|
||||
{t("storeWebsite.noWebsite.button")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</MyCenteredContainer>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue