Skip to content

Commit 1393242

Browse files
#397 admin-update-teams (#491)
* fix-admin-update-teams * fixing update team info --------- Co-authored-by: uwimana janet <[email protected]>
1 parent 4728a7e commit 1393242

File tree

4 files changed

+225
-55
lines changed

4 files changed

+225
-55
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/Teams.tsx

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export interface Team {
3434
name: string;
3535
cohort: Cohort;
3636
ttl: any;
37+
manager: any;
38+
phase: any;
39+
program: any;
3740
}
3841

3942
export const getAllTeam = gql`
@@ -72,6 +75,15 @@ export const getAllTeam = gql`
7275
quality
7376
professional_Skills
7477
}
78+
phase {
79+
name
80+
}
81+
program {
82+
name
83+
}
84+
manager {
85+
email
86+
}
7587
}
7688
7789
getAllCohorts(orgToken: $orgToken) {
@@ -96,6 +108,15 @@ export const getAllTeam = gql`
96108
role
97109
organizations
98110
}
111+
getAllPrograms(orgToken: $orgToken) {
112+
id
113+
name
114+
}
115+
getAllPhases(orgToken: $orgToken) {
116+
id
117+
name
118+
description
119+
}
99120
}
100121
`;
101122

@@ -224,17 +245,16 @@ function AdminTeams() {
224245
}),
225246
},
226247
];
227-
228-
const teamData = getData?.getAllTeams.map(({ name, cohort, ttl }) => ({
229-
name,
230-
cohortName: cohort?.name,
231-
coordinator: cohort?.coordinator?.email
232-
? cohort?.coordinator?.email
233-
: 'Not Assigned',
234-
phase: cohort?.phase.name,
235-
programName: cohort?.program?.name,
236-
ttlEmail: ttl?.profile && ttl.profile.name ? ttl?.email : 'Not Assigned',
237-
}));
248+
const teamData = getData?.getAllTeams.map(
249+
({ name, cohort, ttl, phase, program, manager }) => ({
250+
name,
251+
cohortName: cohort?.name,
252+
coordinator: manager?.email ? manager?.email : cohort?.coordinator?.email,
253+
phase: phase?.name ? phase?.name : cohort?.phase?.name,
254+
programName: program?.name ? program?.name : cohort?.program?.name,
255+
ttlEmail: ttl?.profile && ttl.profile.name ? ttl?.email : 'Not Assigned',
256+
}),
257+
);
238258

239259
return (
240260
<>

0 commit comments

Comments
 (0)