fix: settings error message
This commit is contained in:
parent
b5602bead5
commit
2a95836dcb
3 changed files with 29 additions and 17 deletions
|
@ -108,7 +108,9 @@ export default function ShowEvent() {
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
Location
|
Location
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>{eventData.data.event.location || '-'}</Label>
|
<Label size='large'>
|
||||||
|
{eventData.data.event.location || '-'}
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col gap-4'>
|
<div className='flex flex-col gap-4'>
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='flex flex-row gap-2'>
|
||||||
|
@ -116,7 +118,9 @@ export default function ShowEvent() {
|
||||||
created:
|
created:
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label>
|
||||||
{eventData.data.event.created_at ? formatDate(eventData.data.event.created_at) : '-'}
|
{eventData.data.event.created_at
|
||||||
|
? formatDate(eventData.data.event.created_at)
|
||||||
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='flex flex-row gap-2'>
|
||||||
|
@ -124,7 +128,9 @@ export default function ShowEvent() {
|
||||||
updated:
|
updated:
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label>
|
||||||
{eventData.data.event.updated_at ? formatDate(eventData.data.event.updated_at) : '-'}
|
{eventData.data.event.updated_at
|
||||||
|
? formatDate(eventData.data.event.updated_at)
|
||||||
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -136,14 +142,18 @@ export default function ShowEvent() {
|
||||||
<Label className='text-[var(--color-neutral-300)]'>
|
<Label className='text-[var(--color-neutral-300)]'>
|
||||||
Organiser:
|
Organiser:
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>{userData?.data.user?.name || 'Unknown User'}</Label>
|
<Label size='large'>
|
||||||
|
{userData?.data.user?.name || 'Unknown User'}
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full'>
|
<div className='h-full w-full'>
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
Description
|
Description
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>{eventData.data.event.description || '-'}</Label>
|
<Label size='large'>
|
||||||
|
{eventData.data.event.description || '-'}
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full mt-2'>
|
<div className='h-full w-full mt-2'>
|
||||||
|
@ -164,7 +174,8 @@ export default function ShowEvent() {
|
||||||
|
|
||||||
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
||||||
<div className='w-[20%] grid max-sm:w-full'>
|
<div className='w-[20%] grid max-sm:w-full'>
|
||||||
{session.data?.user?.id === eventData.data.event.organizer.id ? (
|
{session.data?.user?.id ===
|
||||||
|
eventData.data.event.organizer.id ? (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={deleteDialogOpen}
|
open={deleteDialogOpen}
|
||||||
onOpenChange={setDeleteDialogOpen}
|
onOpenChange={setDeleteDialogOpen}
|
||||||
|
@ -179,7 +190,8 @@ export default function ShowEvent() {
|
||||||
<DialogTitle>Delete Event</DialogTitle>
|
<DialogTitle>Delete Event</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Are you sure you want to delete the event “
|
Are you sure you want to delete the event “
|
||||||
{eventData.data.event.title}”? This action cannot be undone.
|
{eventData.data.event.title}”? This action
|
||||||
|
cannot be undone.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
|
@ -219,7 +231,8 @@ export default function ShowEvent() {
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className='w-[20%] grid max-sm:w-full'>
|
<div className='w-[20%] grid max-sm:w-full'>
|
||||||
{session.data?.user?.id === eventData.data.event.organizer.id ? (
|
{session.data?.user?.id ===
|
||||||
|
eventData.data.event.organizer.id ? (
|
||||||
<RedirectButton
|
<RedirectButton
|
||||||
redirectUrl={`/events/edit/${eventID}`}
|
redirectUrl={`/events/edit/${eventID}`}
|
||||||
buttonText='edit'
|
buttonText='edit'
|
||||||
|
|
|
@ -58,14 +58,11 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
error,
|
error,
|
||||||
} = usePostApiEvent();
|
} = usePostApiEvent();
|
||||||
const { data, isLoading, error: fetchError } = useGetApiUserMe();
|
const { data, isLoading, error: fetchError } = useGetApiUserMe();
|
||||||
const { data: eventData } = useGetApiEventEventID(
|
const { data: eventData } = useGetApiEventEventID(props.eventId!, {
|
||||||
props.eventId!,
|
query: { enabled: props.type === 'edit' },
|
||||||
{
|
});
|
||||||
query: { enabled: props.type === 'edit' },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const patchEvent = usePatchApiEventEventID();
|
const patchEvent = usePatchApiEventEventID();
|
||||||
const router = useRouter();;
|
const router = useRouter();
|
||||||
|
|
||||||
// State for date and time fields
|
// State for date and time fields
|
||||||
const [startDate, setStartDate] = React.useState<Date | undefined>(undefined);
|
const [startDate, setStartDate] = React.useState<Date | undefined>(undefined);
|
||||||
|
@ -102,7 +99,9 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
}
|
}
|
||||||
setLocation(eventData?.data?.event.location || '');
|
setLocation(eventData?.data?.event.location || '');
|
||||||
setDescription(eventData?.data?.event.description || '');
|
setDescription(eventData?.data?.event.description || '');
|
||||||
setSelectedParticipants(eventData?.data?.event.participants?.map((u) => u.user) || []);
|
setSelectedParticipants(
|
||||||
|
eventData?.data?.event.participants?.map((u) => u.user) || [],
|
||||||
|
);
|
||||||
} else if (props.type === 'create' && startFromUrl && endFromUrl) {
|
} else if (props.type === 'create' && startFromUrl && endFromUrl) {
|
||||||
// If creating a new event with URL params, set title and dates
|
// If creating a new event with URL params, set title and dates
|
||||||
setTitle('');
|
setTitle('');
|
||||||
|
|
|
@ -98,7 +98,7 @@ export default function AccountTab() {
|
||||||
toast.custom((t) => (
|
toast.custom((t) => (
|
||||||
<ToastInner
|
<ToastInner
|
||||||
toastId={t}
|
toastId={t}
|
||||||
title='Settings saved'
|
title='Error saving settings'
|
||||||
description={
|
description={
|
||||||
error.response?.data.message || 'An unknown error occurred.'
|
error.response?.data.message || 'An unknown error occurred.'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue