Merge branch 'dev' into dev-yj

This commit is contained in:
yjnoh 2024-12-19 09:59:20 +09:00
commit d7bd5d4e93
8 changed files with 96 additions and 48 deletions

View File

@ -50,7 +50,6 @@ export default async function RootLayout({ children }) {
isLoggedIn: session.isLoggedIn, isLoggedIn: session.isLoggedIn,
} }
} }
if (!headerPathname.includes('/login') && !session.isLoggedIn) { if (!headerPathname.includes('/login') && !session.isLoggedIn) {
redirect('/login') redirect('/login')
} }

View File

@ -5,7 +5,7 @@ import Image from 'next/image'
import Link from 'next/link' import Link from 'next/link'
import { useRecoilState } from 'recoil' import { useRecoilState } from 'recoil'
import { useAxios } from '@/hooks/useAxios' import { useAxios } from '@/hooks/useAxios'
import { setSession } from '@/lib/authActions' import { setSession, login } from '@/lib/authActions'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { globalLocaleStore } from '@/store/localeAtom' import { globalLocaleStore } from '@/store/localeAtom'
import { sessionStore } from '@/store/commonAtom' import { sessionStore } from '@/store/commonAtom'
@ -36,7 +36,7 @@ export default function Login() {
const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' } const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
setSession(result) setSession(result)
setSessionState(result) setSessionState(result)
router.push('/') login()
} else { } else {
router.push('/login') router.push('/login')
} }
@ -97,7 +97,8 @@ export default function Login() {
} else { } else {
Cookies.remove('chkLoginId') Cookies.remove('chkLoginId')
} }
router.push('/') // router.push('/')
login()
} else { } else {
alert(res.data.result.resultMsg) alert(res.data.result.resultMsg)
} }

View File

@ -263,7 +263,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
<select className="select-light dark" name="roofGap" ref={roofRef.rafter}> <select className="select-light dark" name="roofGap" ref={roofRef.rafter}>
{raftCodes.map((raft, index) => { {raftCodes.map((raft, index) => {
return ( return (
<option key={index} value={raft.clCode}> <option key={index} value={raft.clCode} selected={currentRoofMaterial.raft === raft.clCode}>
{raft.clCodeNm} {raft.clCodeNm}
</option> </option>
) )

View File

@ -25,16 +25,16 @@ export default function RoofAllocationSetting(props) {
roofList, roofList,
handleDefaultRoofMaterial, handleDefaultRoofMaterial,
handleChangeRoofMaterial, handleChangeRoofMaterial,
handleChangeRaft,
handleChangeLayout,
} = useRoofAllocationSetting(id) } = useRoofAllocationSetting(id)
const { fetchBasicSettings } = useCanvasSetting()
const { findCommonCode } = useCommonCode() const { findCommonCode } = useCommonCode()
const [raftCodes, setRaftCodes] = useState([]) const [raftCodes, setRaftCodes] = useState([])
useEffect(() => { useEffect(() => {
fetchBasicSettings()
const raftCodeList = findCommonCode('203800') const raftCodeList = findCommonCode('203800')
console.log('🚀 ~ useEffect ~ raftCodeList:', raftCodeList) setRaftCodes(raftCodeList.map((raft) => ({ ...raft, value: raft.clCode, name: raft.clCodeNm })))
setRaftCodes(raftCodeList)
}, []) }, [])
return ( return (
<WithDraggable isShow={true} pos={pos}> <WithDraggable isShow={true} pos={pos}>
<div className={`modal-pop-wrap ml mount`}> <div className={`modal-pop-wrap ml mount`}>
@ -125,10 +125,13 @@ export default function RoofAllocationSetting(props) {
<div className="flex-ment"> <div className="flex-ment">
<span>{getMessage('modal.placement.initial.setting.rafter')}</span> <span>{getMessage('modal.placement.initial.setting.rafter')}</span>
<div className="grid-select" style={{ width: '84px' }}> <div className="grid-select" style={{ width: '84px' }}>
<QSelectBox {raftCodes.length > 0 && (
options={raftCodes.map((raft) => ({ name: raft.clCodeNm, value: raft.clCode }))} <QSelectBox
value={raftCodes.find((r) => r.id === roof.id)} options={raftCodes.map((raft) => ({ name: raft.clCodeNm, value: raft.clCode }))}
/> onChange={(e) => handleChangeRaft(e, index)}
value={raftCodes.find((r) => r.value === roof.raft)}
/>
)}
{/* <select className="select-light dark" name="roofGap" ref={roofRef.rafter}> {/* <select className="select-light dark" name="roofGap" ref={roofRef.rafter}>
{raftCodes.map((raft, index) => { {raftCodes.map((raft, index) => {
return ( return (
@ -157,11 +160,21 @@ export default function RoofAllocationSetting(props) {
</div> </div>
<div className="block-box"> <div className="block-box">
<div className="icon-btn-wrap"> <div className="icon-btn-wrap">
<button className={roof.layout === ROOF_MATERIAL_LAYOUT.PARALLEL ? 'act' : ''}> <button
className={roof.layout === ROOF_MATERIAL_LAYOUT.PARALLEL ? 'act' : ''}
onClick={() => {
handleChangeLayout(ROOF_MATERIAL_LAYOUT.PARALLEL, index)
}}
>
{getMessage('modal.roof.alloc.select.parallel')} {getMessage('modal.roof.alloc.select.parallel')}
<i className="allocation01"></i> <i className="allocation01"></i>
</button> </button>
<button className={roof.layout === ROOF_MATERIAL_LAYOUT.STAIRS ? 'act' : ''}> <button
className={roof.layout === ROOF_MATERIAL_LAYOUT.STAIRS ? 'act' : ''}
onClick={() => {
handleChangeLayout(ROOF_MATERIAL_LAYOUT.STAIRS, index)
}}
>
{getMessage('modal.roof.alloc.select.stairs')} <i className="allocation02"></i> {getMessage('modal.roof.alloc.select.stairs')} <i className="allocation02"></i>
</button> </button>
</div> </div>

View File

@ -85,9 +85,9 @@ export default function Header(props) {
}) })
} }
useEffect(() => { // useEffect(() => {
getAutoLoginParam() // getAutoLoginParam()
}, [userSession]) // }, [userSession])
const menus = [ const menus = [
{ id: 0, name: 'header.menus.home', url: '/', children: [] }, { id: 0, name: 'header.menus.home', url: '/', children: [] },

View File

@ -125,6 +125,9 @@ export function useCanvasSetting() {
//지붕재 초기세팅 //지붕재 초기세팅
const addRoofMaterials = async () => { const addRoofMaterials = async () => {
if (roofMaterials.length !== 0) {
return
}
const { data } = await getRoofMaterialList() const { data } = await getRoofMaterialList()
const roofLists = data.map((item, idx) => ({ const roofLists = data.map((item, idx) => ({
...item, ...item,

View File

@ -1,6 +1,6 @@
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil' import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import { canvasState, currentMenuState, currentObjectState } from '@/store/canvasAtom' import { canvasState, currentMenuState, currentObjectState } from '@/store/canvasAtom'
import { useEffect, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { useSwal } from '@/hooks/useSwal' import { useSwal } from '@/hooks/useSwal'
import { usePolygon } from '@/hooks/usePolygon' import { usePolygon } from '@/hooks/usePolygon'
import { basicSettingState, roofDisplaySelector, roofMaterialsSelector, selectedRoofMaterialSelector } from '@/store/settingAtom' import { basicSettingState, roofDisplaySelector, roofMaterialsSelector, selectedRoofMaterialSelector } from '@/store/settingAtom'
@ -30,15 +30,12 @@ export function useRoofAllocationSetting(id) {
const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector) const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector)
const [basicSetting, setBasicSetting] = useRecoilState(basicSettingState) const [basicSetting, setBasicSetting] = useRecoilState(basicSettingState)
const [currentRoofMaterial, setCurrentRoofMaterial] = useState(roofMaterials[0]) // 팝업 내 기준 지붕재 const [currentRoofMaterial, setCurrentRoofMaterial] = useState(roofMaterials[0]) // 팝업 내 기준 지붕재
const [roofList, setRoofList] = useState([]) const [roofList, setRoofList] = useState(basicSetting.roofs) // 배치면 초기설정에서 선택한 지붕재 배열
const [editingLines, setEditingLines] = useState([]) const [editingLines, setEditingLines] = useState([])
const isFirstRef = useRef(0)
const { setSurfaceShapePattern } = useRoofFn() const { setSurfaceShapePattern } = useRoofFn()
useEffect(() => {
setRoofList(basicSetting.roofs)
}, [basicSetting])
useEffect(() => { useEffect(() => {
const roofBases = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF) // roofPolygon.innerLines 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) => { const handleChangeRoofMaterial = (value, index) => {
if (isFirstRef.current === 0) {
isFirstRef.current++
return
}
const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value.id) const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value.id)
const newRoofList = roofList.map((roof, idx) => { const newRoofList = roofList.map((roof, idx) => {
if (idx === index) { if (idx === index) {
@ -231,6 +233,31 @@ export function useRoofAllocationSetting(id) {
setRoofList(newRoofList) 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 { return {
handleSave, handleSave,
onAddRoofMaterial, onAddRoofMaterial,
@ -246,5 +273,7 @@ export function useRoofAllocationSetting(id) {
roofList, roofList,
handleDefaultRoofMaterial, handleDefaultRoofMaterial,
handleChangeRoofMaterial, handleChangeRoofMaterial,
handleChangeRaft,
handleChangeLayout,
} }
} }

View File

@ -59,33 +59,36 @@ export async function setSession(data) {
await session.save() await session.save()
} }
export async function login(formData) { export async function login() {
const session = await getSession() const session = await getSession()
if (session) {
const userId = formData.get('id') redirect('/')
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 (!loginUser) { // const userId = formData.get('id')
throw Error('Wrong Credentials!') // const password = formData.get('password')
}
session.name = loginUser.name // console.log('id:', userId)
session.userId = loginUser.userId // console.log('password:', password)
session.email = loginUser.email
session.isLoggedIn = true
console.log('session:', session)
await session.save() // // const loginUser = await getUserByIdAndPassword({ userId, password })
redirect('/') // 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('/')
} }