mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
just open profile when item exist and loaded
This commit is contained in:
parent
216dbc1b79
commit
0a3f752ab1
@ -19,7 +19,7 @@ import { useTags } from '../Map/hooks/useTags';
|
||||
|
||||
export function ProfileView({ userType }: { userType: string }) {
|
||||
|
||||
const [item, setItem] = useState<Item>({} as Item)
|
||||
const [item, setItem] = useState<Item>()
|
||||
const [updatePermission, setUpdatePermission] = useState<boolean>(false);
|
||||
const [relations, setRelations] = useState<Array<Item>>([]);
|
||||
const [offers, setOffers] = useState<Array<Tag>>([]);
|
||||
@ -51,15 +51,15 @@ export function ProfileView({ userType }: { userType: string }) {
|
||||
setNeeds([]);
|
||||
setRelations([]);
|
||||
|
||||
item.layer?.itemOffersField && getValue(item, item.layer.itemOffersField)?.map(o => {
|
||||
item?.layer?.itemOffersField && getValue(item, item.layer.itemOffersField)?.map(o => {
|
||||
const tag = tags.find(t => t.id === o.tags_id);
|
||||
tag && setOffers(current => [...current, tag])
|
||||
})
|
||||
item.layer?.itemNeedsField && getValue(item, item.layer.itemNeedsField)?.map(n => {
|
||||
item?.layer?.itemNeedsField && getValue(item, item.layer.itemNeedsField)?.map(n => {
|
||||
const tag = tags.find(t => t.id === n.tags_id);
|
||||
tag && setNeeds(current => [...current, tag])
|
||||
})
|
||||
item.relations?.map(r => {
|
||||
item?.relations?.map(r => {
|
||||
const item = items.find(i => i.id == r.related_items_id)
|
||||
item && setRelations(current => [...current, item])
|
||||
})
|
||||
@ -116,7 +116,7 @@ export function ProfileView({ userType }: { userType: string }) {
|
||||
}, [selectPosition])
|
||||
|
||||
useEffect(() => {
|
||||
setTemplate(item.layer?.itemType.template || userType);
|
||||
setTemplate(item?.layer?.itemType.template || userType);
|
||||
}, [userType, item])
|
||||
|
||||
const [urlParams, setUrlParams] = useState(new URLSearchParams(location.search));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user