Skip to content

Commit

Permalink
Merge pull request #458 from NIAEFEUP/fix/prevent-null-from-crashing
Browse files Browse the repository at this point in the history
fix: prevent null from crashing
  • Loading branch information
tomaspalma authored Feb 11, 2025
2 parents 887cee0 + c9c5b4d commit fefba1c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/admin/AdminMarketplaceExchangesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const AdminMarketplaceExhangesCard = ({
exchange.options.map(option => ({
participant_name: undefined,
participant_nmec: exchange.issuer_nmec,
goes_from: option.class_issuer_goes_from.name,
goes_from: option.class_issuer_goes_from?.name,
goes_to: option.class_issuer_goes_to.name,
course_acronym: option.course_info.acronym
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const CommonRequestCard = ({
request.options.forEach((option) => {
if (updatedOptions.get(option.course_info.acronym) === true) {
const matchingClass = (type === "directexchange" ? option.class_participant_goes_to : option.class_issuer_goes_from);
if(!matchingClass) return;
matchingClass.slots.forEach((slot) => {
newExchangeSchedule.push({
courseInfo: option.course_info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export const ListRequestChanges = ({
</TableHeader>
<TableBody>
<TableRow>
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_from.name : (option as ExchangeOption).class_issuer_goes_from.name}</TableCell>
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_to.name : (option as ExchangeOption).class_issuer_goes_to.name}</TableCell>
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_from.name : (option as ExchangeOption).class_issuer_goes_from?.name}</TableCell>
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_to.name : (option as ExchangeOption).class_issuer_goes_to?.name}</TableCell>
</TableRow>
</TableBody>
</Table>
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useMarketplaceAcceptExchange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default (request: MarketplaceRequest | DirectExchangeRequest, selectedOpt
{
courseUnitId: option.course_info.id,
courseUnitName: option.course_info.name,
classNameRequesterGoesTo: (option as ExchangeOption).class_issuer_goes_from.name,
classNameRequesterGoesFrom: (option as ExchangeOption).class_issuer_goes_to.name,
classNameRequesterGoesTo: (option as ExchangeOption).class_issuer_goes_from?.name,
classNameRequesterGoesFrom: (option as ExchangeOption).class_issuer_goes_to?.name,
other_student: {
name: request.issuer_name,
mecNumber: request.issuer_nmec
Expand Down

0 comments on commit fefba1c

Please sign in to comment.