mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
63 lines
3.2 KiB
TypeScript
63 lines
3.2 KiB
TypeScript
import { Dispatch, FC, MouseEvent, SetStateAction, useState } from 'react';
|
|
import dayjs from 'dayjs';
|
|
import { DatePicker } from 'antd';
|
|
import { Icons } from '@/components/Icons';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
|
|
|
type Props = {
|
|
open: boolean
|
|
onOpenChange: Dispatch<SetStateAction<boolean>>
|
|
onClose?: (e: MouseEvent<HTMLButtonElement>) => any
|
|
date: any
|
|
};
|
|
|
|
const NewEvent: FC<Props> = ({ open, onOpenChange, onClose, date }) => {
|
|
const [isLoading, setIsLoading] = useState(false)
|
|
const [isAddTime, setIsAddTime] = useState(false)
|
|
|
|
return (
|
|
<>
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent>
|
|
<DialogHeader className='sr-only'>
|
|
<DialogTitle>Title</DialogTitle>
|
|
<DialogDescription>Description</DialogDescription>
|
|
</DialogHeader>
|
|
<div className='grid grid-cols-8 gap-y-5 my-5 text-sm'>
|
|
<span></span>
|
|
<input className='col-span-7 outline-none bg-transparent border-b border-border focus:border-his focus-visible:ring-offset-2 focus-visible:ring-his ring-offset-his caret-his py-1 text-xl duration-300' placeholder='Add title and time' />
|
|
<i className="ti ti-clock text-xl text-muted-foreground"></i>
|
|
<div className='col-span-7 flex justify-between items-center'>
|
|
<DatePicker defaultValue={dayjs(date)} format='MMMM DD, YYYY'
|
|
size='small' className='input w-48 px-3! z-10' getPopupContainer={(triggerNode: any) => triggerNode.parentNode}
|
|
/>
|
|
{isAddTime ?
|
|
<DatePicker.TimePicker showSecond={false} format='HH:mm'
|
|
size='small' className='input w-max px-3!' getPopupContainer={(triggerNode: any) => triggerNode.parentNode}
|
|
/>
|
|
:
|
|
<Button variant='outline' onClick={() => setIsAddTime(true)}>Add time</Button>
|
|
}
|
|
</div>
|
|
<i className="ti ti-text-caption text-xl text-muted-foreground"></i>
|
|
<textarea className='col-span-7 bg-zinc-100 dark:bg-zinc-900 outline-none p-2 rounded-md caret-his' placeholder='Add description' rows={4} />
|
|
</div>
|
|
<DialogFooter>
|
|
<Button variant='secondary' disabled={isLoading} onClick={onClose} >
|
|
Cancel
|
|
</Button>
|
|
<Button disabled={isLoading} onClick={() => setIsLoading(true)}>
|
|
{isLoading && (
|
|
<Icons.spinner className="mr-1 h-4 w-4 animate-spin" />
|
|
)}
|
|
Save
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default NewEvent; |