refactor: Refactoring router structure
This commit is contained in:
parent
ff564e73e5
commit
fda37ff58a
35
src/app/QcastProvider.js
Normal file
35
src/app/QcastProvider.js
Normal file
@ -0,0 +1,35 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||
import { appMessageStore, globalLocaleStore } from '@/store/localeAtom'
|
||||
import { ErrorBoundary } from 'next/dist/client/components/error-boundary'
|
||||
import ServerError from './error'
|
||||
|
||||
import '@/styles/common.scss'
|
||||
|
||||
import KO from '@/locales/ko.json'
|
||||
import JA from '@/locales/ja.json'
|
||||
|
||||
export const QcastProvider = ({ children }) => {
|
||||
const globalLocale = useRecoilValue(globalLocaleStore)
|
||||
const [appMessageState, setAppMessageState] = useRecoilState(appMessageStore)
|
||||
|
||||
useEffect(() => {
|
||||
console.log(sessionStorage.getItem('hi'))
|
||||
console.log(Object.keys(appMessageState).length)
|
||||
// if (Object.keys(appMessageState).length === 0) {
|
||||
if (globalLocale === 'ko') {
|
||||
setAppMessageState(KO)
|
||||
} else {
|
||||
setAppMessageState(JA)
|
||||
}
|
||||
// }
|
||||
}, [globalLocale])
|
||||
|
||||
return (
|
||||
<>
|
||||
<ErrorBoundary fallback={<ServerError />}>{children}</ErrorBoundary>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -1,10 +1,8 @@
|
||||
// import { getCurrentLocale } from '@/locales/server'
|
||||
import { getSession } from '@/lib/authActions'
|
||||
import MainPage from '@/components/Main'
|
||||
|
||||
export default async function page() {
|
||||
// const session = await getSession()
|
||||
|
||||
// const currentLocale = getCurrentLocale()
|
||||
const session = await getSession()
|
||||
|
||||
const mainPageProps = {
|
||||
isLoggedIn: session?.isLoggedIn,
|
||||
|
||||
16
src/app/community/archive/page.jsx
Normal file
16
src/app/community/archive/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Archive from '@/components/community/Archive'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function CommunityArchivePage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="자료 다운로드" />
|
||||
<div className="container flex flex-wrap items-center justify-between mx-auto p-4 m-4 border">
|
||||
<Archive />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/community/faq/page.jsx
Normal file
16
src/app/community/faq/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Faq from '@/components/community/Faq'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function CommunityFaqPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="FAQ" />
|
||||
<div className="container flex flex-wrap items-center justify-between mx-auto p-4 m-4 border">
|
||||
<Faq />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/community/notice/page.jsx
Normal file
16
src/app/community/notice/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Notice from '@/components/community/Notice'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function CommunityNoticePage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="공지사항" />
|
||||
<div className="container flex flex-wrap items-center justify-between mx-auto p-4 m-4 border">
|
||||
<Notice />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
9
src/app/floor-plan/page.jsx
Normal file
9
src/app/floor-plan/page.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import FloorPlan from '@/components/floor-plan/FloorPlan'
|
||||
|
||||
export default function FloorPlanPage() {
|
||||
return (
|
||||
<>
|
||||
<FloorPlan />
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/initSettingsModal/page.jsx
Normal file
16
src/app/initSettingsModal/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import InitSettingsModal from '@/components/InitSettingsModal'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function InitSettingsModalPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="Basic Settings" />
|
||||
<div className="flex flex-col justify-center my-8">
|
||||
<InitSettingsModal />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
14
src/app/intro/page.jsx
Normal file
14
src/app/intro/page.jsx
Normal file
@ -0,0 +1,14 @@
|
||||
import Intro from '@/components/Intro'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function IntroPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="container mx-auto p-4 m-4 border">
|
||||
<Intro />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
19
src/app/join/complete/page.jsx
Normal file
19
src/app/join/complete/page.jsx
Normal file
@ -0,0 +1,19 @@
|
||||
'use client'
|
||||
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
|
||||
export default function CompletePage() {
|
||||
const { getMessage } = useMessage()
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex min-h-full flex-1 flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<h1 className="text-center text-4xl font-bold mb-10">{getMessage('join.complete.title')}</h1>
|
||||
<div className="mt-10 mb-10 w-full text-center text-2xl">{getMessage('join.complete.contents')}</div>
|
||||
<div className="mt-10 w-full text-center">
|
||||
{getMessage('join.complete.email_comment')} : {getMessage('join.complete.email')}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
5
src/app/join/page.jsx
Normal file
5
src/app/join/page.jsx
Normal file
@ -0,0 +1,5 @@
|
||||
import Join from '@/components/auth/Join'
|
||||
|
||||
export default function JoinPage() {
|
||||
return <>{<Join />}</>
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
import { Inter } from 'next/font/google'
|
||||
|
||||
import { checkSession, getSession } from '@/lib/authActions'
|
||||
import { headers } from 'next/headers'
|
||||
import { redirect } from 'next/navigation'
|
||||
import { getSession } from '@/lib/authActions'
|
||||
import RecoilRootWrapper from './RecoilWrapper'
|
||||
import UIProvider from './UIProvider'
|
||||
|
||||
@ -11,6 +13,7 @@ import QModal from '@/components/common/modal/QModal'
|
||||
|
||||
import './globals.css'
|
||||
import '../styles/style.scss'
|
||||
import { QcastProvider } from './QcastProvider'
|
||||
|
||||
const inter = Inter({ subsets: ['latin'] })
|
||||
|
||||
@ -20,9 +23,16 @@ export const metadata = {
|
||||
}
|
||||
|
||||
export default async function RootLayout({ children }) {
|
||||
await checkSession()
|
||||
const headersList = headers()
|
||||
const headerPathname = headersList.get('x-pathname') || ''
|
||||
|
||||
// console.log('headerPathname:', headerPathname)
|
||||
// const isLoggedIn = await checkSession()
|
||||
const session = await getSession()
|
||||
console.log('session[layout]:', session)
|
||||
if (!headerPathname.includes('/login') && !session.isLoggedIn) {
|
||||
redirect('/login')
|
||||
}
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
@ -32,7 +42,9 @@ export default async function RootLayout({ children }) {
|
||||
<div className="wrap">
|
||||
<Header loginedUserNm={session.userNm} />
|
||||
<div className="content">
|
||||
<UIProvider>{children}</UIProvider>
|
||||
<UIProvider>
|
||||
<QcastProvider>{children}</QcastProvider>
|
||||
</UIProvider>
|
||||
</div>
|
||||
</div>
|
||||
<ToastContainer />
|
||||
|
||||
9
src/app/login/page.jsx
Normal file
9
src/app/login/page.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import Login from '@/components/auth/Login'
|
||||
|
||||
export default function LoginPage() {
|
||||
return (
|
||||
<>
|
||||
<Login />
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/management/plan/page.jsx
Normal file
16
src/app/management/plan/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Plan from '@/components/management/Plan'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function ManagementPlanPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="도면관리" />
|
||||
<div className="container flex flex-wrap items-center justify-between mx-auto p-4 m-4 border">
|
||||
<Plan />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
15
src/app/management/stuff/detail/page.jsx
Normal file
15
src/app/management/stuff/detail/page.jsx
Normal file
@ -0,0 +1,15 @@
|
||||
import React from 'react'
|
||||
import Hero from '@/components/Hero'
|
||||
import StuffDetail from '@/components/management/StuffDetail'
|
||||
export default function ManagementStuffDetailPage() {
|
||||
return (
|
||||
<>
|
||||
<div className="pt-48 flex justify-left">
|
||||
<h1 className="text-4xl archivo-black-regular">물건정보</h1>
|
||||
</div>
|
||||
<div className="m2">
|
||||
<StuffDetail />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
21
src/app/management/stuff/page.jsx
Normal file
21
src/app/management/stuff/page.jsx
Normal file
@ -0,0 +1,21 @@
|
||||
import StuffSearchCondition from '@/components/management/StuffSearchCondition'
|
||||
import Stuff from '@/components/management/Stuff'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
import Hero from '@/components/Hero'
|
||||
export default async function ManagementStuffPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="물건현황" />
|
||||
<div>
|
||||
<div className="m2">
|
||||
<StuffSearchCondition />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col justify-center my-8 pt-20">
|
||||
<Stuff />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/master/company/page.jsx
Normal file
16
src/app/master/company/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Company from '@/components/master/Company'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function MasterCompanyPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="회사정보 조회" />
|
||||
<div className="container flex flex-wrap items-center justify-between mx-auto p-4 m-4 border">
|
||||
<Company />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/master/price/page.jsx
Normal file
16
src/app/master/price/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Price from '@/components/master/Price'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function MasterPricePage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="가격 마스터 조회" />
|
||||
<div className="container flex flex-wrap items-center justify-between mx-auto p-4 m-4 border">
|
||||
<Price />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -1,5 +1,16 @@
|
||||
import Main from '@/components/Main'
|
||||
import MainPage from '@/components/Main'
|
||||
import { getSession } from '@/lib/authActions'
|
||||
|
||||
export default function Home() {
|
||||
return <Main />
|
||||
export default async function Home() {
|
||||
const session = await getSession()
|
||||
|
||||
const mainPageProps = {
|
||||
isLoggedIn: session?.isLoggedIn,
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<MainPage {...mainPageProps} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
17
src/app/playground/page.jsx
Normal file
17
src/app/playground/page.jsx
Normal file
@ -0,0 +1,17 @@
|
||||
import Playground from '@/components/Playground'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function PlaygroundPage() {
|
||||
// const { session } = await checkSession()
|
||||
|
||||
// if (!session.isLoggedIn) {
|
||||
// redirect('/login')
|
||||
// }
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Playground />
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/roof/page.jsx
Normal file
16
src/app/roof/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Roof from '@/components/Roof'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function RoofPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="Drawing on canvas 2D Roof" />
|
||||
<div className="flex flex-col justify-center my-8">
|
||||
<Roof />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
128
src/app/roof2/RoofSelect.jsx
Normal file
128
src/app/roof2/RoofSelect.jsx
Normal file
@ -0,0 +1,128 @@
|
||||
'use client'
|
||||
|
||||
import { Select, SelectItem } from '@nextui-org/react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useAxios } from '@/hooks/useAxios'
|
||||
|
||||
export default function RoofSelect() {
|
||||
const [roofMaterials, setRoofMaterials] = useState([])
|
||||
const [manufacturers, setManufacturers] = useState([])
|
||||
const [trestles, setTrestles] = useState([])
|
||||
const [modules, setModules] = useState([])
|
||||
const [originTrestles, setOriginTrestles] = useState([])
|
||||
|
||||
const [roofMaterialId, setRoofMaterialId] = useState(null)
|
||||
const [manufacturerId, setManufacturerId] = useState(null)
|
||||
const [trestleId, setTrestleId] = useState(null)
|
||||
|
||||
const { get } = useAxios()
|
||||
|
||||
useEffect(() => {
|
||||
get({ url: '/api/roof-material/roof-material-infos' }).then((res) => {
|
||||
//TODO: error handling
|
||||
if (!res) return
|
||||
|
||||
setRoofMaterials(res)
|
||||
})
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!roofMaterialId) {
|
||||
return
|
||||
}
|
||||
|
||||
get({ url: `/api/roof-material/roof-material-infos/${roofMaterialId}/trestles` }).then((res) => {
|
||||
if (res.length === 0) {
|
||||
return
|
||||
}
|
||||
setOriginTrestles(res)
|
||||
const manufactural = res.map((trestle) => {
|
||||
return { id: trestle.manufacturerId, name: trestle.manufacturerName }
|
||||
})
|
||||
// Remove duplicates
|
||||
const uniqueManufactural = Array.from(new Set(manufactural.map((a) => a.id))).map((id) => {
|
||||
return manufactural.find((a) => a.id === id)
|
||||
})
|
||||
|
||||
setManufacturers(uniqueManufactural)
|
||||
})
|
||||
}, [roofMaterialId])
|
||||
|
||||
useEffect(() => {
|
||||
if (!manufacturerId) {
|
||||
return
|
||||
}
|
||||
|
||||
const trestles = originTrestles.filter((trestle) => trestle.manufacturerId === manufacturerId)
|
||||
setTrestles(trestles)
|
||||
}, [manufacturerId])
|
||||
|
||||
useEffect(() => {
|
||||
if (!trestleId) {
|
||||
return
|
||||
}
|
||||
get({ url: `/api/module/module-infos?roofMaterialId=${roofMaterialId}&trestleId=${trestleId}` }).then((res) => {
|
||||
if (res.length === 0) {
|
||||
return
|
||||
}
|
||||
setModules(res)
|
||||
})
|
||||
}, [trestleId])
|
||||
|
||||
const handleRoofMaterialOnChange = (e) => {
|
||||
const roofMaterialId = e.target.value
|
||||
setRoofMaterialId(roofMaterialId)
|
||||
setManufacturers([])
|
||||
setManufacturerId(null)
|
||||
setTrestleId(null)
|
||||
setTrestles([])
|
||||
setModules([])
|
||||
}
|
||||
|
||||
const handleManufacturersOnChange = (e) => {
|
||||
const manufacturerId = Number(e.target.value)
|
||||
setTrestles([])
|
||||
setManufacturerId(manufacturerId)
|
||||
setTrestleId(null)
|
||||
setModules([])
|
||||
}
|
||||
|
||||
const handleTrestlesOnChange = (e) => {
|
||||
const trestleId = Number(e.target.value)
|
||||
setTrestleId(trestleId)
|
||||
setModules([])
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
|
||||
{roofMaterials.length > 0 && (
|
||||
<Select label="지붕재" className="max-w-xs" onChange={handleRoofMaterialOnChange}>
|
||||
{roofMaterials.map((roofMaterial) => (
|
||||
<SelectItem key={roofMaterial.id}>{roofMaterial.name}</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
{manufacturers.length > 0 && (
|
||||
<Select label="제조 회사" className="max-w-xs" onChange={handleManufacturersOnChange}>
|
||||
{manufacturers.map((manufacturer) => (
|
||||
<SelectItem key={manufacturer.id}>{manufacturer.name}</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
{trestles.length > 0 && (
|
||||
<Select label="가대" className="max-w-xs" onChange={handleTrestlesOnChange}>
|
||||
{trestles.map((trestle) => (
|
||||
<SelectItem key={trestle.id}>{trestle.name}</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
{modules.length > 0 && (
|
||||
<Select label="설치가능 모듈" className="max-w-xs">
|
||||
{modules.map((module) => (
|
||||
<SelectItem key={module.id}>{module.name}</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
26
src/app/roof2/page.jsx
Normal file
26
src/app/roof2/page.jsx
Normal file
@ -0,0 +1,26 @@
|
||||
import Roof2 from '@/components/Roof2'
|
||||
import RoofSelect from '@/app/[locale]/roof2/RoofSelect'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function Roof2Page() {
|
||||
const session = await initCheck()
|
||||
const roof2Props = {
|
||||
name: session.name || '',
|
||||
userId: session.userId || '',
|
||||
email: session.email || '',
|
||||
isLoggedIn: session.isLoggedIn,
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<div className="m-2">
|
||||
<RoofSelect />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col justify-center my-8 pt-20">
|
||||
<Roof2 {...roof2Props} />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
16
src/app/settings/page.jsx
Normal file
16
src/app/settings/page.jsx
Normal file
@ -0,0 +1,16 @@
|
||||
import Hero from '@/components/Hero'
|
||||
import Settings from '@/components/Settings'
|
||||
import { initCheck } from '@/util/session-util'
|
||||
|
||||
export default async function SettingsPage() {
|
||||
await initCheck()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero title="Canvas Setting" />
|
||||
<div className="flex flex-col justify-center my-8">
|
||||
<Settings />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { post, patch } from '@/lib/Axios'
|
||||
import { useState } from 'react'
|
||||
import { useAxios } from '@/hooks/useAxios'
|
||||
import { setSession } from '@/lib/authActions'
|
||||
import { redirect } from 'next/navigation'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
@ -9,9 +10,10 @@ import { Button, Switch } from '@nextui-org/react'
|
||||
import { useRecoilState } from 'recoil'
|
||||
import { globalLocaleStore } from '@/store/localeAtom'
|
||||
import { modalContent, modalState } from '@/store/modalAtom'
|
||||
import { useState } from 'react'
|
||||
|
||||
export default function Login(props) {
|
||||
const { patch } = useAxios()
|
||||
|
||||
const { currentLocale } = props
|
||||
const { getMessage } = useMessage()
|
||||
const [globalLocaleState, setGlbalLocaleState] = useRecoilState(globalLocaleStore)
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
'use client'
|
||||
import { Fragment } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import { usePathname, useRouter } from 'next/navigation'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
import QSelectBox from '@/components/common/select/QSelectBox'
|
||||
import React from 'react'
|
||||
import { logout } from '@/lib/authActions'
|
||||
|
||||
import QSelectBox from '@/components/common/select/QSelectBox'
|
||||
|
||||
export const ToggleonMouse = (e, act, target) => {
|
||||
const listWrap = e.target.closest(target)
|
||||
const ListItem = Array.from(listWrap.childNodes)
|
||||
@ -25,31 +26,29 @@ export default function Header(props) {
|
||||
const { loginedUserNm } = props
|
||||
const { getMessage } = useMessage()
|
||||
const pathName = usePathname()
|
||||
|
||||
if (pathName.includes('login') || pathName.includes('join')) {
|
||||
return null
|
||||
}
|
||||
// if (pathName.includes('login') || pathName.includes('join')) {
|
||||
// return null
|
||||
// }
|
||||
const SelectOption = [{ name: 'オンライン保証シ' }, { name: 'ステム' }]
|
||||
const onLogout = () => {
|
||||
logout()
|
||||
}
|
||||
const menus = [
|
||||
{ name: 'header.menus.home', url: '/', children: [] },
|
||||
{ id: 0, name: 'header.menus.home', url: '/', children: [] },
|
||||
{
|
||||
id: 1,
|
||||
name: 'header.menus.management',
|
||||
url: '',
|
||||
children: [
|
||||
{ name: 'header.menus.management.stuff', url: '/management/stuff', children: [] },
|
||||
{ name: 'header.menus.management.plan', url: '/floor-plan', children: [] },
|
||||
{ id: 3, name: 'header.menus.management.stuff', url: '/management/stuff', children: [] },
|
||||
{ id: 4, name: 'header.menus.management.plan', url: '/floor-plan', children: [] },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'header.menus.community',
|
||||
url: '',
|
||||
children: [
|
||||
{ name: 'header.menus.community.notice', url: '/community/notice', children: [] },
|
||||
{ name: 'header.menus.community.faq', url: '/community/faq', children: [] },
|
||||
{ name: 'header.menus.community.archive', url: '/community/archive', children: [] },
|
||||
{ id: 5, name: 'header.menus.community.notice', url: '/community/notice', children: [] },
|
||||
{ id: 6, name: 'header.menus.community.faq', url: '/community/faq', children: [] },
|
||||
{ id: 7, name: 'header.menus.community.archive', url: '/community/archive', children: [] },
|
||||
],
|
||||
},
|
||||
]
|
||||
@ -58,35 +57,33 @@ export default function Header(props) {
|
||||
return menus.map((menu) => {
|
||||
return (
|
||||
<li
|
||||
key={`${menu.name}-mn1`}
|
||||
key={`${menu.id}`}
|
||||
className={'nav-item'}
|
||||
onMouseEnter={(e) => ToggleonMouse(e, 'add', 'nav > ul')}
|
||||
onMouseLeave={(e) => ToggleonMouse(e, 'remove', 'nav > ul')}
|
||||
>
|
||||
{menu.children.length === 0 ? (
|
||||
<Link key={`${menu.name}-link`} href={menu.url}>
|
||||
<Link key={`${menu.id}`} href={menu.url}>
|
||||
{getMessage(menu.name)}
|
||||
</Link>
|
||||
) : (
|
||||
<React.Fragment key={`${menu.name}-frag`}>
|
||||
<Fragment key={`${menu.id}`}>
|
||||
<button>{getMessage(menu.name)}</button>
|
||||
<ul className="nav-depth2">
|
||||
{menu.children.map((m) => {
|
||||
return (
|
||||
<li
|
||||
key={`${m.name}-mn2`}
|
||||
key={`${m.id}`}
|
||||
className={'nav-depth2-item'}
|
||||
onMouseEnter={(e) => ToggleonMouse(e, 'add', 'li > ul')}
|
||||
onMouseLeave={(e) => ToggleonMouse(e, 'remove', 'li > ul')}
|
||||
>
|
||||
<Link key={`${m.name}-link`} href={m.url}>
|
||||
{getMessage(m.name)}
|
||||
</Link>
|
||||
<Link href={m.url}>{getMessage(m.name)}</Link>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</React.Fragment>
|
||||
</Fragment>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
@ -94,33 +91,35 @@ export default function Header(props) {
|
||||
}
|
||||
|
||||
return (
|
||||
<header>
|
||||
<div className="header-inner">
|
||||
<div className="header-right">
|
||||
<h1 className="logo">
|
||||
<Link href={'/'}></Link>
|
||||
</h1>
|
||||
<nav>
|
||||
<ul className="nav-list ">{getMenuTemplate(menus)}</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div className="header-left">
|
||||
<div className="profile-box">
|
||||
<button className="profile">{loginedUserNm}</button>
|
||||
!(pathName.includes('login') || pathName.includes('join')) && (
|
||||
<header>
|
||||
<div className="header-inner">
|
||||
<div className="header-right">
|
||||
<h1 className="logo">
|
||||
<Link href={'/'}></Link>
|
||||
</h1>
|
||||
<nav>
|
||||
<ul className="nav-list ">{getMenuTemplate(menus)}</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div className="sign-out-box">
|
||||
<button className="sign-out" onClick={onLogout}>
|
||||
{getMessage('header.logout')}
|
||||
</button>
|
||||
</div>
|
||||
<div className="select-box">
|
||||
<QSelectBox title={'Q.ORDER'} option={SelectOption} />
|
||||
</div>
|
||||
<div className="btn-wrap">
|
||||
<button className="btn-frame small dark">{getMessage('header.go')}</button>
|
||||
<div className="header-left">
|
||||
<div className="profile-box">
|
||||
<button className="profile">{loginedUserNm}</button>
|
||||
</div>
|
||||
<div className="sign-out-box">
|
||||
<button className="sign-out" onClick={() => logout()}>
|
||||
{getMessage('header.logout')}
|
||||
</button>
|
||||
</div>
|
||||
<div className="select-box">
|
||||
<QSelectBox title={'Q.ORDER'} option={SelectOption} />
|
||||
</div>
|
||||
<div className="btn-wrap">
|
||||
<button className="btn-frame small dark">{getMessage('header.go')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</header>
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
5
src/components/ui/Loading.jsx
Normal file
5
src/components/ui/Loading.jsx
Normal file
@ -0,0 +1,5 @@
|
||||
import style from '@/components/ui/Loading.module.css'
|
||||
|
||||
export default function Loading() {
|
||||
return <span className={style.loader}></span>
|
||||
}
|
||||
35
src/components/ui/Loading.module.css
Normal file
35
src/components/ui/Loading.module.css
Normal file
@ -0,0 +1,35 @@
|
||||
.loader {
|
||||
position: relative;
|
||||
font-size: 48px;
|
||||
letter-spacing: 6px;
|
||||
}
|
||||
.loader:before {
|
||||
content: 'Loading';
|
||||
color: #fff;
|
||||
}
|
||||
.loader:after {
|
||||
content: '';
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background-color: #ff3d00;
|
||||
background-image: radial-gradient(circle 2px, #fff4 100%, transparent 0), radial-gradient(circle 1px, #fff3 100%, transparent 0);
|
||||
background-position:
|
||||
14px -4px,
|
||||
12px -1px;
|
||||
border-radius: 50%;
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
top: -5px;
|
||||
right: 66px;
|
||||
transform-origin: center bottom;
|
||||
animation: fillBaloon 1s ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
@keyframes fillBaloon {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
100% {
|
||||
transform: scale(3);
|
||||
}
|
||||
}
|
||||
@ -38,6 +38,10 @@ export function useAxios() {
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
const promiseGet = async ({ url }) => {
|
||||
return await getInstances(url).get(url)
|
||||
}
|
||||
|
||||
const post = async ({ url, data }) => {
|
||||
return await getInstances(url)
|
||||
.post(url, data)
|
||||
@ -70,5 +74,5 @@ export function useAxios() {
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
return { get, post, promisePost, put, patch, del }
|
||||
return { get, promiseGet, post, promisePost, put, patch, del }
|
||||
}
|
||||
|
||||
@ -28,9 +28,10 @@ export async function getSession() {
|
||||
export async function checkSession() {
|
||||
const session = await getSession()
|
||||
|
||||
if (!session.isLoggedIn) {
|
||||
redirect('/login')
|
||||
}
|
||||
// if (!session.isLoggedIn) {
|
||||
// redirect('/login')
|
||||
// }
|
||||
return session.isLoggedIn
|
||||
}
|
||||
|
||||
export async function setSession(data) {
|
||||
|
||||
@ -1,27 +1,27 @@
|
||||
import { createI18nMiddleware } from 'next-international/middleware'
|
||||
// import { createI18nMiddleware } from 'next-international/middleware'
|
||||
|
||||
const I18nMiddleware = createI18nMiddleware({
|
||||
locales: ['ko', 'ja'],
|
||||
defaultLocale: 'ko',
|
||||
})
|
||||
// const I18nMiddleware = createI18nMiddleware({
|
||||
// locales: ['ko', 'ja'],
|
||||
// defaultLocale: 'ko',
|
||||
// })
|
||||
|
||||
export function middleware(request) {
|
||||
return I18nMiddleware(request)
|
||||
}
|
||||
// export function middleware(request) {
|
||||
// return I18nMiddleware(request)
|
||||
// }
|
||||
|
||||
export const config = {
|
||||
matcher: ['/((?!api|static|.*\\..*|_next|favicon.ico|robots.txt).*)'],
|
||||
}
|
||||
|
||||
// import { NextRequest, NextResponse } from 'next/server'
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
|
||||
// export function middleware(request) {
|
||||
// const requestHeaders = new Headers(request.headers)
|
||||
// requestHeaders.set('x-pathname', request.nextUrl.pathname)
|
||||
export function middleware(request) {
|
||||
const requestHeaders = new Headers(request.headers)
|
||||
requestHeaders.set('x-pathname', request.nextUrl.pathname)
|
||||
|
||||
// return NextResponse.next({
|
||||
// request: {
|
||||
// headers: requestHeaders,
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
return NextResponse.next({
|
||||
request: {
|
||||
headers: requestHeaders,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user