Skip to content

Commit 9d93b8f

Browse files
committed
fix-admin-update-teams
1 parent c4ba4bf commit 9d93b8f

File tree

3 files changed

+90
-21
lines changed

3 files changed

+90
-21
lines changed

src/components/ManagerCard.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ function ManagerCard() {
144144
grade,
145145
teamname: team.name,
146146
coordinator: team?.cohort?.coordinator?.profile
147-
? team.cohort.coordinator.profile.name
148-
: team?.cohort.coordinator?.email,
147+
? team.cohort?.coordinator.profile.name
148+
: team?.cohort?.coordinator?.email,
149149
ttl: team?.ttl?.profile ? team.ttl.profile.name : team?.ttl?.email,
150-
phase: team.cohort.phase.name,
150+
phase: team?.cohort?.phase?.name,
151151
week:
152152
calculateWeeks(team.startingPhase) > 0
153153
? calculateWeeks(team.startingPhase)
@@ -161,9 +161,7 @@ function ManagerCard() {
161161
});
162162

163163
return (
164-
<div
165-
className="font-serif px-4 md:px-0 pb-20 w-full dark:bg-dark-frame-bg dark:text-black h-full flex overflow-x-auto "
166-
>
164+
<div className="font-serif px-4 md:px-0 pb-20 w-full dark:bg-dark-frame-bg dark:text-black h-full flex overflow-x-auto ">
167165
{loading ? (
168166
<div className="flex items-center justify-center w-full h-full">
169167
<div className="spinner" />
@@ -172,7 +170,7 @@ function ManagerCard() {
172170
<div className="pl-10 flex">
173171
{teamData &&
174172
teamData.map((teamProps: any, index: number) => (
175-
<Link key={index} to={`/team/${(teamProps.teamname)}`}>
173+
<Link key={index} to={`/team/${teamProps.teamname}`}>
176174
<Card {...teamProps} />
177175
</Link>
178176
))}

src/components/teamDetails.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ function TeamDetails() {
7878
cohort: team?.cohort?.name,
7979
teamname: team.name,
8080
coordinator: team?.cohort?.coordinator?.profile
81-
? team.cohort.coordinator.profile.name
82-
: team?.cohort.coordinator?.email,
81+
? team.cohort?.coordinator.profile.name
82+
: team?.cohort?.coordinator?.email,
8383
ttl: team?.ttl?.profile ? team.ttl.profile.name : team?.ttl?.email,
8484
Qty,
8585
Qnty,
@@ -90,8 +90,8 @@ function TeamDetails() {
9090

9191
const selectedTeam = teamData
9292
? teamData.find(
93-
(team: { teamname: string | null }) => team.teamname === teamname,
94-
)
93+
(team: { teamname: string | null }) => team.teamname === teamname,
94+
)
9595
: null;
9696
function getColor(rating: number) {
9797
if (rating >= 1.5 && rating <= 2) {
@@ -232,7 +232,7 @@ function TeamDetails() {
232232
</h1>
233233
</div>
234234
<div className="relative dark:text-black">
235-
<p>Coordinator: {selectedTeam.coordinator}</p>
235+
<p>Coordinator: {selectedTeam?.coordinator}</p>
236236
<p>TTL: {selectedTeam.ttl}</p>
237237
</div>
238238
</div>
@@ -314,8 +314,8 @@ function TeamDetails() {
314314
{selectedTeam.Qty >= 1.5 && selectedTeam.Qty <= 2
315315
? 'Good'
316316
: selectedTeam.Qty >= 1 && selectedTeam.Qty < 1.5
317-
? 'Improve'
318-
: 'Poor'}
317+
? 'Improve'
318+
: 'Poor'}
319319
</span>
320320
</div>
321321
</div>
@@ -351,8 +351,8 @@ function TeamDetails() {
351351
? 'Good'
352352
: selectedTeam.Qnty >= 1 &&
353353
selectedTeam.Qnty < 1.5
354-
? 'Improve'
355-
: 'Poor'}
354+
? 'Improve'
355+
: 'Poor'}
356356
</span>
357357
</div>
358358
</div>
@@ -386,12 +386,12 @@ function TeamDetails() {
386386
</ul>
387387
<span style={{ color: getColor(selectedTeam.skills) }}>
388388
{selectedTeam.skills >= 1.5 &&
389-
selectedTeam.skills <= 2
389+
selectedTeam.skills <= 2
390390
? 'Good'
391391
: selectedTeam.skills >= 1 &&
392392
selectedTeam.skills < 1.5
393-
? 'Improve'
394-
: 'Poor'}
393+
? 'Improve'
394+
: 'Poor'}
395395
</span>
396396
</div>
397397
</div>

src/containers/admin-dashBoard/UpdateTeamModal.tsx

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@ import { TFunction, useTranslation } from 'react-i18next';
55
import { toast } from 'react-toastify';
66
import Button from '../../components/Buttons';
77
import { Team, Cohort } from './Teams';
8+
import ControlledSelect from '../../components/ControlledSelect';
89

910
export const UpdateTeam = gql`
10-
mutation UpdateTeam($updateTeamId: ID!, $name: String, $orgToken: String) {
11-
updateTeam(id: $updateTeamId, name: $name, orgToken: $orgToken) {
11+
mutation UpdateTeam(
12+
$updateTeamId: ID!
13+
$name: String
14+
$cohort: String
15+
$TTL: String
16+
$orgToken: String
17+
) {
18+
updateTeam(
19+
id: $updateTeamId
20+
orgToken: $orgToken
21+
name: $name
22+
cohort: $cohort
23+
TTL: $TTL
24+
) {
1225
name
1326
}
1427
}
@@ -24,6 +37,7 @@ export default function UpdateTeamModal({
2437
data?: {
2538
getAllTeams: Team[];
2639
getAllCohorts: Cohort[];
40+
getAllUsers: any;
2741
};
2842
updateTeamModal: boolean;
2943
currentTeam: Team | undefined;
@@ -65,6 +79,8 @@ export default function UpdateTeamModal({
6579
}
6680
});
6781

82+
newData.cohort && (newData.cohort = newData.cohort.value);
83+
newData.TTL && (newData.TTL = newData.TTL.value);
6884
newData.updateTeamId = currentTeam?.id;
6985
orgToken && (newData.orgToken = orgToken);
7086

@@ -73,6 +89,14 @@ export default function UpdateTeamModal({
7389

7490
useEffect(() => {
7591
setValue('name', currentTeam?.name);
92+
setValue('TTL', {
93+
value: currentTeam?.ttl?.email,
94+
label: currentTeam?.ttl?.email || 'no ttl assigned',
95+
});
96+
setValue('cohort', {
97+
value: currentTeam?.cohort?.name,
98+
label: currentTeam?.cohort?.name || 'no cohort assigned',
99+
});
76100
}, [currentTeam, updateTeamModal]);
77101

78102
return (
@@ -106,6 +130,53 @@ export default function UpdateTeamModal({
106130
</p>
107131
)}
108132
</div>
133+
<div className="my-5 input h-9">
134+
<div className="flex items-center w-full h-full rounded-md grouped-input">
135+
<ControlledSelect
136+
placeholder={t('email')}
137+
register={{
138+
control,
139+
name: 'TTL',
140+
rules: {
141+
required: `${t('The ttl email is required')}`,
142+
},
143+
}}
144+
options={
145+
data?.getAllUsers
146+
?.filter((user: any) => user.role === 'ttl')
147+
?.map((user: any) => ({
148+
value: user.email,
149+
label: user.email,
150+
})) ?? []
151+
}
152+
/>
153+
</div>
154+
{errors?.ttlEmail && (
155+
<p className="font-thin text-[12px] text-red-300">
156+
{errors?.ttlEmail?.message?.toString()}
157+
</p>
158+
)}
159+
</div>
160+
161+
<div className="my-5 input h-9 ">
162+
<ControlledSelect
163+
placeholder={t('Choose a Cohort')}
164+
register={{
165+
control,
166+
name: 'cohort',
167+
rules: { required: `${t('The Cohort Name is required')}` },
168+
}}
169+
options={data?.getAllCohorts?.map(({ name }) => ({
170+
value: name,
171+
label: name,
172+
}))}
173+
/>
174+
{errors?.programName && (
175+
<p className="font-thin text-[12px] text-red-300">
176+
{errors?.programName?.message?.toString()}
177+
</p>
178+
)}
179+
</div>
109180

110181
<div className="flex justify-between w-full">
111182
<Button

0 commit comments

Comments
 (0)