mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
added contact, start and end to tabs form
This commit is contained in:
parent
c9633e5dce
commit
b42e310d69
@ -2,11 +2,18 @@ import * as React from 'react'
|
|||||||
import { TextInput } from '../../../Input'
|
import { TextInput } from '../../../Input'
|
||||||
import { Item } from '../../../../types'
|
import { Item } from '../../../../types'
|
||||||
|
|
||||||
export const PopupStartEndInput = ({item}:{item?:Item}) => {
|
type StartEndInputProps = {
|
||||||
|
item?:Item,
|
||||||
|
showLabels?: boolean
|
||||||
|
updateStartValue?: (value: string ) => void;
|
||||||
|
updateEndValue?: (value: string ) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PopupStartEndInput = ({item, showLabels = true, updateStartValue, updateEndValue}:StartEndInputProps) => {
|
||||||
return (
|
return (
|
||||||
<div className='tw-grid tw-grid-cols-2 tw-gap-2 tw-mb-5'>
|
<div className='tw-grid tw-grid-cols-2 tw-gap-2 tw-mb-5'>
|
||||||
<TextInput type='date' placeholder='start' dataField='start' inputStyle='tw-text-sm tw-px-2' labelTitle='start' defaultValue={item && item.start? item.start.substring(0, 10) : ""} autocomplete='one-time-code'></TextInput>
|
<TextInput type='date' placeholder='start' dataField='start' inputStyle='tw-text-sm tw-px-2' labelTitle={showLabels ? "start" :""} defaultValue={item && item.start? item.start.substring(0, 10) : ""} autocomplete='one-time-code' updateFormValue={updateStartValue}></TextInput>
|
||||||
<TextInput type='date' placeholder='end' dataField='end' inputStyle='tw-text-sm tw-px-2' labelTitle='end' defaultValue={item && item.end ? item.end.substring(0, 10) : ""} autocomplete='one-time-code'></TextInput>
|
<TextInput type='date' placeholder='end' dataField='end' inputStyle='tw-text-sm tw-px-2' labelTitle={showLabels ? "end" :""} defaultValue={item && item.end ? item.end.substring(0, 10) : ""} autocomplete='one-time-code' updateFormValue={updateEndValue}></TextInput>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,9 @@ export function ProfileForm({ userType }: { userType: string }) {
|
|||||||
markerIcon: "",
|
markerIcon: "",
|
||||||
offers: [] as Tag[],
|
offers: [] as Tag[],
|
||||||
needs: [] as Tag[],
|
needs: [] as Tag[],
|
||||||
relations: [] as Item[]
|
relations: [] as Item[],
|
||||||
|
start: "",
|
||||||
|
end: ""
|
||||||
});
|
});
|
||||||
|
|
||||||
const [updatePermission, setUpdatePermission] = useState<boolean>(false);
|
const [updatePermission, setUpdatePermission] = useState<boolean>(false);
|
||||||
@ -105,7 +107,9 @@ export function ProfileForm({ userType }: { userType: string }) {
|
|||||||
markerIcon: item?.marker_icon ?? "",
|
markerIcon: item?.marker_icon ?? "",
|
||||||
offers: offers,
|
offers: offers,
|
||||||
needs: needs,
|
needs: needs,
|
||||||
relations: relations
|
relations: relations,
|
||||||
|
start: item?.start ?? "",
|
||||||
|
end: item?.end ?? ""
|
||||||
});
|
});
|
||||||
}, [item, tags, items]);
|
}, [item, tags, items]);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import { TextAreaInput } from "../../Input"
|
import { TextAreaInput, TextInput } from "../../Input"
|
||||||
import { TextView } from "../../Map"
|
import { PopupStartEndInput, TextView } from "../../Map"
|
||||||
import { ActionButton } from "../Subcomponents/ActionsButton"
|
import { ActionButton } from "../Subcomponents/ActionsButton"
|
||||||
import { LinkedItemsHeaderView } from "../Subcomponents/LinkedItemsHeaderView"
|
import { LinkedItemsHeaderView } from "../Subcomponents/LinkedItemsHeaderView"
|
||||||
import { TagsWidget } from "../Subcomponents/TagsWidget"
|
import { TagsWidget } from "../Subcomponents/TagsWidget"
|
||||||
@ -20,7 +20,7 @@ export const TabsForm = ({ item, state, setState, updatePermission, linkItem, un
|
|||||||
let urlTab = params.get("tab");
|
let urlTab = params.get("tab");
|
||||||
if (!urlTab?.includes(id.toString()))
|
if (!urlTab?.includes(id.toString()))
|
||||||
params.set("tab", `${id ? id : ""}`)
|
params.set("tab", `${id ? id : ""}`)
|
||||||
navigate(location.pathname+ "?" + params.toString());
|
navigate(location.pathname + "?" + params.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -30,13 +30,41 @@ export const TabsForm = ({ item, state, setState, updatePermission, linkItem, un
|
|||||||
}, [location])
|
}, [location])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div role="tablist" className="tw-tabs tw-tabs-lifted tw-mt-4">
|
<div role="tablist" className="tw-tabs tw-tabs-lifted tw-mt-3">
|
||||||
<input type="radio" name="my_tabs_2" role="tab" className={`tw-tab [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]`} aria-label="Info" checked={activeTab == 1 && true} onChange={() => updateActiveTab(1)} />
|
<input type="radio" name="my_tabs_2" role="tab" className={`tw-tab [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]`} aria-label="Info" checked={activeTab == 1 && true} onChange={() => updateActiveTab(1)} />
|
||||||
<div role="tabpanel" className="tw-tab-content tw-bg-base-100 tw-border-[var(--fallback-bc,oklch(var(--bc)/0.2))] tw-rounded-box tw-h-[calc(100dvh-332px)] tw-min-h-56 tw-border-none">
|
<div role="tabpanel" className="tw-tab-content tw-bg-base-100 tw-border-[var(--fallback-bc,oklch(var(--bc)/0.2))] tw-rounded-box tw-h-[calc(100dvh-332px)] tw-min-h-56 tw-border-none">
|
||||||
<TextAreaInput placeholder="About me ..." defaultValue={item?.text ? item.text : ""} updateFormValue={(v) => setState(prevState => ({
|
<div className="tw-flex tw-flex-col tw-h-full tw-pt-4">
|
||||||
|
{item.layer.itemType.show_start_end_input &&
|
||||||
|
<PopupStartEndInput
|
||||||
|
item={item}
|
||||||
|
showLabels={false}
|
||||||
|
updateEndValue={(e) => setState(prevState => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
text: v
|
end: e
|
||||||
}))} containerStyle='tw-h-full' inputStyle='tw-h-full tw-border-t-0 tw-rounded-tl-none' />
|
}))}
|
||||||
|
updateStartValue={(s) => setState(prevState => ({
|
||||||
|
...prevState,
|
||||||
|
start: s
|
||||||
|
}))}></PopupStartEndInput>
|
||||||
|
}
|
||||||
|
|
||||||
|
<TextAreaInput placeholder="About ..." defaultValue={item?.text ? item.text : ""} updateFormValue={(v) => setState(prevState => ({
|
||||||
|
...prevState,
|
||||||
|
text: v
|
||||||
|
}))} containerStyle='tw-grow' inputStyle={`tw-h-full ${!item.layer.itemType.show_start_end_input && "tw-border-t-0 tw-rounded-tl-none"}`} />
|
||||||
|
<div>
|
||||||
|
<TextAreaInput
|
||||||
|
placeholder="contact info"
|
||||||
|
defaultValue={state.contact || ""}
|
||||||
|
updateFormValue={(c) => setState(prevState => ({
|
||||||
|
...prevState,
|
||||||
|
contact: c
|
||||||
|
}))}
|
||||||
|
inputStyle="tw-h-24"
|
||||||
|
containerStyle="tw-pt-4"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{item.layer?.itemType.offers_and_needs &&
|
{item.layer?.itemType.offers_and_needs &&
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -48,11 +48,13 @@ export const TabsView = ({ item, offers, needs, relations, updatePermission, loa
|
|||||||
aria-label="Info" checked={activeTab == 1 && true}
|
aria-label="Info" checked={activeTab == 1 && true}
|
||||||
onChange={() => updateActiveTab(1)} />
|
onChange={() => updateActiveTab(1)} />
|
||||||
<div role="tabpanel"
|
<div role="tabpanel"
|
||||||
className="tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-280px)] tw-overflow-y-auto fade tw-pt-2 tw-pb-4 tw-mb-4 tw-overflow-x-hidden">
|
className="tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-280px)] tw-overflow-y-auto fade tw-pt-2 tw-pb-4 tw-mb-4 tw-overflow-x-hidden tw-flex tw-flex-col">
|
||||||
{item.layer?.itemType.show_start_end &&
|
{item.layer?.itemType.show_start_end &&
|
||||||
<div className='tw-max-w-xs'><StartEndView item={item}></StartEndView></div>
|
<div className='tw-max-w-xs'><StartEndView item={item}></StartEndView></div>
|
||||||
}
|
}
|
||||||
<TextView item={item} />
|
<TextView item={item} />
|
||||||
|
<div className='tw-h-4'></div>
|
||||||
|
<TextView item={item} itemTextField='contact'/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{item.layer?.itemType.offers_and_needs &&
|
{item.layer?.itemType.offers_and_needs &&
|
||||||
|
|||||||
@ -119,23 +119,24 @@ export const onUpdateItem = async (state, item, tags, addTag, setLoading, naviga
|
|||||||
existingNeed && needs_updates.push(existingNeed.id)
|
existingNeed && needs_updates.push(existingNeed.id)
|
||||||
!existingNeed && needs_updates.push({ items_id: item?.id, tags_id: n.id })
|
!existingNeed && needs_updates.push({ items_id: item?.id, tags_id: n.id })
|
||||||
!existingNeed && !tags.some(t => t.id === n.id) && addTag({ ...n, offer_or_need: true })
|
!existingNeed && !tags.some(t => t.id === n.id) && addTag({ ...n, offer_or_need: true })
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// update profile item in current state
|
// update profile item in current state
|
||||||
changedItem = {
|
changedItem = {
|
||||||
id: state.id,
|
id: state.id,
|
||||||
group_type: state.groupType,
|
|
||||||
status: state.status,
|
|
||||||
name: state.name,
|
name: state.name,
|
||||||
subname: state.subname,
|
...state.subname && {subname: state.subname},
|
||||||
text: state.text,
|
...state.text && {text: state.text},
|
||||||
color: state.color,
|
...state.color && {color: state.color},
|
||||||
position: item.position,
|
position: item.position,
|
||||||
contact: state.contact,
|
...state.groupType && {group_type: state.groupType},
|
||||||
telephone: state.telephone,
|
...state.status && {status: state.status},
|
||||||
|
...state.contact && {contact: state.contact},
|
||||||
|
...state.telephone && {telephone: state.telephone},
|
||||||
|
...state.end && {end: state.end},
|
||||||
|
...state.start && {start: state.start},
|
||||||
...state.markerIcon && { markerIcon: state.markerIcon },
|
...state.markerIcon && { markerIcon: state.markerIcon },
|
||||||
next_appointment: state.nextAppointment,
|
...state.nextAppointment && {next_appointment: state.nextAppointment},
|
||||||
...state.image.length > 10 && { image: state.image },
|
...state.image.length > 10 && { image: state.image },
|
||||||
...state.offers.length > 0 && { offers: offer_updates },
|
...state.offers.length > 0 && { offers: offer_updates },
|
||||||
...state.needs.length > 0 && { needs: needs_updates }
|
...state.needs.length > 0 && { needs: needs_updates }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user