diff --git a/src/app/layout.js b/src/app/layout.js index 3383aa10..0f688eea 100644 --- a/src/app/layout.js +++ b/src/app/layout.js @@ -50,7 +50,6 @@ export default async function RootLayout({ children }) { isLoggedIn: session.isLoggedIn, } } - if (!headerPathname.includes('/login') && !session.isLoggedIn) { redirect('/login') } diff --git a/src/components/auth/Login.jsx b/src/components/auth/Login.jsx index af50a515..55711929 100644 --- a/src/components/auth/Login.jsx +++ b/src/components/auth/Login.jsx @@ -5,7 +5,7 @@ import Image from 'next/image' import Link from 'next/link' import { useRecoilState } from 'recoil' import { useAxios } from '@/hooks/useAxios' -import { setSession } from '@/lib/authActions' +import { setSession, login } from '@/lib/authActions' import { useMessage } from '@/hooks/useMessage' import { globalLocaleStore } from '@/store/localeAtom' import { sessionStore } from '@/store/commonAtom' @@ -36,7 +36,7 @@ export default function Login() { const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' } setSession(result) setSessionState(result) - router.push('/') + login() } else { router.push('/login') } @@ -97,7 +97,8 @@ export default function Login() { } else { Cookies.remove('chkLoginId') } - router.push('/') + // router.push('/') + login() } else { alert(res.data.result.resultMsg) } diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx index 9c2ade43..c508ad37 100644 --- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx +++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx @@ -263,7 +263,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set {raftCodes.map((raft, index) => { return ( @@ -157,11 +160,21 @@ export default function RoofAllocationSetting(props) {
- -
diff --git a/src/components/header/Header.jsx b/src/components/header/Header.jsx index b8cfafd2..2e2e98cd 100644 --- a/src/components/header/Header.jsx +++ b/src/components/header/Header.jsx @@ -85,9 +85,9 @@ export default function Header(props) { }) } - useEffect(() => { - getAutoLoginParam() - }, [userSession]) + // useEffect(() => { + // getAutoLoginParam() + // }, [userSession]) const menus = [ { id: 0, name: 'header.menus.home', url: '/', children: [] }, diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index 26b78b51..59cb4eef 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -125,6 +125,9 @@ export function useCanvasSetting() { //지붕재 초기세팅 const addRoofMaterials = async () => { + if (roofMaterials.length !== 0) { + return + } const { data } = await getRoofMaterialList() const roofLists = data.map((item, idx) => ({ ...item, diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index ff20c0cb..d2215131 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -1,6 +1,6 @@ import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil' import { canvasState, currentMenuState, currentObjectState } from '@/store/canvasAtom' -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useSwal } from '@/hooks/useSwal' import { usePolygon } from '@/hooks/usePolygon' import { basicSettingState, roofDisplaySelector, roofMaterialsSelector, selectedRoofMaterialSelector } from '@/store/settingAtom' @@ -30,15 +30,12 @@ export function useRoofAllocationSetting(id) { const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector) const [basicSetting, setBasicSetting] = useRecoilState(basicSettingState) const [currentRoofMaterial, setCurrentRoofMaterial] = useState(roofMaterials[0]) // 팝업 내 기준 지붕재 - const [roofList, setRoofList] = useState([]) + const [roofList, setRoofList] = useState(basicSetting.roofs) // 배치면 초기설정에서 선택한 지붕재 배열 const [editingLines, setEditingLines] = useState([]) + const isFirstRef = useRef(0) const { setSurfaceShapePattern } = useRoofFn() - useEffect(() => { - setRoofList(basicSetting.roofs) - }, [basicSetting]) - useEffect(() => { const roofBases = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF) // roofPolygon.innerLines @@ -211,6 +208,11 @@ export function useRoofAllocationSetting(id) { // 지붕재 변경 const handleChangeRoofMaterial = (value, index) => { + if (isFirstRef.current === 0) { + isFirstRef.current++ + return + } + const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value.id) const newRoofList = roofList.map((roof, idx) => { if (idx === index) { @@ -231,6 +233,31 @@ export function useRoofAllocationSetting(id) { setRoofList(newRoofList) } + // 서까래 변경 + const handleChangeRaft = (e, index) => { + const raftValue = e.value + + const newRoofList = roofList.map((roof, idx) => { + if (idx === index) { + return { ...roof, raft: raftValue } + } + return roof + }) + + setRoofList(newRoofList) + } + + const handleChangeLayout = (layoutValue, index) => { + const newRoofList = roofList.map((roof, idx) => { + if (idx === index) { + return { ...roof, layout: layoutValue } + } + return roof + }) + + setRoofList(newRoofList) + } + return { handleSave, onAddRoofMaterial, @@ -246,5 +273,7 @@ export function useRoofAllocationSetting(id) { roofList, handleDefaultRoofMaterial, handleChangeRoofMaterial, + handleChangeRaft, + handleChangeLayout, } } diff --git a/src/lib/authActions.js b/src/lib/authActions.js index 0834833e..929d3895 100644 --- a/src/lib/authActions.js +++ b/src/lib/authActions.js @@ -59,33 +59,36 @@ export async function setSession(data) { await session.save() } -export async function login(formData) { +export async function login() { const session = await getSession() - - const userId = formData.get('id') - const password = formData.get('password') - - console.log('id:', userId) - console.log('password:', password) - - // const loginUser = await getUserByIdAndPassword({ userId, password }) - const loginUser = { - id: 1, - userId: 'test123', - name: 'jinsoo Kim', - email: 'jinsoo.kim@example.com', + if (session) { + redirect('/') } - if (!loginUser) { - throw Error('Wrong Credentials!') - } + // const userId = formData.get('id') + // const password = formData.get('password') - session.name = loginUser.name - session.userId = loginUser.userId - session.email = loginUser.email - session.isLoggedIn = true - console.log('session:', session) + // console.log('id:', userId) + // console.log('password:', password) - await session.save() - redirect('/') + // // const loginUser = await getUserByIdAndPassword({ userId, password }) + // const loginUser = { + // id: 1, + // userId: 'test123', + // name: 'jinsoo Kim', + // email: 'jinsoo.kim@example.com', + // } + + // if (!loginUser) { + // throw Error('Wrong Credentials!') + // } + + // session.name = loginUser.name + // session.userId = loginUser.userId + // session.email = loginUser.email + // session.isLoggedIn = true + // console.log('session:', session) + + // await session.save() + // redirect('/') }