mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-12 23:36:00 +00:00
feat(release): improve typing of itemsApi (WIP) (#148)
* Improve typing of itemsApi * Show error if name of new item cannot be determined --------- Co-authored-by: Ulf Gebhardt <ulf.gebhardt@webcraft-media.de> Co-authored-by: Anton Tranelis <31516529+antontranelis@users.noreply.github.com>
This commit is contained in:
parent
18030b8bc0
commit
1de44c3e1c
@ -53,6 +53,13 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
|
||||
})
|
||||
formItem.position = { type: 'Point', coordinates: [props.position.lng, props.position.lat] }
|
||||
evt.preventDefault()
|
||||
|
||||
const name = formItem.name ? formItem.name : user?.first_name
|
||||
if (!name) {
|
||||
toast.error('Name is must be defined')
|
||||
return
|
||||
}
|
||||
|
||||
setSpinner(true)
|
||||
|
||||
formItem.text &&
|
||||
@ -98,8 +105,8 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
|
||||
;(!props.layer.userProfileLayer || !item) &&
|
||||
(await props.layer.api?.createItem!({
|
||||
...formItem,
|
||||
name,
|
||||
id: uuid,
|
||||
name: formItem.name ? formItem.name : user?.first_name,
|
||||
}))
|
||||
success = true
|
||||
// eslint-disable-next-line no-catch-all/no-catch-all
|
||||
|
||||
@ -82,7 +82,6 @@ function useItemsManager(initialItems: Item[]): {
|
||||
},
|
||||
})
|
||||
result.map((item) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
dispatch({ type: 'ADD', item: { ...item, layer } })
|
||||
return null
|
||||
})
|
||||
|
||||
3
src/types/LayerProps.d.ts
vendored
3
src/types/LayerProps.d.ts
vendored
@ -18,8 +18,7 @@ export interface LayerProps {
|
||||
markerShape: string
|
||||
markerDefaultColor: string
|
||||
markerDefaultColor2?: string
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
api?: ItemsApi<any>
|
||||
api?: ItemsApi<Item>
|
||||
itemType: ItemType
|
||||
userProfileLayer?: boolean
|
||||
customEditLink?: string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user