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