mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-03-01 12:44:17 +00:00
removed replaced itemType on all the places where it was used to identyfi the user profile layer
This commit is contained in:
parent
f909efd229
commit
a8269b0a48
@ -16,12 +16,10 @@ export default function NavBar({ appName, userType }: { appName: string; userTyp
|
||||
|
||||
useEffect(() => {
|
||||
const profile =
|
||||
user &&
|
||||
items.find((i) => i.user_created?.id === user.id && i.layer?.itemType.name === userType)
|
||||
user && items.find((i) => i.user_created?.id === user.id && i.layer?.userProfileLayer)
|
||||
profile
|
||||
? setUserProfile(profile)
|
||||
: setUserProfile({ id: crypto.randomUUID(), name: user?.first_name ?? '', text: '' })
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [user, items])
|
||||
|
||||
// useEffect(() => {}, [userProfile])
|
||||
|
||||
@ -29,7 +29,7 @@ export function Quests() {
|
||||
items.find(
|
||||
(i) =>
|
||||
i.user_created?.id === user?.id &&
|
||||
i.layer?.itemType.name === 'user' &&
|
||||
i.layer?.userProfileLayer &&
|
||||
i.user_created?.id != null,
|
||||
),
|
||||
)
|
||||
|
||||
@ -86,8 +86,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
|
||||
map.closePopup()
|
||||
} else {
|
||||
const item = items.find(
|
||||
(i) =>
|
||||
i.user_created?.id === user?.id && i.layer?.itemType.name === props.layer.itemType.name,
|
||||
(i) => i.user_created?.id === user?.id && i.layer?.id === props.layer.id,
|
||||
)
|
||||
|
||||
const uuid = crypto.randomUUID()
|
||||
@ -114,7 +113,6 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
|
||||
...formItem,
|
||||
name: (formItem.name ? formItem.name : user?.first_name) ?? '',
|
||||
user_created: user ?? undefined,
|
||||
type: props.layer.itemType,
|
||||
id: uuid,
|
||||
layer: props.layer,
|
||||
public_edit: !user,
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { toast } from 'react-toastify'
|
||||
|
||||
import { useAppState } from '#components/AppShell/hooks/useAppState'
|
||||
import { useAuth } from '#components/Auth/useAuth'
|
||||
@ -76,14 +77,19 @@ export function ProfileForm() {
|
||||
item && setItem(item)
|
||||
|
||||
if (!item) {
|
||||
const layer = layers.find((l) => l.itemType.name === appState.userType)
|
||||
setItem({
|
||||
id: crypto.randomUUID(),
|
||||
name: user?.first_name ?? '',
|
||||
text: '',
|
||||
layer,
|
||||
new: true,
|
||||
})
|
||||
if (items.some((i) => i.user_created?.id === user?.id && i.layer?.userProfileLayer)) {
|
||||
navigate('/')
|
||||
toast.error('Item does not exist')
|
||||
} else {
|
||||
const layer = layers.find((l) => l.userProfileLayer)
|
||||
setItem({
|
||||
id: crypto.randomUUID(),
|
||||
name: user?.first_name ?? '',
|
||||
text: '',
|
||||
layer,
|
||||
new: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
||||
@ -16,24 +16,9 @@ export const ContactInfoView = ({ item, heading }: { item: Item; heading: string
|
||||
const items = useItems()
|
||||
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
'user:',
|
||||
items.find(
|
||||
(i) =>
|
||||
i.user_created?.id === item.user_created?.id &&
|
||||
i.layer?.itemType.name === appState.userType,
|
||||
),
|
||||
)
|
||||
|
||||
setProfileOwner(
|
||||
items.find(
|
||||
(i) =>
|
||||
i.user_created?.id === item.user_created?.id &&
|
||||
i.layer?.itemType.name === appState.userType,
|
||||
),
|
||||
items.find((i) => i.user_created?.id === item.user_created?.id && i.layer?.userProfileLayer),
|
||||
)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [item, items])
|
||||
|
||||
return (
|
||||
|
||||
@ -273,7 +273,6 @@ export const onUpdateItem = async (
|
||||
...changedItem,
|
||||
layer: item.layer,
|
||||
user_created: user,
|
||||
type: item.layer?.itemType,
|
||||
}),
|
||||
)
|
||||
.then(() => {
|
||||
|
||||
@ -76,7 +76,7 @@ export const AttestationForm = ({ api }: { api?: ItemsApi<unknown> }) => {
|
||||
(i) =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
i.user_created?.id === to[0].directus_users_id &&
|
||||
i.layer?.itemType.name === 'player',
|
||||
i.layer?.userProfileLayer === true,
|
||||
)?.id +
|
||||
'?tab=2',
|
||||
),
|
||||
|
||||
@ -13,7 +13,7 @@ import { MapOverlayPage } from './MapOverlayPage'
|
||||
export const SelectUser = () => {
|
||||
const appState = useAppState()
|
||||
const items = useItems()
|
||||
const users = items.filter((i) => i.layer?.itemType.name === appState.userType)
|
||||
const users = items.filter((i) => i.layer?.userProfileLayer)
|
||||
|
||||
const [selectedUsers, setSelectedUsers] = useState<string[]>([])
|
||||
|
||||
|
||||
2
src/types/Item.d.ts
vendored
2
src/types/Item.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import type { ItemsApi } from './ItemsApi'
|
||||
import type { ItemType } from './ItemType'
|
||||
import type { LayerProps } from './LayerProps'
|
||||
import type { Relation } from './Relation'
|
||||
import type { UserItem } from './UserItem'
|
||||
@ -50,7 +49,6 @@ export interface Item {
|
||||
contact?: string
|
||||
telephone?: string
|
||||
next_appointment?: string
|
||||
type?: ItemType
|
||||
gallery?: GalleryItem[]
|
||||
|
||||
// {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user