Skip to content

Commit

Permalink
Merge pull request #436 from NIAEFEUP/fix/multiple-student-admin-exch…
Browse files Browse the repository at this point in the history
…anges-crashing

fix: multiple student admin exchanges crashing
  • Loading branch information
tomaspalma authored Feb 6, 2025
2 parents 7c224ea + 21e4922 commit a99531b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/admin/requests/AdminPreviewSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const AdminPreviewSchedule = ({
<DialogTitle>Prever horário</DialogTitle>
</DialogHeader>
<ScheduleContext.Provider value={{
originalExchangeSchedule: originalSchedule.filter((classDescriptor) => classDescriptor.classInfo && classDescriptor.courseInfo),
originalExchangeSchedule: originalSchedule?.filter((classDescriptor) => classDescriptor.classInfo && classDescriptor.courseInfo),
exchangeSchedule: schedule,
setExchangeSchedule: setSchedule,
enrolledCourseUnits: [],
Expand Down
29 changes: 16 additions & 13 deletions src/components/admin/requests/cards/SingleStudentExchangeCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { ClassDescriptor, UrgentRequest, UrgentRequestOption } from "../../../../@types"
import { ClassDescriptor, UrgentRequest } from "../../../../@types"
import { Card, CardContent, CardHeader, CardTitle } from "../../../ui/card";
import { Button } from "../../../ui/button";
import { ArrowRightIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
Expand Down Expand Up @@ -38,7 +38,7 @@ export const SingleStudentExchangeCard = ({
</CardTitle>
<ExchangeStatus exchange={exchangeState} />
</div>
<RequestDate
<RequestDate
date={exchange.date}
/>
</div>
Expand All @@ -61,7 +61,7 @@ export const SingleStudentExchangeCard = ({
</CardHeader>

<CardContent className="w-full ">
{open && exchange.options.map((option: UrgentRequestOption) => (
{open &&
<div className="flex flex-col gap-y-8" key={crypto.randomUUID()}>
<div className="flex justify-between">
<Person name={exchange.user_nmec} nmec={exchange.user_nmec} />
Expand All @@ -70,14 +70,17 @@ export const SingleStudentExchangeCard = ({
key={crypto.randomUUID()}
className="flex flex-col gap-y-2 items-center border-gray-200 border-2 rounded-md p-2 px-4"
>
<div className="flex gap-5 items-center">
<h2 className="font-bold">{option.course_unit.acronym}</h2>
<div className="flex gap-2 items-center">
<p>{option.class_user_goes_from.name}</p>
<ArrowRightIcon className="w-5 h-5" />
<p>{option.class_user_goes_to.name}</p>
<>{exchange.options.map((option) => (
<div key={crypto.randomUUID()} className="flex gap-5 items-center">
<h2 className="font-bold">{option.course_unit.acronym}</h2>
<div className="flex gap-2 items-center">
<p>{option.class_user_goes_from.name}</p>
<ArrowRightIcon className="w-5 h-5" />
<p>{option.class_user_goes_to.name}</p>
</div>
</div>
</div>
))}
</>
</div>
</div>
<div>
Expand All @@ -101,12 +104,12 @@ export const SingleStudentExchangeCard = ({
<p>{exchange.message}</p>
</div>
</div>
))}
}
</CardContent>

{open &&
<AdminRequestCardFooter
nmecs={[exchange.user_nmec]}
nmecs={[exchange.user_nmec]}
exchangeMessage={listEmailExchanges(
exchange.options.map(option => ({
participant_nmec: exchange.user_nmec,
Expand All @@ -119,7 +122,7 @@ export const SingleStudentExchangeCard = ({
requestId={exchange.id}
setExchange={setExchangeState}
courseId={exchange.options.map(option => option.course_unit.course)}
/>
/>
}
</Card>
</>
Expand Down

0 comments on commit a99531b

Please sign in to comment.