rainbow vomit
This commit is contained in:
parent
cabb8a9b27
commit
f857ae3e2d
@ -46,7 +46,7 @@ export default function CardGroup(props: TCardGroup) {
|
|||||||
data.map((task, i) => (
|
data.map((task, i) => (
|
||||||
<TaskCard
|
<TaskCard
|
||||||
key={task.id}
|
key={task.id}
|
||||||
id={task.id.toString() + props.id}
|
id={task.id.toString()}
|
||||||
title={task.title}
|
title={task.title}
|
||||||
description={task.status}
|
description={task.status}
|
||||||
index={i}
|
index={i}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ export default function MainBoard() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DragDropContext onDragEnd={dragEndHandle}>
|
<DragDropContext onDragEnd={dragEndHandle}>
|
||||||
<ScrollArea scrollbars='horizontal'>
|
<ScrollArea scrollbars='horizontal' className='pb-3'>
|
||||||
<Flex gap={'2'} className='min-w-fit'>
|
<Flex gap={'2'} className='min-w-fit'>
|
||||||
{!isLoading &&
|
{!isLoading &&
|
||||||
(cringe as any[]).map((item: any) => (
|
(cringe as any[]).map((item: any) => (
|
||||||
@ -44,7 +44,6 @@ export default function MainBoard() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</DragDropContext>
|
</DragDropContext>
|
||||||
<Button onClick={onClick}>Create task</Button>
|
|
||||||
<Button onClick={onClick1}>Create project</Button>
|
<Button onClick={onClick1}>Create project</Button>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,26 +1,65 @@
|
|||||||
import { Draggable } from '@hello-pangea/dnd';
|
import { Draggable } from '@hello-pangea/dnd';
|
||||||
import { Button, Card, Flex, Text } from '@radix-ui/themes';
|
import { Badge, Button, Card, Flex, Text } from '@radix-ui/themes';
|
||||||
|
import { useUpdateTaskMutation } from '../../services/mainApi';
|
||||||
|
|
||||||
type TTaskCard = {
|
type TTaskCard = {
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
index?: number;
|
index?: number;
|
||||||
status: "todo" | "in-progress" | "completed";
|
status: 'todo' | 'in-progress' | 'completed';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const badgeNames = {
|
||||||
|
todo: 'To do',
|
||||||
|
'in-progress': 'In progress',
|
||||||
|
completed: 'Completed',
|
||||||
|
} as const
|
||||||
|
|
||||||
|
const badgeColors = {
|
||||||
|
todo: 'blue',
|
||||||
|
'in-progress': 'orange',
|
||||||
|
completed: 'green',
|
||||||
|
} as const
|
||||||
|
|
||||||
export default function TaskCard(props: TTaskCard) {
|
export default function TaskCard(props: TTaskCard) {
|
||||||
|
const [updateTask] = useUpdateTaskMutation();
|
||||||
|
|
||||||
|
const updateStatus = (newStatus: 'todo' | 'in-progress' | 'completed') => {
|
||||||
|
updateTask({ id: props.id, status: newStatus });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Draggable draggableId={props.id || '123'} index={props.index || 0}>
|
<Draggable draggableId={props.id || '123'} index={props.index || 0}>
|
||||||
{(provided) => (
|
{(provided) => (
|
||||||
<Card
|
<Card
|
||||||
className="!w-62"
|
className="!w-62 !flex flex-col gap-2"
|
||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
{...provided.draggableProps}
|
{...provided.draggableProps}
|
||||||
>
|
>
|
||||||
<Flex direction="column" gap="2">
|
<Flex direction="column" gap="2">
|
||||||
<Text wrap="pretty">{props.title}</Text>
|
<Flex justify={'between'}>
|
||||||
<Button>Mark completed</Button>
|
<Text wrap="pretty">{props.title}</Text>
|
||||||
|
<Badge color={badgeColors[props.status] || 'gray'}>{badgeNames[props.status]}</Badge>
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex justify={'between'}>
|
||||||
|
{props.status !== 'todo' && (
|
||||||
|
<Button color={badgeColors['todo']} onClick={() => updateStatus('todo')}>
|
||||||
|
Todo
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{props.status !== 'in-progress' && (
|
||||||
|
<Button color={badgeColors['in-progress']} onClick={() => updateStatus('in-progress')}>
|
||||||
|
In Progress
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{props.status !== 'completed' && (
|
||||||
|
<Button color={badgeColors['completed']} onClick={() => updateStatus('completed')}>
|
||||||
|
Completed
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ export const mainApi = createApi({
|
|||||||
query: (task) => ({
|
query: (task) => ({
|
||||||
url: `tasks/${task.id}`,
|
url: `tasks/${task.id}`,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
body: task,
|
body: {status: task.status},
|
||||||
}),
|
}),
|
||||||
invalidatesTags: (result, error, id) => [{ type: 'Task', id }],
|
invalidatesTags: (result, error, id) => [{ type: 'Task', id }],
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user