refactor: Update toast functionality to use Swal
This commit is contained in:
parent
8f36a5a170
commit
cba28de088
@ -14,10 +14,11 @@ import { Button } from '@nextui-org/react'
|
|||||||
import SingleDatePicker from './common/datepicker/SingleDatePicker'
|
import SingleDatePicker from './common/datepicker/SingleDatePicker'
|
||||||
import RangeDatePicker from './common/datepicker/RangeDatePicker'
|
import RangeDatePicker from './common/datepicker/RangeDatePicker'
|
||||||
import QGrid from './common/grid/QGrid'
|
import QGrid from './common/grid/QGrid'
|
||||||
import { toastUp } from '@/hooks/useToast'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
|
|
||||||
export default function Intro() {
|
export default function Intro() {
|
||||||
const { get } = useAxios()
|
const { get } = useAxios()
|
||||||
|
const { swalFire } = useSwal()
|
||||||
|
|
||||||
// const [open, setOpen] = useState(false)
|
// const [open, setOpen] = useState(false)
|
||||||
const [startDate, setStartDate] = useState(new Date())
|
const [startDate, setStartDate] = useState(new Date())
|
||||||
@ -127,9 +128,8 @@ export default function Intro() {
|
|||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
toastUp({
|
swalFire({
|
||||||
message: 'This is a toast message',
|
text: 'This is a toast message',
|
||||||
type: 'success',
|
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -14,7 +14,6 @@ import { cadFileNameState, googleMapFileNameState, useCadFileState, useGoogleMap
|
|||||||
import QSelect from '@/components/ui/QSelect'
|
import QSelect from '@/components/ui/QSelect'
|
||||||
import { Button } from '@nextui-org/react'
|
import { Button } from '@nextui-org/react'
|
||||||
import ColorPicker from './common/color-picker/ColorPicker'
|
import ColorPicker from './common/color-picker/ColorPicker'
|
||||||
import { toastUp } from '@/hooks/useToast'
|
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
|
|
||||||
import styles from './playground.module.css'
|
import styles from './playground.module.css'
|
||||||
@ -57,11 +56,11 @@ export default function Playground() {
|
|||||||
convertDwgToPng(res.data.Files[0].FileName, res.data.Files[0].FileData)
|
convertDwgToPng(res.data.Files[0].FileName, res.data.Files[0].FileData)
|
||||||
setUseCadFile(true)
|
setUseCadFile(true)
|
||||||
setCadFileName(res.data.Files[0].FileName)
|
setCadFileName(res.data.Files[0].FileName)
|
||||||
toastUp({ message: '파일 변환 완료', type: 'success' })
|
swalFire({ text: '파일 변환 완료' })
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
toastUp({ message: '파일 변환 실패', type: 'error' })
|
swalFire({ text: '파일 변환 실패' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ export default function Playground() {
|
|||||||
const res = await get({ url: `http://localhost:3000/api/html2canvas?q=${queryString}&fileNm=${fileNm}&zoom=${zoom}` })
|
const res = await get({ url: `http://localhost:3000/api/html2canvas?q=${queryString}&fileNm=${fileNm}&zoom=${zoom}` })
|
||||||
console.log('res', res)
|
console.log('res', res)
|
||||||
setGoogleMapFileName(res.fileNm)
|
setGoogleMapFileName(res.fileNm)
|
||||||
toastUp({ message: '이미지 저장 완료', type: 'success' })
|
swalFire({ text: '이미지 저장 완료' })
|
||||||
setUseGoogleMapFile(true)
|
setUseGoogleMapFile(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { settingModalFirstOptionsState, settingModalSecondOptionsState } from '@
|
|||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { toastUp } from '@/hooks/useToast'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { adsorptionPointAddModeState } from '@/store/canvasAtom'
|
import { adsorptionPointAddModeState } from '@/store/canvasAtom'
|
||||||
|
|
||||||
export default function FirstOption() {
|
export default function FirstOption() {
|
||||||
@ -14,6 +14,7 @@ export default function FirstOption() {
|
|||||||
const { option3, option4 } = settingModalSecondOptions
|
const { option3, option4 } = settingModalSecondOptions
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { get, post } = useAxios()
|
const { get, post } = useAxios()
|
||||||
|
const { swalFire } = useSwal()
|
||||||
|
|
||||||
// 데이터를 최초 한 번만 조회
|
// 데이터를 최초 한 번만 조회
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -107,12 +108,11 @@ export default function FirstOption() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HTTP POST 요청 보내기
|
// HTTP POST 요청 보내기
|
||||||
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData }).then((res) => {
|
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData }).then((res) => {\
|
||||||
//toastUp({ message: res.returnMessage, type: 'success' })
|
swalFire({ text: getMessage(res.returnMessage) })
|
||||||
toastUp({ message: getMessage(res.returnMessage), type: 'success' })
|
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {\
|
||||||
toastUp({ message: getMessage(res.returnMessage), type: 'error' })
|
swalFire({ text: getMessage(res.returnMessage) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,11 +179,10 @@ export default function FirstOption() {
|
|||||||
|
|
||||||
// HTTP POST 요청 보내기
|
// HTTP POST 요청 보내기
|
||||||
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData }).then((res) => {
|
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData }).then((res) => {
|
||||||
//toastUp({ message: res.returnMessage, type: 'success' })
|
swalFire({ text: getMessage(res.returnMessage) })
|
||||||
toastUp({ message: getMessage(res.returnMessage), type: 'success' })
|
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toastUp({ message: getMessage(res.returnMessage), type: 'error' })
|
swalFire({ text: getMessage(res.returnMessage) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { settingModalFirstOptionsState, settingModalSecondOptionsState } from '@
|
|||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { toastUp } from '@/hooks/useToast'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { adsorptionPointModeState, adsorptionRangeState } from '@/store/canvasAtom'
|
import { adsorptionPointModeState, adsorptionRangeState } from '@/store/canvasAtom'
|
||||||
|
|
||||||
export default function SecondOption() {
|
export default function SecondOption() {
|
||||||
@ -17,6 +17,7 @@ export default function SecondOption() {
|
|||||||
const { option3, option4 } = settingModalSecondOptions
|
const { option3, option4 } = settingModalSecondOptions
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { get, post } = useAxios()
|
const { get, post } = useAxios()
|
||||||
|
const { swalFire } = useSwal()
|
||||||
|
|
||||||
// 데이터를 최초 한 번만 조회
|
// 데이터를 최초 한 번만 조회
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -109,10 +110,10 @@ export default function SecondOption() {
|
|||||||
|
|
||||||
// HTTP POST 요청 보내기
|
// HTTP POST 요청 보내기
|
||||||
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData }).then((res) => {
|
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData }).then((res) => {
|
||||||
toastUp({ message: getMessage(res.returnMessage), type: 'success' })
|
swalFire({ text: getMessage(res.returnMessage) })
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toastUp({ message: getMessage(res.returnMessage), type: 'error' })
|
swalFire({ text: getMessage(res.returnMessage) })
|
||||||
}
|
}
|
||||||
setAdsorptionRange(option.range)
|
setAdsorptionRange(option.range)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user