mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
fix(lib): auto close update position toast (#277)
* add close button to custom info modal * auto close update position toat * Revert "add close button to custom info modal" This reverts commit cf5b9a407effe0772ed622ce2369cf16e0b82175. * fix: reset position for new items without text
This commit is contained in:
parent
c92695eea7
commit
045ec726eb
@ -20,7 +20,7 @@ export const SelectPosition = ({
|
|||||||
</label>
|
</label>
|
||||||
<div className='tw:alert tw:bg-base-100 tw:text-base-content'>
|
<div className='tw:alert tw:bg-base-100 tw:text-base-content'>
|
||||||
<div>
|
<div>
|
||||||
{selectNewItemPosition && 'text' in selectNewItemPosition && (
|
{selectNewItemPosition && 'layer' in selectNewItemPosition && (
|
||||||
<span className='tw:text-lg'>
|
<span className='tw:text-lg'>
|
||||||
Select new position of <b>{selectNewItemPosition.name}</b> on the map!
|
Select new position of <b>{selectNewItemPosition.name}</b> on the map!
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@ -69,7 +69,7 @@ function useSelectPositionManager(): {
|
|||||||
})
|
})
|
||||||
setSelectPosition(null)
|
setSelectPosition(null)
|
||||||
}
|
}
|
||||||
if ('text' in selectPosition) {
|
if ('layer' in selectPosition) {
|
||||||
// if selectPosition is an Item
|
// if selectPosition is an Item
|
||||||
const position =
|
const position =
|
||||||
mapClicked?.position.lng &&
|
mapClicked?.position.lng &&
|
||||||
@ -101,9 +101,9 @@ function useSelectPositionManager(): {
|
|||||||
success = true
|
success = true
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
toast.update(toastId, { render: error.message, type: 'error' })
|
toast.update(toastId, { render: error.message, type: 'error', autoClose: 5000 })
|
||||||
} else if (typeof error === 'string') {
|
} else if (typeof error === 'string') {
|
||||||
toast.update(toastId, { render: error, type: 'error' })
|
toast.update(toastId, { render: error, type: 'error', autoClose: 5000 })
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
@ -115,6 +115,7 @@ function useSelectPositionManager(): {
|
|||||||
render: 'Item position updated',
|
render: 'Item position updated',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
})
|
})
|
||||||
setSelectPosition(null)
|
setSelectPosition(null)
|
||||||
setMarkerClicked(null)
|
setMarkerClicked(null)
|
||||||
@ -125,6 +126,8 @@ function useSelectPositionManager(): {
|
|||||||
render: "you don't have permission to add items to " + markerClicked?.name,
|
render: "you don't have permission to add items to " + markerClicked?.name,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
|
closeButton: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,16 +143,34 @@ function useSelectPositionManager(): {
|
|||||||
success = true
|
success = true
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
toast.update(toastId, { render: error.message, type: 'error', isLoading: false })
|
toast.update(toastId, {
|
||||||
|
render: error.message,
|
||||||
|
type: 'error',
|
||||||
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
|
closeButton: true,
|
||||||
|
})
|
||||||
} else if (typeof error === 'string') {
|
} else if (typeof error === 'string') {
|
||||||
toast.update(toastId, { render: error, type: 'error', isLoading: false })
|
toast.update(toastId, {
|
||||||
|
render: error,
|
||||||
|
type: 'error',
|
||||||
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
|
closeButton: true,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
updateItem(updatedItem)
|
updateItem(updatedItem)
|
||||||
toast.update(toastId, { render: 'Item position updated', type: 'success', isLoading: false })
|
toast.update(toastId, {
|
||||||
|
render: 'Item position updated',
|
||||||
|
type: 'success',
|
||||||
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
|
closeButton: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,16 +189,34 @@ function useSelectPositionManager(): {
|
|||||||
success = true
|
success = true
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
toast.update(toastId, { render: error.message, type: 'error', isLoading: false })
|
toast.update(toastId, {
|
||||||
|
render: error.message,
|
||||||
|
type: 'error',
|
||||||
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
|
closeButton: true,
|
||||||
|
})
|
||||||
} else if (typeof error === 'string') {
|
} else if (typeof error === 'string') {
|
||||||
toast.update(toastId, { render: error, type: 'error', isLoading: false })
|
toast.update(toastId, {
|
||||||
|
render: error,
|
||||||
|
type: 'error',
|
||||||
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
|
closeButton: true,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
updateItem({ ...markerClicked, relations: newRelations })
|
updateItem({ ...markerClicked, relations: newRelations })
|
||||||
toast.update(toastId, { render: 'Item linked', type: 'success', isLoading: false })
|
toast.update(toastId, {
|
||||||
|
render: 'Item linked',
|
||||||
|
type: 'success',
|
||||||
|
isLoading: false,
|
||||||
|
autoClose: 5000,
|
||||||
|
closeButton: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user