Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Error
- HEAD /_next/data/development/en/host/dashboard.json 500 in 56ms
- HEAD /_next/data/development/en/host/dashboard.json 500 in 41ms
- ⨯ /home/mwafrika/byfood/node_modules/rc-util/es/React/render.js:1
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
- ^^^^^^
- SyntaxError: Cannot use import statement outside a module
- at internalCompileFunction (node:internal/vm:128:18)
- at wrapSafe (node:internal/modules/cjs/loader:1280:20)
- at Module._compile (node:internal/modules/cjs/loader:1332:27)
- at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
- at Module.load (node:internal/modules/cjs/loader:1206:32)
- at Module._load (node:internal/modules/cjs/loader:1022:12)
- at Module.require (node:internal/modules/cjs/loader:1231:19)
- at mod.require (/home/mwafrika/byfood/node_modules/next/dist/server/require-hook.js:65:28)
- at require (node:internal/modules/helpers:179:18)
- at rc-util/es/React/render (/home/mwafrika/byfood/apps/japan-site/.next/server/pages/host/dashboard.js:4892:18)
- at __webpack_require__ (/home/mwafrika/byfood/apps/japan-site/.next/server/webpack-runtime.js:33:42)
- at eval (webpack-internal:///../../node_modules/antd/es/message/index.js:8:81)
- at ../../node_modules/antd/es/message/index.js (/home/mwafrika/byfood/apps/japan-site/.next/server/vendor-chunks/antd.js:170:1)
- at __webpack_require__ (/home/mwafrika/byfood/apps/japan-site/.next/server/webpack-runtime.js:33:42)
- at eval (webpack-internal:///__barrel_optimize__?names=message!=!../../node_modules/antd/es/index.js:5:66) {
- page: '/host/dashboard'
- }
- HEAD /_next/data/development/en/host/dashboard.json 500 in 42ms
- HEAD /_next/data/development/en/host/dashboard.json 500 in 36ms
- // Code
- import React, { useCallback, useContext, useEffect, useMemo } from "react";
- import { css } from "@emotion/react";
- import { Box, Flex } from "@rebass/grid/emotion";
- import { Colors, GlobalStyles } from "@byfood/fe-styles";
- import Router, { useRouter } from "next/router";
- import { Cookie, LocalStorage } from "@byfood/fe-utils";
- import { EnvVariables, StorageKeys, Users } from "@byfood/fe-data";
- import DashboardSvg from "../../../svg/host/DashboardSvg";
- import LogOutSvg from "../../../svg/host/LogOutSvg";
- import CollapseMenu from "./CollapseMenu";
- import { experienceLinks, productLinks } from "../Host.data";
- import ProfilePicUpdate from "./ProfilePicUpdate";
- import { LanguageContext } from "../../../contexts/language/LanguageProvider";
- import NextLink from "../../../components/NextLink";
- import Anchor from "../../../components/Anchor";
- import { UserContextProps, UserContext } from "../../../contexts/user/UserContext";
- import PartnerFaqSvg from "../../../svg/host/PartnerFaqSvg";
- import { message } from "antd";
- interface Props {
- user: Users.User;
- }
- function LeftPanel(props: Props) {
- const { user } = useContext(UserContext) as UserContextProps;
- const router = useRouter();
- const isDashboard = router.pathname === "/host/dashboard";
- const [usr, setUsr] = React.useState<Users.User>({} as Users.User);
- const langCtx = useContext(LanguageContext).langData;
- useEffect(() => {
- if (user) {
- setUsr(user);
- }
- }, [user]);
- const onLogOut = useCallback(() => {
- Cookie.removeAllCookies();
- LocalStorage.removeItemFromStorage(StorageKeys.USER_STORAGE_KEY);
- message.success("You’ve successfully logged out.");
- Router.push("/");
- console.log("You’ve successfully logged out.", "Left side panel");
- Users.logout().catch(() => {
- Cookie.removeAllCookies();
- LocalStorage.removeItemFromStorage(StorageKeys.USER_STORAGE_KEY);
- message.warning("You’ve successfully logged out.");
- Router.push("/");
- });
- }, []);
- const renderCollapse = useMemo(() => {
- switch (EnvVariables.REGION_ENV) {
- case EnvVariables.REGION_JP: {
- return (
- <>
- <CollapseMenu
- title={langCtx.hostSideMenu_lblExperiences.toUpperCase()}
- data={experienceLinks}
- user={usr}
- />
- <CollapseMenu
- title={langCtx.hostSideMenu_lblCreateGourmet.toUpperCase()}
- data={productLinks}
- user={usr}
- />
- </>
- );
- }
- default: {
- return (
- <CollapseMenu
- title={langCtx.hostSideMenu_lblExperiences.toUpperCase()}
- data={experienceLinks}
- user={usr}
- />
- );
- }
- }
- }, [langCtx, user]);
- return (
- <Box width={1}>
- <Box css={align}>
- <Flex justifyContent={"center"}>
- <ProfilePicUpdate user={usr} onUpdate={(updatedUsr: Users.User) => setUsr(updatedUsr)} />
- </Flex>
- <Box mt={20} css={nameTxt}>
- {usr.NameSurname}
- </Box>
- <NextLink href={"/host/account"} css={accountTxt}>
- {langCtx.hostSideMenu_hdrAccountSettings}
- </NextLink>
- </Box>
- <Box mt={42} mb={50} key={"dashboard"} width={1}>
- <Anchor href={"/host/dashboard"} css={GlobalStyles.href}>
- <Flex alignItems={"center"}>
- <DashboardSvg fill={isDashboard ? Colors.lightRed : undefined} />
- <Box ml={12} css={linkTxt(isDashboard)}>
- {langCtx.hostSideMenu_lblDash}
- </Box>
- </Flex>
- </Anchor>
- </Box>
- {renderCollapse}
- <Box mt={50} key={"partner-faq"} width={1}>
- <Anchor css={GlobalStyles.href} href={"/partner-faq"}>
- <Flex alignItems={"center"}>
- <PartnerFaqSvg fill={Colors.lightRed} />
- <Box ml={12} css={linkTxt(true)}>
- {langCtx.hostSideMenu_partnerfaq}
- </Box>
- </Flex>
- </Anchor>
- </Box>
- <Box mt={50} key={"logout"} onClick={onLogOut} width={1}>
- <Anchor css={GlobalStyles.href} href={"/"}>
- <Flex alignItems={"center"}>
- <LogOutSvg />
- <Box ml={12} css={linkTxt()}>
- {langCtx.hostSideMenu_lblLogout}
- </Box>
- </Flex>
- </Anchor>
- </Box>
- </Box>
- );
- }
- export default LeftPanel;
Advertisement
Add Comment
Please, Sign In to add comment