mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-31 00:53:37 +00:00
Added Started At Date Field
This commit is contained in:
parent
c6e2a88f1c
commit
514ae94f43
5 changed files with 50 additions and 16 deletions
|
@ -15,7 +15,7 @@ Currently, there is no documentation or wiki available but there will be one add
|
||||||
|
|
||||||
This will be published on the site some time soon but for now, the roadmap will be listed here.
|
This will be published on the site some time soon but for now, the roadmap will be listed here.
|
||||||
|
|
||||||
- [ ] Finish adding started at date feature
|
- [x] Finish adding started at date field
|
||||||
- [x] Pagination for Audit Logs page
|
- [x] Pagination for Audit Logs page
|
||||||
- [ ] Board sorting options (Boards Page)
|
- [ ] Board sorting options (Boards Page)
|
||||||
- [ ] Add real-time collaboration
|
- [ ] Add real-time collaboration
|
||||||
|
|
|
@ -32,6 +32,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
||||||
data: {
|
data: {
|
||||||
...values,
|
...values,
|
||||||
dueDate: dueDate,
|
dueDate: dueDate,
|
||||||
|
startedAt: startedAt,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,21 @@ export const CardItem = ({ index, data }: CardItemProps) => {
|
||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
role='button'
|
role='button'
|
||||||
onClick={() => cardModal.onOpen(data.id)}
|
onClick={() => cardModal.onOpen(data.id)}
|
||||||
className='truncate rounded-md border-2 border-transparent bg-white px-3 py-2 text-sm shadow-sm hover:border-black'
|
className='space-y-2 truncate rounded-md border-2 border-transparent bg-white px-3 py-2 text-sm shadow-sm hover:border-black'
|
||||||
>
|
>
|
||||||
{data.title}
|
{data.title}
|
||||||
<div className='flex w-fit rounded-md border-2 border-transparent bg-slate-100 px-0.5 pb-0.5 pt-0.5 text-sm'>
|
{data?.dueDate && (
|
||||||
<Calendar className='ml-0.5 mr-0.5 h-4 w-4' />
|
<div className='flex w-fit rounded-md border-2 border-transparent bg-slate-100 px-0.5 pb-0.5 pt-0.5 text-sm'>
|
||||||
{data?.dueDate
|
<Calendar className='ml-0.5 mr-0.5 h-4 w-4' />
|
||||||
? 'Due: ' + format(data.dueDate, 'PP')
|
Due: {format(data.dueDate, 'PP')}
|
||||||
: 'No Due Date'}
|
</div>
|
||||||
</div>
|
)}
|
||||||
|
{data?.startedAt && (
|
||||||
|
<div className='flex w-fit rounded-md border-2 border-transparent bg-slate-100 px-0.5 pb-0.5 pt-0.5 text-sm'>
|
||||||
|
<Calendar className='ml-0.5 mr-0.5 h-4 w-4' />
|
||||||
|
Started: {format(data.startedAt, 'PP')}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Draggable>
|
</Draggable>
|
||||||
|
|
|
@ -80,6 +80,7 @@ export const Actions = ({ data }: ActionsProps) => {
|
||||||
Copy
|
Copy
|
||||||
</Button>
|
</Button>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
|
type='dueDate'
|
||||||
variant='gray'
|
variant='gray'
|
||||||
className='w-full justify-start text-black'
|
className='w-full justify-start text-black'
|
||||||
size='inline'
|
size='inline'
|
||||||
|
@ -88,6 +89,16 @@ export const Actions = ({ data }: ActionsProps) => {
|
||||||
boardId={params.boardId as string}
|
boardId={params.boardId as string}
|
||||||
card={data}
|
card={data}
|
||||||
/>
|
/>
|
||||||
|
<DatePicker
|
||||||
|
type='startedAtDate'
|
||||||
|
variant='gray'
|
||||||
|
className='w-full justify-start text-black'
|
||||||
|
size='inline'
|
||||||
|
placeholder='Add Started Date'
|
||||||
|
afterSelectText='Started '
|
||||||
|
boardId={params.boardId as string}
|
||||||
|
card={data}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={onDelete}
|
onClick={onDelete}
|
||||||
disabled={isLoadingDelete}
|
disabled={isLoadingDelete}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { useAction } from '@/hooks/use-action';
|
||||||
import { CardWithList } from '@/types';
|
import { CardWithList } from '@/types';
|
||||||
|
|
||||||
interface DatePickerProps {
|
interface DatePickerProps {
|
||||||
|
type: 'dueDate' | 'startedAtDate';
|
||||||
variant?:
|
variant?:
|
||||||
| 'outline'
|
| 'outline'
|
||||||
| 'default'
|
| 'default'
|
||||||
|
@ -37,6 +38,7 @@ interface DatePickerProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DatePicker({
|
export function DatePicker({
|
||||||
|
type,
|
||||||
variant,
|
variant,
|
||||||
className,
|
className,
|
||||||
size,
|
size,
|
||||||
|
@ -49,7 +51,7 @@ export function DatePicker({
|
||||||
|
|
||||||
const { execute, isLoading } = useAction(updateCard, {
|
const { execute, isLoading } = useAction(updateCard, {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success('Due date updated');
|
toast.success('Date updated');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
|
@ -57,19 +59,33 @@ export function DatePicker({
|
||||||
});
|
});
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (card?.dueDate) {
|
if (card?.dueDate && type === 'dueDate') {
|
||||||
setDate(card.dueDate);
|
setDate(card.dueDate);
|
||||||
}
|
}
|
||||||
}, [card?.dueDate]);
|
|
||||||
|
if (card?.startedAt && type === 'startedAtDate') {
|
||||||
|
setDate(card.startedAt);
|
||||||
|
}
|
||||||
|
}, [card?.startedAt, card?.dueDate, type]);
|
||||||
|
|
||||||
const onBlur = () => {
|
const onBlur = () => {
|
||||||
if (!date || !boardId || !card) return;
|
if (!date || !boardId || !card) return;
|
||||||
|
|
||||||
execute({
|
if (type === 'dueDate') {
|
||||||
id: card.id,
|
execute({
|
||||||
boardId,
|
id: card.id,
|
||||||
dueDate: date,
|
boardId,
|
||||||
});
|
dueDate: date,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'startedAtDate') {
|
||||||
|
execute({
|
||||||
|
id: card.id,
|
||||||
|
boardId,
|
||||||
|
startedAt: date,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setDate(date);
|
setDate(date);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue