Skip to content

Commit 60b749f

Browse files
authored
Merge pull request #56 from cortex-reply/fix/teams
fix: applies fix on team view
2 parents f74a8cb + 31fdaeb commit 60b749f

5 files changed

Lines changed: 259 additions & 239 deletions

File tree

src/components/Foundary/Views/TeamsIndexView.tsx

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
"use client"
1+
'use client'
22

3-
import { useState } from "react"
4-
import { motion, AnimatePresence } from "motion/react"
5-
import { DashboardHero } from "../../Heros/DashboardHero/DashboardHero"
6-
import { TeamCard } from "../../Projects/team-card"
7-
import { type TeamSummary } from "../types"
8-
import { TeamForm, type Team } from "../team-form"
3+
import { useState } from 'react'
4+
import { motion, AnimatePresence } from 'motion/react'
5+
import { DashboardHero } from '../../Heros/DashboardHero/DashboardHero'
6+
import { TeamCard } from '../../Projects/team-card'
7+
import { type TeamSummary } from '../types'
8+
import { TeamForm, type Team } from '../team-form'
99
import {
1010
Dialog,
1111
DialogContent,
1212
DialogDescription,
1313
DialogHeader,
1414
DialogTitle,
15-
} from "@/components/ui/dialog"
15+
} from '@/components/ui/dialog'
1616

1717
interface TeamsIndexViewProps {
1818
teams?: TeamSummary[]
19-
onCreateTeam?: (team: Team) => void
19+
onCreateTeam?: (team: Team) => Promise<void>
2020
onTeamOpen?: (team: TeamSummary) => void
2121
}
2222

@@ -31,8 +31,8 @@ export default function TeamsIndexView({
3131
setIsNewTeamDialogOpen(true)
3232
}
3333

34-
const handleTeamSave = (team: Team) => {
35-
onCreateTeam?.(team)
34+
const handleTeamSave = async (team: Team) => {
35+
await onCreateTeam?.(team)
3636
setIsNewTeamDialogOpen(false)
3737
}
3838

@@ -59,7 +59,7 @@ export default function TeamsIndexView({
5959
description="Collaborate with your human and digital colleagues across different teams and projects."
6060
gradient="bg-gradient-to-r from-blue-600 via-cyan-600 to-teal-600"
6161
primaryAction={{
62-
label: "Create Team",
62+
label: 'Create Team',
6363
onClick: handleNewTeamClick,
6464
}}
6565
/>
@@ -68,21 +68,15 @@ export default function TeamsIndexView({
6868
<h2 className="text-2xl font-semibold">Active Teams</h2>
6969
{teams.length === 0 ? (
7070
<div className="text-center py-12">
71-
<p className="text-muted-foreground text-lg">
72-
You're not part of any teams yet.
73-
</p>
71+
<p className="text-muted-foreground text-lg">You're not part of any teams yet.</p>
7472
<p className="text-muted-foreground text-sm mt-2">
7573
Create a new team or ask to be added to an existing one.
7674
</p>
7775
</div>
7876
) : (
7977
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
8078
{teams.map((team) => (
81-
<TeamCard
82-
key={team.id}
83-
team={team}
84-
onOpen={handleTeamOpen}
85-
/>
79+
<TeamCard key={team.id} team={team} onOpen={handleTeamOpen} />
8680
))}
8781
</div>
8882
)}
@@ -92,7 +86,7 @@ export default function TeamsIndexView({
9286

9387
{/* New Team Dialog */}
9488
<Dialog open={isNewTeamDialogOpen} onOpenChange={setIsNewTeamDialogOpen}>
95-
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto p-0">
89+
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
9690
<div className="sr-only">
9791
<DialogHeader>
9892
<DialogTitle>Create New Team</DialogTitle>
Lines changed: 126 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
"use client"
1+
'use client'
22

3-
import type React from "react"
3+
import type React from 'react'
44

5-
import { useState, useEffect } from "react"
6-
import { Users, Edit } from "lucide-react"
7-
import { Button } from "@/components/ui/button"
8-
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
9-
import { Input } from "@/components/ui/input"
10-
import { Label } from "@/components/ui/label"
11-
import { Textarea } from "@/components/ui/textarea"
12-
import { Switch } from "@/components/ui/switch"
13-
import type { User, DigitalColleague, Team as BaseTeam } from "./types"
5+
import { useState, useEffect } from 'react'
6+
import { Users, Edit } from 'lucide-react'
7+
import { Button } from '@/components/ui/button'
8+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
9+
import { Input } from '@/components/ui/input'
10+
import { Label } from '@/components/ui/label'
11+
import { Textarea } from '@/components/ui/textarea'
12+
import { Switch } from '@/components/ui/switch'
13+
import type { User, DigitalColleague, Team as BaseTeam } from './types'
1414

1515
export interface Team {
16-
id: number;
17-
name: string;
18-
description?: string | null;
19-
systemMsg?: string | null;
20-
useProjects?: boolean | null;
21-
useKnowledge?: boolean | null;
22-
useFiles?: boolean | null;
23-
useChat?: boolean | null;
24-
updatedAt: string;
25-
createdAt: string;
16+
id: number
17+
name: string
18+
description?: string | null
19+
systemMsg?: string | null
20+
useProjects?: boolean | null
21+
useKnowledge?: boolean | null
22+
useFiles?: boolean | null
23+
useChat?: boolean | null
24+
updatedAt: string
25+
createdAt: string
2626
}
2727

2828
interface TeamFormProps {
2929
team?: Team
30-
onSave: (team: Team) => void
30+
onSave: (team: Team) => Promise<void>
3131
onCancel: () => void
3232
isLoading?: boolean
3333
title?: string
@@ -43,13 +43,13 @@ export function TeamForm({
4343
isLoading = false,
4444
title,
4545
submitLabel,
46-
cancelLabel = "Cancel",
46+
cancelLabel = 'Cancel',
4747
readOnly = false,
4848
}: TeamFormProps) {
4949
const [formData, setFormData] = useState<Partial<Team>>({
50-
name: "",
51-
description: "",
52-
systemMsg: "",
50+
name: '',
51+
description: '',
52+
systemMsg: '',
5353
useProjects: false,
5454
useKnowledge: false,
5555
useFiles: false,
@@ -65,7 +65,7 @@ export function TeamForm({
6565
}
6666
}, [team])
6767

68-
const handleSubmit = (e: React.FormEvent) => {
68+
const handleSubmit = async (e: React.FormEvent) => {
6969
e.preventDefault()
7070

7171
const teamData: Team = {
@@ -80,129 +80,126 @@ export function TeamForm({
8080
updatedAt: new Date().toISOString(),
8181
createdAt: formData.createdAt || new Date().toISOString(),
8282
}
83-
onSave(teamData)
83+
await onSave(teamData)
8484
}
8585

8686
const handleEditToggle = (e: React.FormEvent) => {
8787
e.preventDefault()
8888
setEditMode(!editMode)
8989
}
9090

91-
const formTitle = title || (!editMode ? "View Team" : (team ? "Edit Team" : "Create New Team"))
92-
const buttonLabel = submitLabel || (team ? "Update Team" : "Create Team")
91+
const formTitle = title || (!editMode ? 'View Team' : team ? 'Edit Team' : 'Create New Team')
92+
const buttonLabel = submitLabel || (team ? 'Update Team' : 'Create Team')
9393

9494
return (
95-
<Card className="m-8 w-full max-w-4xl mx-auto">
96-
<CardHeader>
97-
<CardTitle className="flex items-center gap-2">
98-
<Users className="h-5 w-5" />
99-
{formTitle}
100-
</CardTitle>
101-
</CardHeader>
102-
<CardContent>
103-
<form onSubmit={handleSubmit} className="space-y-6">
104-
{/* Basic Information */}
105-
<div className="space-y-4">
106-
<div className="space-y-2">
107-
<Label htmlFor="name">Team Name *</Label>
108-
<Input
109-
id="name"
110-
value={formData.name || ""}
111-
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
112-
required
95+
<>
96+
<div className="flex items-center gap-2">
97+
<Users className="h-5 w-5" />
98+
{formTitle}
99+
</div>
100+
101+
<form onSubmit={handleSubmit} className="space-y-6">
102+
{/* Basic Information */}
103+
<div className="space-y-4">
104+
<div className="space-y-2">
105+
<Label htmlFor="name">Team Name *</Label>
106+
<Input
107+
id="name"
108+
value={formData.name || ''}
109+
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
110+
required
111+
disabled={isLoading || !editMode}
112+
placeholder="Enter team name..."
113+
/>
114+
</div>
115+
<div className="space-y-2">
116+
<Label htmlFor="description">Description</Label>
117+
<Textarea
118+
id="description"
119+
value={formData.description || ''}
120+
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
121+
rows={3}
122+
placeholder="Brief description of this team..."
123+
disabled={isLoading || !editMode}
124+
/>
125+
</div>
126+
<div className="space-y-2">
127+
<Label htmlFor="systemMsg">Ways of working</Label>
128+
<Textarea
129+
id="systemMsg"
130+
value={formData.systemMsg || ''}
131+
onChange={(e) => setFormData({ ...formData, systemMsg: e.target.value })}
132+
rows={3}
133+
placeholder="Describe how this team works in as much detail as possible. Include processes, tools, systems, styles..."
134+
disabled={isLoading || !editMode}
135+
/>
136+
</div>
137+
</div>
138+
139+
{/* Team Configuration */}
140+
<div className="space-y-4">
141+
<h3 className="text-lg font-semibold">Team Configuration</h3>
142+
143+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
144+
<div className="flex items-center space-x-2">
145+
<Switch
146+
id="useProjects"
147+
checked={formData.useProjects || false}
148+
onCheckedChange={(checked) => setFormData({ ...formData, useProjects: checked })}
113149
disabled={isLoading || !editMode}
114-
placeholder="Enter team name..."
115150
/>
151+
<Label htmlFor="useProjects">Enable Projects</Label>
116152
</div>
117-
<div className="space-y-2">
118-
<Label htmlFor="description">Description</Label>
119-
<Textarea
120-
id="description"
121-
value={formData.description || ""}
122-
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
123-
rows={3}
124-
placeholder="Brief description of this team..."
153+
154+
<div className="flex items-center space-x-2">
155+
<Switch
156+
id="useKnowledge"
157+
checked={formData.useKnowledge || false}
158+
onCheckedChange={(checked) => setFormData({ ...formData, useKnowledge: checked })}
125159
disabled={isLoading || !editMode}
126160
/>
161+
<Label htmlFor="useKnowledge">Enable Knowledge Base</Label>
127162
</div>
128-
<div className="space-y-2">
129-
<Label htmlFor="systemMsg">Ways of working</Label>
130-
<Textarea
131-
id="systemMsg"
132-
value={formData.systemMsg || ""}
133-
onChange={(e) => setFormData({ ...formData, systemMsg: e.target.value })}
134-
rows={3}
135-
placeholder="Describe how this team works in as much detail as possible. Include processes, tools, systems, styles..."
163+
164+
<div className="flex items-center space-x-2">
165+
<Switch
166+
id="useFiles"
167+
checked={formData.useFiles || false}
168+
onCheckedChange={(checked) => setFormData({ ...formData, useFiles: checked })}
136169
disabled={isLoading || !editMode}
137170
/>
171+
<Label htmlFor="useFiles">Enable File Management</Label>
138172
</div>
139-
</div>
140173

141-
{/* Team Configuration */}
142-
<div className="space-y-4">
143-
<h3 className="text-lg font-semibold">Team Configuration</h3>
144-
145-
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
146-
<div className="flex items-center space-x-2">
147-
<Switch
148-
id="useProjects"
149-
checked={formData.useProjects || false}
150-
onCheckedChange={(checked) => setFormData({ ...formData, useProjects: checked })}
151-
disabled={isLoading || !editMode}
152-
/>
153-
<Label htmlFor="useProjects">Enable Projects</Label>
154-
</div>
155-
156-
<div className="flex items-center space-x-2">
157-
<Switch
158-
id="useKnowledge"
159-
checked={formData.useKnowledge || false}
160-
onCheckedChange={(checked) => setFormData({ ...formData, useKnowledge: checked })}
161-
disabled={isLoading || !editMode}
162-
/>
163-
<Label htmlFor="useKnowledge">Enable Knowledge Base</Label>
164-
</div>
165-
166-
<div className="flex items-center space-x-2">
167-
<Switch
168-
id="useFiles"
169-
checked={formData.useFiles || false}
170-
onCheckedChange={(checked) => setFormData({ ...formData, useFiles: checked })}
171-
disabled={isLoading || !editMode}
172-
/>
173-
<Label htmlFor="useFiles">Enable File Management</Label>
174-
</div>
175-
176-
<div className="flex items-center space-x-2">
177-
<Switch
178-
id="useChat"
179-
checked={formData.useChat || false}
180-
onCheckedChange={(checked) => setFormData({ ...formData, useChat: checked })}
181-
disabled={isLoading || !editMode}
182-
/>
183-
<Label htmlFor="useChat">Enable Team Chat</Label>
184-
</div>
174+
<div className="flex items-center space-x-2">
175+
<Switch
176+
id="useChat"
177+
checked={formData.useChat || false}
178+
onCheckedChange={(checked) => setFormData({ ...formData, useChat: checked })}
179+
disabled={isLoading || !editMode}
180+
/>
181+
<Label htmlFor="useChat">Enable Team Chat</Label>
185182
</div>
186183
</div>
187-
188-
{/* Form Actions */}
189-
<div className="flex justify-end gap-2 pt-4 border-t">
190-
<Button type="button" variant="outline" onClick={onCancel} disabled={isLoading}>
191-
{!editMode ? "Close" : cancelLabel}
184+
</div>
185+
186+
{/* Form Actions */}
187+
<div className="flex justify-end gap-2 pt-4 border-t">
188+
<Button type="button" variant="outline" onClick={onCancel} disabled={isLoading}>
189+
{!editMode ? 'Close' : cancelLabel}
190+
</Button>
191+
{!editMode ? (
192+
<Button type="button" onClick={handleEditToggle} disabled={isLoading} className="gap-2">
193+
<Edit className="h-4 w-4" />
194+
Edit
192195
</Button>
193-
{!editMode ? (
194-
<Button type="button" onClick={handleEditToggle} disabled={isLoading} className="gap-2">
195-
<Edit className="h-4 w-4" />
196-
Edit
197-
</Button>
198-
) : (
199-
<Button type="submit" disabled={isLoading || !formData.name?.trim()}>
200-
{isLoading ? "Saving..." : buttonLabel}
201-
</Button>
202-
)}
203-
</div>
204-
</form>
205-
</CardContent>
206-
</Card>
196+
) : (
197+
<Button type="submit" disabled={isLoading || !formData.name?.trim()}>
198+
{isLoading ? 'Saving...' : buttonLabel}
199+
</Button>
200+
)}
201+
</div>
202+
</form>
203+
</>
207204
)
208205
}

0 commit comments

Comments
 (0)