Skip to content

Commit fefba1c

Browse files
authored
Merge pull request #458 from NIAEFEUP/fix/prevent-null-from-crashing
fix: prevent null from crashing
2 parents 887cee0 + c9c5b4d commit fefba1c

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/components/admin/AdminMarketplaceExchangesCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const AdminMarketplaceExhangesCard = ({
109109
exchange.options.map(option => ({
110110
participant_name: undefined,
111111
participant_nmec: exchange.issuer_nmec,
112-
goes_from: option.class_issuer_goes_from.name,
112+
goes_from: option.class_issuer_goes_from?.name,
113113
goes_to: option.class_issuer_goes_to.name,
114114
course_acronym: option.course_info.acronym
115115
}))

src/components/exchange/requests/view/cards/CommonRequestCard.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export const CommonRequestCard = ({
9393
request.options.forEach((option) => {
9494
if (updatedOptions.get(option.course_info.acronym) === true) {
9595
const matchingClass = (type === "directexchange" ? option.class_participant_goes_to : option.class_issuer_goes_from);
96+
if(!matchingClass) return;
9697
matchingClass.slots.forEach((slot) => {
9798
newExchangeSchedule.push({
9899
courseInfo: option.course_info,

src/components/exchange/requests/view/cards/ListRequestChanges.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export const ListRequestChanges = ({
7979
</TableHeader>
8080
<TableBody>
8181
<TableRow>
82-
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_from.name : (option as ExchangeOption).class_issuer_goes_from.name}</TableCell>
83-
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_to.name : (option as ExchangeOption).class_issuer_goes_to.name}</TableCell>
82+
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_from.name : (option as ExchangeOption).class_issuer_goes_from?.name}</TableCell>
83+
<TableCell>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_to.name : (option as ExchangeOption).class_issuer_goes_to?.name}</TableCell>
8484
</TableRow>
8585
</TableBody>
8686
</Table>

src/hooks/useMarketplaceAcceptExchange.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default (request: MarketplaceRequest | DirectExchangeRequest, selectedOpt
1717
{
1818
courseUnitId: option.course_info.id,
1919
courseUnitName: option.course_info.name,
20-
classNameRequesterGoesTo: (option as ExchangeOption).class_issuer_goes_from.name,
21-
classNameRequesterGoesFrom: (option as ExchangeOption).class_issuer_goes_to.name,
20+
classNameRequesterGoesTo: (option as ExchangeOption).class_issuer_goes_from?.name,
21+
classNameRequesterGoesFrom: (option as ExchangeOption).class_issuer_goes_to?.name,
2222
other_student: {
2323
name: request.issuer_name,
2424
mecNumber: request.issuer_nmec

0 commit comments

Comments
 (0)