feat: create edit Event Page and add closeOnAction prop for Toaster
This commit is contained in:
parent
a469948da5
commit
c0ff8e87bb
4 changed files with 40 additions and 6 deletions
|
@ -128,9 +128,9 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
location: data.location,
|
||||
},
|
||||
});
|
||||
console.log('Updating event with data:', data);
|
||||
console.log('Updating event');
|
||||
} else {
|
||||
console.log('Creating event with data:', data);
|
||||
console.log('Creating event');
|
||||
createEvent({ data });
|
||||
}
|
||||
|
||||
|
@ -279,11 +279,13 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
<Button
|
||||
type='button'
|
||||
variant='secondary'
|
||||
onClick={() => router.back()}
|
||||
onClick={() => {
|
||||
router.back();
|
||||
console.log('user aborted - no change in database');
|
||||
}}
|
||||
>
|
||||
cancel
|
||||
</Button>
|
||||
{/* TODO: add onClick handler to cancel cancel */}
|
||||
</div>
|
||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||
<Button
|
||||
|
|
|
@ -60,6 +60,7 @@ interface ToastInnerProps {
|
|||
| 'warning'
|
||||
| 'notification';
|
||||
iconName?: keyof typeof Icons;
|
||||
closeOnAction?: boolean;
|
||||
}
|
||||
|
||||
const variantConfig = {
|
||||
|
@ -97,6 +98,7 @@ export const ToastInner: React.FC<ToastInnerProps> = ({
|
|||
toastId,
|
||||
variant = 'default',
|
||||
iconName,
|
||||
closeOnAction = true,
|
||||
}) => {
|
||||
const bgColor = variantConfig[variant].bgColor;
|
||||
|
||||
|
@ -134,7 +136,12 @@ export const ToastInner: React.FC<ToastInnerProps> = ({
|
|||
<Button
|
||||
variant={'secondary'}
|
||||
className='w-100px w-full mr-2'
|
||||
onClick={onAction}
|
||||
onClick={() => {
|
||||
onAction();
|
||||
if (closeOnAction) {
|
||||
toast.dismiss(toastId);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{buttonText}
|
||||
</Button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue