Skip to content

Commit

Permalink
refactor: better handling of common request components having two types
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspalma committed Nov 30, 2024
1 parent 54cfdbd commit 517aa9c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const CreateRequestCard = ({
<div className="flex flex-col gap-y-2">
<p className="text-left font-bold">Estudante</p>
<Button variant="outline" className="w-full">
{selectedDestinationStudent ? selectedDestinationStudent.nome : "Escolher estudante..."}
{selectedDestinationStudent ? selectedDestinationStudent.name : "Escolher estudante..."}
</Button>
</div>
</DropdownMenuTrigger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ArchiveBoxIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline"
import { Hourglass } from "lucide-react"
import { useState } from "react"
import { MarketplaceRequest } from "../../../../../@types"
import { DirectExchangeRequest, MarketplaceRequest } from "../../../../../@types"
import { Button } from "../../../../ui/button"
import { CardDescription, CardHeader, CardTitle } from "../../../../ui/card"
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../../../ui/tooltip"
Expand All @@ -11,7 +11,7 @@ type Props = {
name: string
username: string
hovered: boolean
request: MarketplaceRequest
request: MarketplaceRequest | DirectExchangeRequest
openHook: [boolean, React.Dispatch<React.SetStateAction<boolean>>]
showRequestStatus?: boolean
hideAbility?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export const ListRequestChanges = ({
{option.course_info.acronym} - {option.course_info.name}
</p>
<div className="flex flex-row gap-x-2 items-center font-bold">
<p>{type === "directexchange" ? option.class_participant_goes_from.name : option.class_issuer_goes_from.name}</p>
<p>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_from.name : (option as ExchangeOption).class_issuer_goes_from.name}</p>
<ArrowRightIcon className="w-5 h-5" />
<p>{type === "directexchange" ? option.class_participant_goes_to.name : option.class_issuer_goes_to.name}</p>
<p>{type === "directexchange" ? (option as DirectExchangeParticipant).class_participant_goes_to.name : (option as ExchangeOption).class_issuer_goes_to.name}</p>
</div>
</div>
</label>
Expand Down
5 changes: 3 additions & 2 deletions src/components/exchange/requests/view/cards/RequestCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ListRequestChanges } from "./ListRequestChanges";
import ExchangeRequestCommonContext from "../../../../../contexts/ExchangeRequestCommonContext";
import { CommonCardHeader } from "./CommonCardHeader";
import ConflictsContext from "../../../../../contexts/ConflictsContext";
import { ExchangeOption } from "../../../../../@types";

export const RequestCard = ({ }) => {
const {
Expand Down Expand Up @@ -48,8 +49,8 @@ export const RequestCard = ({ }) => {
{
courseUnitId: option.course_info.id,
courseUnitName: option.course_info.name,
classNameRequesterGoesFrom: option.class_issuer_goes_from.name,
classNameRequesterGoesTo: option.class_issuer_goes_to.name,
classNameRequesterGoesFrom: (option as ExchangeOption).class_issuer_goes_from.name,
classNameRequesterGoesTo: (option as ExchangeOption).class_issuer_goes_to.name,
other_student: {
name: request.issuer_name,
mecNumber: request.issuer_nmec
Expand Down

0 comments on commit 517aa9c

Please sign in to comment.