Skip to content

Commit a536f36

Browse files
authored
Merge pull request #96 from refactor-group/update_coaching_sessions
Update coaching sessions
2 parents a403446 + 7c6ada9 commit a536f36

14 files changed

+472
-610
lines changed

src/app/dashboard/page.tsx

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,11 @@
11
import type { Metadata } from "next";
2-
import type * as React from "react";
3-
import { cn } from "@/components/lib/utils";
4-
import SelectCoachingRelationship from "@/components/ui/dashboard/select-coaching-relationship";
5-
import CoachingSessionList from "@/components/ui/dashboard/coaching-session-list";
6-
import AddEntities from "@/components/ui/dashboard/add-entities";
2+
import { DashboardContainer } from "../../components/ui/dashboard/dashboard-container";
73

84
export const metadata: Metadata = {
95
title: "Dashboard",
106
description: "Coaching dashboard",
117
};
128

13-
function DashboardContainer({
14-
className,
15-
...props
16-
}: React.HTMLAttributes<HTMLDivElement>) {
17-
return (
18-
<div
19-
className={cn(
20-
// Base styles
21-
"p-4",
22-
// Mobile: stack vertically
23-
"flex flex-col gap-6",
24-
// Tablet and up (640px+): side by side
25-
"sm:grid sm:grid-cols-2",
26-
// Never grow wider than the site-header
27-
"max-w-screen-2xl",
28-
// Ensure full width for children
29-
"[&>*]:w-full",
30-
className
31-
)}
32-
{...props}
33-
/>
34-
);
35-
}
36-
379
export default function DashboardPage() {
38-
return (
39-
<>
40-
<div className="p-4 max-w-screen-2xl">
41-
<div className="mb-8 w-full">
42-
<AddEntities />
43-
</div>
44-
</div>
45-
<DashboardContainer>
46-
<SelectCoachingRelationship />
47-
<CoachingSessionList />
48-
</DashboardContainer>
49-
</>
50-
);
10+
return <DashboardContainer />;
5111
}

src/components/ui/coaching-relationship-selector.tsx

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import { useEffect } from "react";
1414
import { useAuthStore } from "@/lib/providers/auth-store-provider";
1515
import { useCoachingRelationshipStateStore } from "@/lib/providers/coaching-relationship-state-store-provider";
1616
import { useCoachingSessionStateStore } from "@/lib/providers/coaching-session-state-store-provider";
17+
import { cn } from "../lib/utils";
1718

1819
interface CoachingRelationshipsSelectorProps extends PopoverProps {
20+
className?: string;
1921
/// The Organization's Id for which to get a list of associated CoachingRelationships
2022
organizationId: Id;
2123
/// Disable the component from interaction with the user
@@ -38,18 +40,13 @@ function CoachingRelationshipsSelectItems({
3840
// Be sure to cache the list of current coaching relationships in the CoachingRelationshipStateStore
3941
useEffect(() => {
4042
if (!relationships.length) return;
41-
console.debug(
42-
`relationships (useEffect): ${JSON.stringify(relationships)}`
43-
);
4443
setCurrentCoachingRelationships(relationships);
4544
}, [relationships, setCurrentCoachingRelationships]);
4645

4746
if (isLoading) return <div>Loading...</div>;
4847
if (isError) return <div>Error loading coaching relationships</div>;
4948
if (!relationships?.length) return <div>No coaching relationships found</div>;
5049

51-
console.debug(`relationships: ${JSON.stringify(relationships)}`);
52-
5350
return (
5451
<>
5552
{relationships.map((rel) => (
@@ -63,6 +60,7 @@ function CoachingRelationshipsSelectItems({
6360
}
6461

6562
export default function CoachingRelationshipSelector({
63+
className,
6664
organizationId,
6765
disabled,
6866
onSelect,
@@ -101,29 +99,32 @@ export default function CoachingRelationshipSelector({
10199
? getCurrentCoachingRelationship(currentCoachingRelationshipId)
102100
: null;
103101

104-
const displayValue = currentRelationship ? (
105-
<>
106-
{currentRelationship.coach_first_name}{" "}
107-
{currentRelationship.coach_last_name} -&gt;{" "}
108-
{currentRelationship.coachee_first_name}{" "}
109-
{currentRelationship.coachee_last_name}
110-
</>
111-
) : undefined;
102+
const displayValue =
103+
currentRelationship && currentRelationship.id ? (
104+
<>
105+
{currentRelationship.coach_first_name}{" "}
106+
{currentRelationship.coach_last_name} -&gt;{" "}
107+
{currentRelationship.coachee_first_name}{" "}
108+
{currentRelationship.coachee_last_name}
109+
</>
110+
) : undefined;
112111

113112
return (
114-
<Select
115-
disabled={disabled}
116-
value={currentCoachingRelationshipId ?? undefined}
117-
onValueChange={handleSetCoachingRelationship}
118-
>
119-
<SelectTrigger id="coaching-relationship-selector">
120-
<SelectValue placeholder="Select coaching relationship">
121-
{displayValue}
122-
</SelectValue>
123-
</SelectTrigger>
124-
<SelectContent>
125-
<CoachingRelationshipsSelectItems organizationId={organizationId} />
126-
</SelectContent>
127-
</Select>
113+
<div className={cn("font-normal", className)}>
114+
<Select
115+
disabled={disabled}
116+
value={currentCoachingRelationshipId ?? undefined}
117+
onValueChange={handleSetCoachingRelationship}
118+
>
119+
<SelectTrigger id="coaching-relationship-selector">
120+
<SelectValue placeholder="Select coaching relationship">
121+
{displayValue}
122+
</SelectValue>
123+
</SelectTrigger>
124+
<SelectContent>
125+
<CoachingRelationshipsSelectItems organizationId={organizationId} />
126+
</SelectContent>
127+
</Select>
128+
</div>
128129
);
129130
}

src/components/ui/coaching-session.tsx

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,31 @@ import Link from "next/link";
88
import { useCoachingSessionStateStore } from "@/lib/providers/coaching-session-state-store-provider";
99
import { useOverarchingGoalBySession } from "@/lib/api/overarching-goals";
1010
import { Id } from "@/types/general";
11+
import {
12+
DropdownMenu,
13+
DropdownMenuContent,
14+
DropdownMenuItem,
15+
DropdownMenuTrigger,
16+
} from "@/components/ui/dropdown-menu";
17+
import { MoreHorizontal } from "lucide-react";
18+
import { CoachingSession as CoachingSessionType } from "@/types/coaching-session";
19+
import { useAuthStore } from "@/lib/providers/auth-store-provider";
1120

1221
interface CoachingSessionProps {
13-
coachingSession: {
14-
id: Id;
15-
date: string;
16-
};
22+
coachingSession: CoachingSessionType;
23+
onUpdate: () => void;
24+
onDelete: () => void;
1725
}
1826

1927
const CoachingSession: React.FC<CoachingSessionProps> = ({
2028
coachingSession,
29+
onUpdate,
30+
onDelete,
2131
}) => {
2232
const { setCurrentCoachingSessionId } = useCoachingSessionStateStore(
2333
(state) => state
2434
);
35+
const { isCoach } = useAuthStore((state) => state);
2536

2637
return (
2738
<Card>
@@ -33,15 +44,34 @@ const CoachingSession: React.FC<CoachingSessionProps> = ({
3344
{format(new Date(coachingSession.date), "MMMM d, yyyy h:mm a")}
3445
</div>
3546
</div>
36-
<Link href={`/coaching-sessions/${coachingSession.id}`} passHref>
37-
<Button
38-
size="sm"
39-
className="w-full sm:w-auto mt-2 sm:mt-0"
40-
onClick={() => setCurrentCoachingSessionId(coachingSession.id)}
41-
>
42-
Join Session
43-
</Button>
44-
</Link>
47+
<div className="flex items-center gap-2">
48+
<Link href={`/coaching-sessions/${coachingSession.id}`} passHref>
49+
<Button
50+
size="sm"
51+
className="w-full sm:w-auto mt-2 sm:mt-0 text-sm px-3 py-1"
52+
onClick={() => setCurrentCoachingSessionId(coachingSession.id)}
53+
>
54+
Join Session
55+
</Button>
56+
</Link>
57+
<DropdownMenu>
58+
<DropdownMenuTrigger asChild>
59+
<Button variant="ghost" size="icon">
60+
<MoreHorizontal className="h-4 w-4" />
61+
</Button>
62+
</DropdownMenuTrigger>
63+
<DropdownMenuContent align="end">
64+
<DropdownMenuItem onClick={onUpdate}>
65+
Edit
66+
</DropdownMenuItem>
67+
{isCoach && (
68+
<DropdownMenuItem onClick={onDelete} className="text-destructive">
69+
Delete
70+
</DropdownMenuItem>
71+
)}
72+
</DropdownMenuContent>
73+
</DropdownMenu>
74+
</div>
4575
</div>
4676
</CardHeader>
4777
</Card>

src/components/ui/dashboard/add-coaching-session-dialog.tsx

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)