Skip to content

Commit af36953

Browse files
authored
Merge pull request #164 from Zindiks/claude/fix-card-details-click-01MVuq5CPEZrEf75DvYQdeM7
Fix card details click functionality
2 parents 44a9085 + 7b2615c commit af36953

File tree

5 files changed

+82
-22
lines changed

5 files changed

+82
-22
lines changed

api/src/modules/cards/card.controller.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
UpdateCardOrderArray,
55
UpdateCardTitle,
66
UpdateCardDetails,
7+
UpdateCardDetailsById,
78
DeleteCard,
89
} from "./card.schema";
910
import { CardService } from "./card.service";
@@ -170,6 +171,24 @@ export class CardController {
170171
}
171172
}
172173

174+
public async updateCardDetailsByIdController(
175+
request: FastifyRequest<{
176+
Params: { id: string };
177+
Body: UpdateCardDetailsById;
178+
}>,
179+
reply: FastifyReply,
180+
) {
181+
const { id } = request.params;
182+
const body = request.body;
183+
184+
try {
185+
const card = await this.cardService.updateDetails({ id, ...body });
186+
return reply.status(200).send(card);
187+
} catch (err) {
188+
return reply.status(500).send(err);
189+
}
190+
}
191+
173192
public async updateCardOrderController(
174193
request: FastifyRequest<{
175194
Body: UpdateCardOrderArray;

api/src/modules/cards/card.route.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ export default async function cardRoutes(fastify: FastifyInstance) {
5858
cardController.getCardWithDetailsController.bind(cardController),
5959
);
6060

61+
fastify.patch(
62+
"/:id/details",
63+
{
64+
schema: {
65+
params: { type: "object", properties: { id: { type: "string" } } },
66+
body: CardSchema.UpdateCardDetailsByIdSchema,
67+
response: {
68+
200: CardSchema.FullCardResponseSchema,
69+
},
70+
tags: ["card"],
71+
description: "Update card details by ID (title, description, status, due_date, priority)",
72+
},
73+
},
74+
cardController.updateCardDetailsByIdController.bind(cardController),
75+
);
76+
6177
fastify.get(
6278
"/list/:list_id",
6379
{

api/src/modules/cards/card.schema.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,29 @@ export class CardSchema {
9090
{ $id: "UpdateCardDetailsSchema" },
9191
);
9292

93+
static UpdateCardDetailsByIdSchema = Type.Object(
94+
{
95+
list_id,
96+
title: Type.Optional(title),
97+
description: Type.Optional(
98+
Type.Union([Type.String({ minLength: 3, maxLength: 255 }), Type.Null()]),
99+
),
100+
status: Type.Optional(Type.String()),
101+
due_date: Type.Optional(
102+
Type.Union([Type.String({ format: "date-time" }), Type.Null()]),
103+
),
104+
priority: Type.Optional(
105+
Type.Union([
106+
Type.Literal("low"),
107+
Type.Literal("medium"),
108+
Type.Literal("high"),
109+
Type.Literal("critical"),
110+
]),
111+
),
112+
},
113+
{ $id: "UpdateCardDetailsByIdSchema" },
114+
);
115+
93116
//RESPONSE SCHEMA
94117
static FullCardResponseSchema = Type.Object(
95118
{
@@ -255,6 +278,7 @@ export class CardSchema {
255278
export type CreateCard = Static<typeof CardSchema.CreateCardSchema>;
256279
export type UpdateCardTitle = Static<typeof CardSchema.UpdateCardTitleSchema>;
257280
export type UpdateCardDetails = Static<typeof CardSchema.UpdateCardDetailsSchema>;
281+
export type UpdateCardDetailsById = Static<typeof CardSchema.UpdateCardDetailsByIdSchema>;
258282
export type UpdateCardOrder = Static<typeof CardSchema.UpdateCardOrderSchema>;
259283
export type UpdateCardOrderArray = Static<
260284
typeof CardSchema.UpdateCardOrderSchemaArray

client/src/components/card/CardDetailsPanel.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useEffect, useRef } from "react";
22
import type { CardWithDetails } from "@/types/types";
33
import {
4-
Sheet,
5-
SheetContent,
6-
SheetHeader,
7-
} from "@/components/ui/sheet";
4+
Dialog,
5+
DialogContent,
6+
DialogHeader,
7+
} from "@/components/ui/dialog";
88
import { Separator } from "@/components/ui/separator";
99
import { Skeleton } from "@/components/ui/skeleton";
1010
import { useCardDetails } from "@/hooks/useCardDetails";
@@ -105,28 +105,28 @@ export const CardDetailsPanel = ({
105105

106106
// Handler functions
107107
const handleUpdateTitle = (title: string) => {
108-
if (!cardId) return;
109-
updateDetails.mutate({ id: cardId, title });
108+
if (!cardId || !cardDetails) return;
109+
updateDetails.mutate({ id: cardId, list_id: cardDetails.list_id, title });
110110
};
111111

112112
const handleUpdateDescription = (description: string) => {
113-
if (!cardId) return;
114-
updateDetails.mutate({ id: cardId, description });
113+
if (!cardId || !cardDetails) return;
114+
updateDetails.mutate({ id: cardId, list_id: cardDetails.list_id, description });
115115
};
116116

117117
const handleUpdatePriority = (priority: "low" | "medium" | "high" | "critical" | undefined) => {
118-
if (!cardId) return;
119-
updateDetails.mutate({ id: cardId, priority });
118+
if (!cardId || !cardDetails) return;
119+
updateDetails.mutate({ id: cardId, list_id: cardDetails.list_id, priority });
120120
};
121121

122122
const handleUpdateStatus = (status: string) => {
123-
if (!cardId) return;
124-
updateDetails.mutate({ id: cardId, status });
123+
if (!cardId || !cardDetails) return;
124+
updateDetails.mutate({ id: cardId, list_id: cardDetails.list_id, status });
125125
};
126126

127127
const handleUpdateDueDate = (due_date: string | undefined) => {
128-
if (!cardId) return;
129-
updateDetails.mutate({ id: cardId, due_date });
128+
if (!cardId || !cardDetails) return;
129+
updateDetails.mutate({ id: cardId, list_id: cardDetails.list_id, due_date });
130130
};
131131

132132
const handleDeleteCard = () => {
@@ -142,8 +142,8 @@ export const CardDetailsPanel = ({
142142
};
143143

144144
return (
145-
<Sheet open={isOpen} onOpenChange={onClose}>
146-
<SheetContent size="wide" className="overflow-y-auto p-0">
145+
<Dialog open={isOpen} onOpenChange={onClose}>
146+
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto p-0">
147147
{isLoading && (
148148
<div className="p-6 space-y-4">
149149
<Skeleton className="h-8 w-3/4" />
@@ -153,9 +153,9 @@ export const CardDetailsPanel = ({
153153
)}
154154

155155
{!isLoading && cardDetails && (
156-
<div className="flex flex-col h-full">
156+
<div className="flex flex-col">
157157
{/* Header */}
158-
<SheetHeader className="p-6 pb-4">
158+
<DialogHeader className="p-6 pb-4">
159159
<div className="flex items-start justify-between pr-8" ref={titleRef}>
160160
<EditableTitle
161161
value={cardDetails.title}
@@ -171,10 +171,10 @@ export const CardDetailsPanel = ({
171171
<div className="flex items-center gap-2 text-sm text-muted-foreground">
172172
in list <span className="font-medium">List Name</span>
173173
</div>
174-
</SheetHeader>
174+
</DialogHeader>
175175

176176
{/* Main Content */}
177-
<div className="flex-1 px-6 pb-6 space-y-6">
177+
<div className="px-6 pb-6 space-y-6">
178178
{/* Metadata Section */}
179179
<div className="flex flex-wrap gap-3">
180180
<PrioritySelector
@@ -250,10 +250,10 @@ export const CardDetailsPanel = ({
250250
<p>Card not found</p>
251251
</div>
252252
)}
253-
</SheetContent>
253+
</DialogContent>
254254

255255
{/* Keyboard Shortcuts Dialog */}
256256
<KeyboardShortcutsDialog open={showDialog} onOpenChange={setShowDialog} />
257-
</Sheet>
257+
</Dialog>
258258
);
259259
};

client/src/hooks/useCardDetails.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const API_URL = `${API_HOST}:${API_PORT}${API_VERSION}`;
1111

1212
export interface UpdateCardDetailsParams {
1313
id: string;
14+
list_id: string;
1415
title?: string;
1516
description?: string;
1617
status?: string;

0 commit comments

Comments
 (0)