Canvas 설정 화면 수정(globalLocale 및 toastUp 적용)
This commit is contained in:
parent
ea6ba4ef2c
commit
993870e169
@ -4,15 +4,21 @@ import { useEffect, useState } from 'react'
|
|||||||
import MenuDepth01 from './MenuDepth01'
|
import MenuDepth01 from './MenuDepth01'
|
||||||
import QSelectBox from '@/components/common/select/QSelectBox'
|
import QSelectBox from '@/components/common/select/QSelectBox'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { post } from '@/lib/Axios'
|
|
||||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
|
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
|
||||||
import { settingModalFirstOptionsState, settingModalSecondOptionsState } from '@/store/settingAtom'
|
import { settingModalFirstOptionsState, settingModalSecondOptionsState } from '@/store/settingAtom'
|
||||||
import { canvasState, canvasZoomState, currentMenuState, verticalHorizontalModeState } from '@/store/canvasAtom'
|
import { canvasState, canvasZoomState, currentMenuState, verticalHorizontalModeState } from '@/store/canvasAtom'
|
||||||
import { outerLinePointsState } from '@/store/outerLineAtom'
|
import { outerLinePointsState } from '@/store/outerLineAtom'
|
||||||
|
import { appMessageStore, globalLocaleStore } from '@/store/localeAtom'
|
||||||
import { MENU } from '@/common/common'
|
import { MENU } from '@/common/common'
|
||||||
|
|
||||||
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
|
import { toastUp } from '@/hooks/useToast'
|
||||||
|
|
||||||
|
import KO from '@/locales/ko.json'
|
||||||
|
import JA from '@/locales/ja.json'
|
||||||
|
|
||||||
export default function CanvasMenu(props) {
|
export default function CanvasMenu(props) {
|
||||||
const [objectNo] = useState('test123240912001') // 이후 삭제 필요
|
const [objectNo, setObjectNo] = useState('test123240912001') // 이후 삭제 필요
|
||||||
const { setShowCanvasSettingModal, showOutlineModal, setShowOutlineModal } = props
|
const { setShowCanvasSettingModal, showOutlineModal, setShowOutlineModal } = props
|
||||||
const [menuNumber, setMenuNumber] = useState(null)
|
const [menuNumber, setMenuNumber] = useState(null)
|
||||||
const [verticalHorizontalMode, setVerticalHorizontalMode] = useRecoilState(verticalHorizontalModeState)
|
const [verticalHorizontalMode, setVerticalHorizontalMode] = useRecoilState(verticalHorizontalModeState)
|
||||||
@ -22,6 +28,9 @@ export default function CanvasMenu(props) {
|
|||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
const setCurrentMenu = useSetRecoilState(currentMenuState)
|
const setCurrentMenu = useSetRecoilState(currentMenuState)
|
||||||
const setPoints = useSetRecoilState(outerLinePointsState)
|
const setPoints = useSetRecoilState(outerLinePointsState)
|
||||||
|
const globalLocale = useRecoilValue(globalLocaleStore)
|
||||||
|
const [appMessageState, setAppMessageState] = useRecoilState(appMessageStore)
|
||||||
|
const { post } = useAxios()
|
||||||
|
|
||||||
const SelectOption = [{ name: '瓦53A' }, { name: '瓦53A' }]
|
const SelectOption = [{ name: '瓦53A' }, { name: '瓦53A' }]
|
||||||
const onClickNav = (number) => {
|
const onClickNav = (number) => {
|
||||||
@ -38,7 +47,13 @@ export default function CanvasMenu(props) {
|
|||||||
const firstOptions = useRecoilState(settingModalFirstOptionsState)
|
const firstOptions = useRecoilState(settingModalFirstOptionsState)
|
||||||
const secondOptions = useRecoilState(settingModalSecondOptionsState)
|
const secondOptions = useRecoilState(settingModalSecondOptionsState)
|
||||||
|
|
||||||
useEffect(() => {}, [menuNumber, type])
|
useEffect(() => {
|
||||||
|
if (globalLocale === 'k') {
|
||||||
|
setAppMessageState(KO)
|
||||||
|
} else {
|
||||||
|
setAppMessageState(JA)
|
||||||
|
}
|
||||||
|
}, [menuNumber, type, globalLocale])
|
||||||
|
|
||||||
// 저장버튼(btn08) 클릭 시 호출되는 함수
|
// 저장버튼(btn08) 클릭 시 호출되는 함수
|
||||||
const handleSaveSettings = async () => {
|
const handleSaveSettings = async () => {
|
||||||
@ -65,6 +80,7 @@ export default function CanvasMenu(props) {
|
|||||||
|
|
||||||
const patternData = {
|
const patternData = {
|
||||||
objectNo,
|
objectNo,
|
||||||
|
//디스플레이 설정(다중)
|
||||||
assignDisplay: dataToSend.firstOption1[0].selected,
|
assignDisplay: dataToSend.firstOption1[0].selected,
|
||||||
drawDisplay: dataToSend.firstOption1[1].selected,
|
drawDisplay: dataToSend.firstOption1[1].selected,
|
||||||
gridDisplay: dataToSend.firstOption1[2].selected,
|
gridDisplay: dataToSend.firstOption1[2].selected,
|
||||||
@ -76,9 +92,11 @@ export default function CanvasMenu(props) {
|
|||||||
trestleDisplay: dataToSend.firstOption1[8].selected,
|
trestleDisplay: dataToSend.firstOption1[8].selected,
|
||||||
coordiDisplay: dataToSend.firstOption1[9].selected,
|
coordiDisplay: dataToSend.firstOption1[9].selected,
|
||||||
drawConverDisplay: dataToSend.firstOption1[10].selected,
|
drawConverDisplay: dataToSend.firstOption1[10].selected,
|
||||||
|
//화면 표시(다중)
|
||||||
onlyBorder: dataToSend.firstOption2[0].selected,
|
onlyBorder: dataToSend.firstOption2[0].selected,
|
||||||
lineHatch: dataToSend.firstOption2[1].selected,
|
lineHatch: dataToSend.firstOption2[1].selected,
|
||||||
allPainted: dataToSend.firstOption2[2].selected,
|
allPainted: dataToSend.firstOption2[2].selected,
|
||||||
|
//흡착범위 설정(단건)
|
||||||
adsorpRangeSmall: dataToSend.secondOption2[0].selected,
|
adsorpRangeSmall: dataToSend.secondOption2[0].selected,
|
||||||
adsorpRangeSmallSemi: dataToSend.secondOption2[1].selected,
|
adsorpRangeSmallSemi: dataToSend.secondOption2[1].selected,
|
||||||
adsorpRangeMedium: dataToSend.secondOption2[2].selected,
|
adsorpRangeMedium: dataToSend.secondOption2[2].selected,
|
||||||
@ -86,13 +104,11 @@ export default function CanvasMenu(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HTTP POST 요청 보내기
|
// HTTP POST 요청 보내기
|
||||||
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData })
|
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData }).then((res) => {
|
||||||
|
toastUp({ message: res.returnMessage, type: 'success' })
|
||||||
// 응답 처리
|
})
|
||||||
alert('설정이 저장되었습니다.')
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('설정을 저장하는 동안 오류가 발생했습니다:', error)
|
toastUp({ message: res.returnMessage, type: 'error' })
|
||||||
alert('설정을 저장하는 중 오류가 발생했습니다.')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,28 +1,24 @@
|
|||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
import { settingModalFirstOptionsState } from '@/store/settingAtom'
|
import { settingModalFirstOptionsState } from '@/store/settingAtom'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useCallback, useEffect, useState } from 'react'
|
||||||
import { get } from '@/lib/Axios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
|
|
||||||
export default function FirstOption() {
|
export default function FirstOption() {
|
||||||
const [objectNo] = useState('test123240912001') // 이후 삭제 필요
|
const [objectNo, setObjectNo] = useState('test123240912001') // 이후 삭제 필요
|
||||||
const [settingsModalOptions, setSettingModalOptions] = useRecoilState(settingModalFirstOptionsState)
|
const [settingsModalOptions, setSettingModalOptions] = useRecoilState(settingModalFirstOptionsState)
|
||||||
const { option1, option2 } = settingsModalOptions
|
const { option1, option2 } = settingsModalOptions
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
|
const { get } = useAxios()
|
||||||
const [isFetched, setIsFetched] = useState(false) // 조회 여부 상태
|
|
||||||
|
|
||||||
// 데이터를 최초 한 번만 조회
|
// 데이터를 최초 한 번만 조회
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('FirstOption useEffect 실행')
|
console.log('FirstOption useEffect 실행')
|
||||||
if (!isFetched) {
|
fetchSettings()
|
||||||
// 조회가 안 되었을 때만 fetchSettings 실행
|
}, [objectNo])
|
||||||
fetchSettings()
|
|
||||||
}
|
|
||||||
}, [isFetched]) // isFetched 상태가 변할 때마다 확인
|
|
||||||
|
|
||||||
// Canvas Setting 조회 및 초기화
|
// Canvas Setting 조회 및 초기화
|
||||||
const fetchSettings = async () => {
|
const fetchSettings = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await get({ url: `/api/canvas-management/canvas-settings/by-object/${objectNo}` })
|
const res = await get({ url: `/api/canvas-management/canvas-settings/by-object/${objectNo}` })
|
||||||
|
|
||||||
@ -49,12 +45,10 @@ export default function FirstOption() {
|
|||||||
option1,
|
option1,
|
||||||
option2,
|
option2,
|
||||||
})
|
})
|
||||||
|
|
||||||
setIsFetched(true) // 조회가 완료되면 isFetched를 true로 설정
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Data fetching error:', error)
|
console.error('Data fetching error:', error)
|
||||||
}
|
}
|
||||||
}
|
}, [objectNo])
|
||||||
|
|
||||||
const onClickOption = (option) => {
|
const onClickOption = (option) => {
|
||||||
option.selected = !option.selected
|
option.selected = !option.selected
|
||||||
@ -67,23 +61,25 @@ export default function FirstOption() {
|
|||||||
<div className="modal-check-btn-wrap">
|
<div className="modal-check-btn-wrap">
|
||||||
<h3 className="check-wrap-title light">{getMessage('modal.canvas.setting.first.option.info')}</h3>
|
<h3 className="check-wrap-title light">{getMessage('modal.canvas.setting.first.option.info')}</h3>
|
||||||
<div className="flex-check-box for2">
|
<div className="flex-check-box for2">
|
||||||
{settingsModalOptions?.option1?.map((item) => (
|
{settingsModalOptions &&
|
||||||
<button key={item.id} className={`check-btn ${item.selected ? 'act' : ''}`} onClick={(e) => onClickOption(item)}>
|
settingsModalOptions.option1.map((item) => (
|
||||||
<span className="check-area"></span>
|
<button key={item.id} className={`check-btn ${item.selected ? 'act' : ''}`} onClick={(e) => onClickOption(item)}>
|
||||||
<span className="title-area">{getMessage(item.name)}</span>
|
<span className="check-area"></span>
|
||||||
</button>
|
<span className="title-area">{getMessage(item.name)}</span>
|
||||||
))}
|
</button>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-check-btn-wrap">
|
<div className="modal-check-btn-wrap">
|
||||||
<h3 className="check-wrap-title">{getMessage('modal.canvas.setting.first.option.display')}</h3>
|
<h3 className="check-wrap-title">{getMessage('modal.canvas.setting.first.option.display')}</h3>
|
||||||
<div className="flex-check-box for-line">
|
<div className="flex-check-box for-line">
|
||||||
{settingsModalOptions?.option2?.map((item) => (
|
{settingsModalOptions &&
|
||||||
<button key={item.id} className={`check-btn ${item.selected ? 'act' : ''}`} onClick={(e) => onClickOption(item)}>
|
settingsModalOptions.option2.map((item) => (
|
||||||
<span className="check-area"></span>
|
<button key={item.id} className={`check-btn ${item.selected ? 'act' : ''}`} onClick={(e) => onClickOption(item)}>
|
||||||
<span className="title-area">{getMessage(item.name)}</span>
|
<span className="check-area"></span>
|
||||||
</button>
|
<span className="title-area">{getMessage(item.name)}</span>
|
||||||
))}
|
</button>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -1,27 +1,24 @@
|
|||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
import { settingModalSecondOptionsState } from '@/store/settingAtom'
|
import { settingModalSecondOptionsState } from '@/store/settingAtom'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useCallback, useEffect, useState } from 'react'
|
||||||
import { get } from '@/lib/Axios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
|
|
||||||
export default function SecondOption() {
|
export default function SecondOption() {
|
||||||
const [objectNo] = useState('test123240912001') // 이후 삭제 필요
|
const [objectNo, setObjectNo] = useState('test123240912001') // 이후 삭제 필요
|
||||||
const [settingsModalOptions, setSettingModalOptions] = useRecoilState(settingModalSecondOptionsState)
|
const [settingsModalOptions, setSettingModalOptions] = useRecoilState(settingModalSecondOptionsState)
|
||||||
const { option1, option2 } = settingsModalOptions
|
const { option1, option2 } = settingsModalOptions
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
|
const { get } = useAxios()
|
||||||
const [isFetched, setIsFetched] = useState(false) // 조회 여부 상태
|
|
||||||
|
|
||||||
// 데이터를 최초 한 번만 조회
|
// 데이터를 최초 한 번만 조회
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('SecondOption useEffect 실행')
|
console.log('SecondOption useEffect 실행')
|
||||||
if (!isFetched) {
|
fetchSettings()
|
||||||
// 조회가 안 되었을 때만 fetchSettings 실행
|
}, [objectNo])
|
||||||
fetchSettings()
|
|
||||||
}
|
|
||||||
}, [isFetched]) // isFetched 상태가 변할 때마다 확인
|
|
||||||
|
|
||||||
const fetchSettings = async () => {
|
// Canvas Setting 조회 및 초기화
|
||||||
|
const fetchSettings = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await get({ url: `/api/canvas-management/canvas-settings/by-object/${objectNo}` })
|
const res = await get({ url: `/api/canvas-management/canvas-settings/by-object/${objectNo}` })
|
||||||
|
|
||||||
@ -36,12 +33,10 @@ export default function SecondOption() {
|
|||||||
option1,
|
option1,
|
||||||
option2,
|
option2,
|
||||||
})
|
})
|
||||||
|
|
||||||
setIsFetched(true) // 조회가 완료되면 isFetched를 true로 설정
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Data fetching error:', error)
|
console.error('Data fetching error:', error)
|
||||||
}
|
}
|
||||||
}
|
}, [objectNo])
|
||||||
|
|
||||||
const onClickOption = (option) => {
|
const onClickOption = (option) => {
|
||||||
// option2에서 한 개만 선택 가능하도록 처리
|
// option2에서 한 개만 선택 가능하도록 처리
|
||||||
@ -54,22 +49,24 @@ export default function SecondOption() {
|
|||||||
<div className="modal-check-btn-wrap">
|
<div className="modal-check-btn-wrap">
|
||||||
<h3 className="check-wrap-title">{getMessage('modal.canvas.setting.font.plan.edit')}</h3>
|
<h3 className="check-wrap-title">{getMessage('modal.canvas.setting.font.plan.edit')}</h3>
|
||||||
<div className="flex-check-box for2">
|
<div className="flex-check-box for2">
|
||||||
{settingsModalOptions.option1.map((item, index) => (
|
{settingsModalOptions &&
|
||||||
<button key={item.id || index} className="arr-btn">
|
settingsModalOptions.option1.map((item) => (
|
||||||
<span>{getMessage(item.name)}</span>
|
<button key={item.id} className="arr-btn">
|
||||||
</button>
|
<span>{getMessage(item.name)}</span>
|
||||||
))}
|
</button>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-check-btn-wrap">
|
<div className="modal-check-btn-wrap">
|
||||||
<h3 className="check-wrap-title">{getMessage('modal.canvas.setting.font.plan.absorption')}</h3>
|
<h3 className="check-wrap-title">{getMessage('modal.canvas.setting.font.plan.absorption')}</h3>
|
||||||
<div className="flex-check-box for-line">
|
<div className="flex-check-box for-line">
|
||||||
{settingsModalOptions.option2.map((item, index) => (
|
{settingsModalOptions &&
|
||||||
<button key={item.id || index} className={`check-btn ${item.selected ? 'act' : ''}`} onClick={() => onClickOption(item)}>
|
settingsModalOptions.option2.map((item) => (
|
||||||
<span className="check-area"></span>
|
<button key={item.id} className={`check-btn ${item.selected ? 'act' : ''}`} onClick={() => onClickOption(item)}>
|
||||||
<span className="title-area">{getMessage(item.name)}</span>
|
<span className="check-area"></span>
|
||||||
</button>
|
<span className="title-area">{getMessage(item.name)}</span>
|
||||||
))}
|
</button>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-check-box for-line">
|
<div className="flex-check-box for-line">
|
||||||
<button className="arr-btn">
|
<button className="arr-btn">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user