Merge branch 'dev' of https://git.hanasys.jp/qcast3/onsitesurvey into feature/survey
This commit is contained in:
commit
901b7b1ae8
@ -1,5 +1,5 @@
|
||||
import Header from '@/components/ui/common/Header'
|
||||
|
||||
export default async function page() {
|
||||
return <Header name={'調査物件一覧'} />
|
||||
return <Header />
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
export default function layout({ children }: { children: React.ReactNode }) {
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
export default function layout({ children }: { children: ReactNode }) {
|
||||
return <div className="container">{children}</div>
|
||||
}
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import type { Metadata } from 'next'
|
||||
import type { SessionData } from '@/types/Auth'
|
||||
|
||||
import ReactQueryProviders from '@/providers/ReactQueryProvider'
|
||||
import EdgeProvider from '@/providers/EdgeProvider'
|
||||
import PopupController from '@/components/ui/PopupController'
|
||||
|
||||
import '@/styles/style.scss'
|
||||
import { cookies } from 'next/headers'
|
||||
import { getIronSession } from 'iron-session'
|
||||
import { sessionOptions } from '@/libs/session'
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import '@/styles/style.scss'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Create Next App',
|
||||
@ -21,9 +25,14 @@ interface RootLayoutProps {
|
||||
}6
|
||||
|
||||
export default async function RootLayout({ children, header, footer, floatBtn }: RootLayoutProps): Promise<ReactNode> {
|
||||
const cookieStore = await cookies()
|
||||
const session = await getIronSession<SessionData>(cookieStore, sessionOptions)
|
||||
|
||||
const sessionData = JSON.stringify(session)
|
||||
|
||||
return (
|
||||
<ReactQueryProviders>
|
||||
<EdgeProvider>
|
||||
<EdgeProvider sessionData={sessionData}>
|
||||
<html lang="ja" suppressHydrationWarning>
|
||||
<body>
|
||||
<div className="wrap">
|
||||
|
||||
23
src/app/pw-reset/layout.tsx
Normal file
23
src/app/pw-reset/layout.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
interface PwResetLayoutProps {
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
export default function layout({ children }: PwResetLayoutProps) {
|
||||
return (
|
||||
<>
|
||||
<div className="container">
|
||||
<div className="sale-contents">
|
||||
<div className="border-frame">
|
||||
<div className="pw-guide">
|
||||
<div className="pw-guide-tit">パスワードをリセットする</div>
|
||||
<div className="pw-guide-txt">新しいパスワードを入力してください.</div>
|
||||
</div>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
9
src/app/pw-reset/page.tsx
Normal file
9
src/app/pw-reset/page.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import PwResetForm from '@/components/pw-reset/PwResetForm'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<>
|
||||
<PwResetForm />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
import { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
interface SuitableLayoutProps {
|
||||
children: ReactNode
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
interface SurveySaleLayoutProps {
|
||||
children: ReactNode
|
||||
|
||||
59
src/components/pw-reset/PwResetForm.tsx
Normal file
59
src/components/pw-reset/PwResetForm.tsx
Normal file
@ -0,0 +1,59 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
|
||||
export default function PwResetForm() {
|
||||
const [pwShow01, setPwShow01] = useState(false) //비밀번호 확인 보이기 숨기기
|
||||
const [pwShow02, setPwShow02] = useState(false) //비밀번호 재확인 보이기 숨기기
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="border-frame">
|
||||
<div className="data-form-wrap">
|
||||
<div className="data-input-form-bx">
|
||||
<div className="data-input-form-tit">
|
||||
新規パスワード再入力 <i className="import">*</i>
|
||||
</div>
|
||||
<div className="data-input">
|
||||
<div className="login-input pw change">
|
||||
<input type={`${pwShow01 ? 'text' : 'password'}`} className="login-frame" placeholder="●●●●" />
|
||||
<button className={`login-icon ${pwShow01 ? 'act' : ''}`} onClick={() => setPwShow01(!pwShow01)}>
|
||||
<i className="show-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="data-input-guide">10文字以内</div>
|
||||
</div>
|
||||
<div className="data-input-form-bx">
|
||||
<div className="data-input-form-tit">
|
||||
新規パスワード入力 <i className="import">*</i>
|
||||
</div>
|
||||
<div className="data-input">
|
||||
<div className="login-input pw change">
|
||||
<input type={`${pwShow02 ? 'text' : 'password'}`} className="login-frame" placeholder="●●●●" />
|
||||
<button className={`login-icon ${pwShow02 ? 'act' : ''}`} onClick={() => setPwShow02(!pwShow02)}>
|
||||
<i className="show-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="data-input-guide">10文字以内</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="btn-flex-wrap">
|
||||
<div className="btn-bx">
|
||||
<button className="btn-frame n-blue icon" onClick={() => router.back()}>
|
||||
戻る<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div className="btn-bx">
|
||||
<button className="btn-frame red icon">
|
||||
リセットする<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -4,27 +4,23 @@ import Link from 'next/link'
|
||||
import { usePathname, useRouter } from 'next/navigation'
|
||||
|
||||
import { Swiper, SwiperSlide } from 'swiper/react'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
|
||||
import { useSideNavState } from '@/store/sideNavState'
|
||||
import { useHeaderStore } from '@/store/header'
|
||||
import { useSessionStore } from '@/store/session'
|
||||
import { useTitle } from '@/hooks/useTitle'
|
||||
|
||||
import type { HeaderProps } from '@/types/Header'
|
||||
import { axiosInstance } from '@/libs/axios'
|
||||
|
||||
import 'swiper/css'
|
||||
import { axiosInstance } from '@/libs/axios'
|
||||
import { useSessionStore } from '@/store/session'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
|
||||
// type HeaderProps = {
|
||||
// name: string //header 이름
|
||||
// backBtn: boolean // 뒤로가기 버튼 유무
|
||||
// }
|
||||
|
||||
export default function Header({ name }: HeaderProps) {
|
||||
export default function Header() {
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const { sideNavIsOpen, setSideNavIsOpen } = useSideNavState()
|
||||
const { backBtn } = useHeaderStore()
|
||||
const { getTitle } = useTitle()
|
||||
|
||||
const { session, reset } = useSessionStore()
|
||||
const queryClient = useQueryClient()
|
||||
@ -53,7 +49,7 @@ export default function Header({ name }: HeaderProps) {
|
||||
</div>
|
||||
)}
|
||||
<h2 className="logo">
|
||||
<Link href={'/'}>{name}</Link>
|
||||
<Link href={'/'}>{getTitle(pathname)}</Link>
|
||||
</h2>
|
||||
<div className="side-button-wrap">
|
||||
<button className="side-button" onClick={() => setSideNavIsOpen(true)}></button>
|
||||
@ -112,7 +108,7 @@ export default function Header({ name }: HeaderProps) {
|
||||
<button onClick={() => router.push('/inquiry/regist')}>1:1お問い合わせ登録</button>
|
||||
</li>
|
||||
<li className="side-nav-item">
|
||||
<button>パスワードリセット</button>
|
||||
<button onClick={() => router.push('/pw-reset')}>パスワードリセット</button>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
37
src/hooks/useTitle.ts
Normal file
37
src/hooks/useTitle.ts
Normal file
@ -0,0 +1,37 @@
|
||||
export const useTitle = () => {
|
||||
const getTitle = (pathname: string) => {
|
||||
// Handle dynamic routes first
|
||||
if (pathname.startsWith('/survey-sale/') && pathname !== '/survey-sale/basic-info' && pathname !== '/survey-sale/roof-info') {
|
||||
return '調査物件一覧'
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/inquiry/') && pathname !== '/inquiry/list' && pathname !== '/inquiry/regist') {
|
||||
return '1:1お問い合わせ詳細'
|
||||
}
|
||||
|
||||
// Handle static routes
|
||||
switch (pathname) {
|
||||
case '/':
|
||||
return 'Hanasys 現地調査'
|
||||
case '/suitable':
|
||||
return '屋根材適合性の確認'
|
||||
case '/survey-sale':
|
||||
return '調査物件一覧'
|
||||
case '/survey-sale/basic-info':
|
||||
return '調査物件登録'
|
||||
case '/survey-sale/roof-info':
|
||||
return '調査物件新規登録'
|
||||
case '/inquiry/list':
|
||||
return '1:1お問い合わせ'
|
||||
case '/inquiry/regist':
|
||||
return '1:1お問い合わせ'
|
||||
case '/pw-reset':
|
||||
return 'パスワードリセット'
|
||||
|
||||
default:
|
||||
return 'Hanasys 現地調査'
|
||||
}
|
||||
}
|
||||
|
||||
return { getTitle }
|
||||
}
|
||||
@ -1,25 +1,29 @@
|
||||
'use client'
|
||||
|
||||
import { useAlertSwitch } from '@/store/alertSwitch'
|
||||
import { useHeaderStore } from '@/store/header'
|
||||
import { usePopupController } from '@/store/popupController'
|
||||
import { useSideNavState } from '@/store/sideNavState'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import { useEffect } from 'react'
|
||||
import { useSessionStore } from '@/store/session'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
alert2: (msg: string, alert2BtnYes?: () => void, alert2BtnNo?: () => void) => void
|
||||
}
|
||||
interface EdgeProviderProps {
|
||||
children: React.ReactNode
|
||||
sessionData: string
|
||||
}
|
||||
|
||||
export default function EdgeProvider({ children }: React.PropsWithChildren) {
|
||||
export default function EdgeProvider({ children, sessionData }: EdgeProviderProps) {
|
||||
const pathname = usePathname()
|
||||
const { setBackBtn } = useHeaderStore()
|
||||
const { reset } = useSideNavState()
|
||||
const { setAlertMsg, setAlertBtn, setAlert, setAlert2, setAlert2BtnYes, setAlert2BtnNo } = usePopupController()
|
||||
const { alertKind } = useAlertSwitch()
|
||||
const { session, setSession } = useSessionStore()
|
||||
|
||||
/**
|
||||
* alert 함수 - window.alert 함수 대체
|
||||
* @param msg
|
||||
* @param alertBtn
|
||||
*/
|
||||
const alertFunc = (msg: string, alertBtn: Function) => {
|
||||
console.log('🚀 ~ alertFunc ~ msg:', msg)
|
||||
setAlertMsg(msg)
|
||||
@ -27,7 +31,7 @@ export default function EdgeProvider({ children }: React.PropsWithChildren) {
|
||||
setAlert(true)
|
||||
}
|
||||
/**
|
||||
* alert2 함수
|
||||
* alert2 함수 - window.confirm 함수 대체
|
||||
* @param msg alert 메시지
|
||||
* @param alertBtn2Yes alert 확인 버튼 클릭시 실행되는 함수
|
||||
* @param alertBtn2No alert 취소 버튼 클릭시 실행되는 함수
|
||||
@ -42,16 +46,28 @@ export default function EdgeProvider({ children }: React.PropsWithChildren) {
|
||||
|
||||
//alert 함수 변경해서 바인딩
|
||||
useEffect(() => {
|
||||
if (alertKind === 'single') {
|
||||
window.alert = function (msg, alertBtn = () => setAlert(false)) {
|
||||
alertFunc(msg, alertBtn)
|
||||
}
|
||||
} else if (alertKind === 'multi') {
|
||||
window.alert = function (msg, alert2BtnYes = () => setAlert2(false), alert2BtnNo = () => setAlert2(false)) {
|
||||
alertFunc2(msg, alert2BtnYes, alert2BtnNo)
|
||||
}
|
||||
window.alert = function (msg, alertBtn = () => setAlert(false)) {
|
||||
alertFunc(msg, alertBtn)
|
||||
}
|
||||
}, [alertKind])
|
||||
window.confirm = function (msg = '', alert2BtnYes = () => setAlert2(false), alert2BtnNo = () => setAlert2(false)) {
|
||||
alertFunc2(
|
||||
msg,
|
||||
() => {
|
||||
alert2BtnYes()
|
||||
return true
|
||||
},
|
||||
() => {
|
||||
alert2BtnNo()
|
||||
return false
|
||||
},
|
||||
)
|
||||
return false
|
||||
}
|
||||
setSession({
|
||||
...session,
|
||||
...JSON.parse(sessionData),
|
||||
})
|
||||
}, [])
|
||||
|
||||
/**
|
||||
* 헤더 뒤로가기 버튼 컨트롤
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
import { create } from 'zustand'
|
||||
|
||||
type AlertSwitchState = {
|
||||
alertKind: string
|
||||
setAlertKind: (value: string) => void
|
||||
reset: () => void
|
||||
}
|
||||
|
||||
type InitialState = {
|
||||
alertKind: string
|
||||
}
|
||||
|
||||
const initialState: InitialState = {
|
||||
alertKind: 'single',
|
||||
}
|
||||
|
||||
export const useAlertSwitch = create<AlertSwitchState>((set) => ({
|
||||
...initialState,
|
||||
setAlertKind: (value: string) => set((state) => ({ ...state, alertKind: value })),
|
||||
reset: () => set(initialState),
|
||||
}))
|
||||
Loading…
x
Reference in New Issue
Block a user