mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-12 23:36:00 +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>
|
||||
<div className='tw:alert tw:bg-base-100 tw:text-base-content'>
|
||||
<div>
|
||||
{selectNewItemPosition && 'text' in selectNewItemPosition && (
|
||||
{selectNewItemPosition && 'layer' in selectNewItemPosition && (
|
||||
<span className='tw:text-lg'>
|
||||
Select new position of <b>{selectNewItemPosition.name}</b> on the map!
|
||||
</span>
|
||||
|
||||
@ -69,7 +69,7 @@ function useSelectPositionManager(): {
|
||||
})
|
||||
setSelectPosition(null)
|
||||
}
|
||||
if ('text' in selectPosition) {
|
||||
if ('layer' in selectPosition) {
|
||||
// if selectPosition is an Item
|
||||
const position =
|
||||
mapClicked?.position.lng &&
|
||||
@ -101,9 +101,9 @@ function useSelectPositionManager(): {
|
||||
success = true
|
||||
} catch (error: unknown) {
|
||||
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') {
|
||||
toast.update(toastId, { render: error, type: 'error' })
|
||||
toast.update(toastId, { render: error, type: 'error', autoClose: 5000 })
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
@ -115,6 +115,7 @@ function useSelectPositionManager(): {
|
||||
render: 'Item position updated',
|
||||
type: 'success',
|
||||
isLoading: false,
|
||||
autoClose: 5000,
|
||||
})
|
||||
setSelectPosition(null)
|
||||
setMarkerClicked(null)
|
||||
@ -125,6 +126,8 @@ function useSelectPositionManager(): {
|
||||
render: "you don't have permission to add items to " + markerClicked?.name,
|
||||
type: 'error',
|
||||
isLoading: false,
|
||||
autoClose: 5000,
|
||||
closeButton: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -140,16 +143,34 @@ function useSelectPositionManager(): {
|
||||
success = true
|
||||
} catch (error: unknown) {
|
||||
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') {
|
||||
toast.update(toastId, { render: error, type: 'error', isLoading: false })
|
||||
toast.update(toastId, {
|
||||
render: error,
|
||||
type: 'error',
|
||||
isLoading: false,
|
||||
autoClose: 5000,
|
||||
closeButton: true,
|
||||
})
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
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
|
||||
} catch (error: unknown) {
|
||||
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') {
|
||||
toast.update(toastId, { render: error, type: 'error', isLoading: false })
|
||||
toast.update(toastId, {
|
||||
render: error,
|
||||
type: 'error',
|
||||
isLoading: false,
|
||||
autoClose: 5000,
|
||||
closeButton: true,
|
||||
})
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
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