-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #459 from NIAEFEUP/main
Merge hotfixes in main to develop
- Loading branch information
Showing
26 changed files
with
330 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
set -e # abort script if any command fails | ||
|
||
docker compose up $1 tts-frontend | ||
docker compose up $1 tts-frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { useState } from "react" | ||
import { Button } from "../ui/button" | ||
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card" | ||
import { ExchangeStatus } from "./requests/cards/ExchangeStatus" | ||
import { Person } from "./requests/cards/Person" | ||
import { RequestDate } from "./requests/cards/RequestDate" | ||
import { ArrowRightIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" | ||
import { AdminPreviewSchedule } from "./requests/AdminPreviewSchedule" | ||
import useStudentsSchedule from "../../hooks/admin/useStudentsSchedule" | ||
import { ClassDescriptor, MarketplaceRequest } from "../../@types" | ||
import { AdminRequestCardFooter } from "./requests/cards/AdminRequestCardFooter" | ||
import { listEmailExchanges } from "../../utils/mail" | ||
import { AdminRequestType } from "../../utils/exchange" | ||
|
||
type Props = { | ||
exchange: MarketplaceRequest | ||
} | ||
|
||
export const AdminMarketplaceExhangesCard = ({ | ||
exchange | ||
}: Props) => { | ||
const [open, setOpen] = useState<boolean>(false); | ||
const [exchangeState, setExchangeState] = useState(exchange); | ||
|
||
const { schedule } = useStudentsSchedule(exchange.issuer_nmec); | ||
|
||
return (<> | ||
<Card> | ||
<CardHeader className="flex flex-row justify-between items-center"> | ||
<div className="flex gap-4 items-center"> | ||
<div className="flex flex-col gap-1 "> | ||
<div className="flex gap-2 items-center"> | ||
<CardTitle> | ||
<h2 className="font-bold"> | ||
{`#${exchange.id}`} | ||
</h2> | ||
</CardTitle> | ||
<ExchangeStatus exchange={exchangeState} /> | ||
</div> | ||
<RequestDate | ||
date={exchange.date} | ||
/> | ||
</div> | ||
{!open && <> | ||
<Person name={exchange.issuer_name} nmec={exchange.issuer_nmec} /> | ||
</>} | ||
|
||
</div> | ||
<div> | ||
<Button | ||
onClick={() => setOpen(prev => !prev)} | ||
className="bg-white text-black border-2 border-black hover:text-white" | ||
> | ||
{open | ||
? <ChevronUpIcon className="w-5 h-5" /> | ||
: <ChevronDownIcon className="w-5 h-5" /> | ||
} | ||
</Button> | ||
</div> | ||
</CardHeader> | ||
|
||
<CardContent className="w-full "> | ||
{open && | ||
<div className="flex flex-col gap-y-8" key={crypto.randomUUID()}> | ||
<div className="flex justify-between"> | ||
<Person name={exchange.issuer_name} nmec={exchange.issuer_nmec} /> | ||
<div> | ||
<div | ||
key={crypto.randomUUID()} | ||
className="flex flex-col gap-y-2 items-center border-gray-200 border-2 rounded-md p-2 px-4" | ||
> | ||
<>{exchange.options.map((option) => ( | ||
<div key={crypto.randomUUID()} className="flex gap-5 items-center"> | ||
<h2 className="font-bold">{option.course_info.acronym}</h2> | ||
<div className="flex gap-2 items-center"> | ||
<p>{option.class_issuer_goes_from.name}</p> | ||
<ArrowRightIcon className="w-5 h-5" /> | ||
<p>{option.class_issuer_goes_to.name}</p> | ||
</div> | ||
</div> | ||
))} | ||
</> | ||
</div> | ||
</div> | ||
<div> | ||
<AdminPreviewSchedule | ||
originalSchedule={schedule} | ||
classesToAdd={ | ||
exchange.options.map((option): ClassDescriptor => { | ||
return { | ||
classInfo: option.class_issuer_goes_to, | ||
courseInfo: option.course_info, | ||
slotInfo: null | ||
} | ||
}) | ||
} | ||
|
||
/> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
</CardContent> | ||
|
||
{open && | ||
<AdminRequestCardFooter | ||
nmecs={[exchange.issuer_nmec]} | ||
exchangeMessage={listEmailExchanges( | ||
exchange.options.map(option => ({ | ||
participant_name: undefined, | ||
participant_nmec: exchange.issuer_nmec, | ||
goes_from: option.class_issuer_goes_from?.name, | ||
goes_to: option.class_issuer_goes_to.name, | ||
course_acronym: option.course_info.acronym | ||
})) | ||
)} | ||
requestType={AdminRequestType.URGENT_EXCHANGE} | ||
requestId={exchange.id} | ||
setExchange={setExchangeState} | ||
courseId={exchange.options.map(option => option.course_info.course)} | ||
/> | ||
} | ||
</Card> | ||
</> | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
src/components/admin/requests/AdminMarketplaceExhanges.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useContext } from "react"; | ||
import RequestFiltersContext from "../../../contexts/admin/RequestFiltersContext"; | ||
import useAdminAllMarketplaceExchanges from "../../../hooks/admin/useAdminAllMarketplaceExchanges" | ||
import AdminPaginationContext from "../../../contexts/admin/AdminPaginationContext"; | ||
import { BarLoader } from "react-spinners"; | ||
import { AdminMarketplaceExhangesCard } from "../AdminMarketplaceExchangesCard"; | ||
|
||
export const AdminMarketplaceExhanges = () => { | ||
const filterContext = useContext(RequestFiltersContext); | ||
const { currPage } = useContext(AdminPaginationContext); | ||
const { exchanges, loading } = useAdminAllMarketplaceExchanges(filterContext, currPage); | ||
|
||
return (<> | ||
{loading && <BarLoader className="w-full" />} | ||
|
||
{exchanges?.map((exchange) => ( | ||
<AdminMarketplaceExhangesCard | ||
key={`admin-marketplace-${exchange.id}`} | ||
exchange={exchange} | ||
/> | ||
))} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,11 @@ export const AdminSendEmail = ({ | |
message="" | ||
}: Props) => { | ||
return <> | ||
<a href={`${mailtoStringBuilder(nmec)}?subject=${subject}&[email protected]&body=Viva,%0D%0A%0D%0A ${message} %0D%0A%0D%0ACmpts,%0D%0ADaniel Silva%0D%0A(pela comissão de inscrição em turmas)`}> | ||
<a | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
href={`${mailtoStringBuilder(nmec)}?subject=${subject}&[email protected]&body=Viva,%0D%0A%0D%0A ${message} %0D%0A%0D%0ACmpts,%0D%0ADaniel Silva%0D%0A(pela comissão de inscrição em turmas)`} | ||
> | ||
<Button | ||
variant="secondary" | ||
> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { Dispatch, SetStateAction } from "react" | ||
import { CourseUnitEnrollment, DirectExchangeRequest, UrgentRequest } from "../../../../@types" | ||
import { CourseUnitEnrollment, DirectExchangeRequest, MarketplaceRequest, UrgentRequest } from "../../../../@types" | ||
import { AdminRequestType } from "../../../../utils/exchange" | ||
import exchangeRequestService from "../../../../api/services/exchangeRequestService" | ||
import { mailtoStringBuilder } from "../../../../utils/mail" | ||
|
@@ -15,7 +15,7 @@ type Props = { | |
requestType: AdminRequestType, | ||
requestId: number, | ||
showTreatButton?: boolean, | ||
setExchange?: Dispatch<SetStateAction<DirectExchangeRequest | UrgentRequest | CourseUnitEnrollment>> | ||
setExchange?: Dispatch<SetStateAction<DirectExchangeRequest | UrgentRequest | CourseUnitEnrollment | MarketplaceRequest>> | ||
courseId: Array<number> | ||
} | ||
|
||
|
@@ -29,6 +29,9 @@ const rejectRequest = async ( | |
await exchangeRequestService.adminRejectExchangeRequest(requestType, id); | ||
|
||
const a = document.createElement('a'); | ||
a.target = "_blank"; | ||
a.rel = "noopener noreferrer"; | ||
|
||
if(requestType === AdminRequestType.DIRECT_EXCHANGE || requestType === AdminRequestType.URGENT_EXCHANGE) { | ||
a.href = `${mailtoStringBuilder(nmecs)}?subject=Pedido de Alteração de Turma&[email protected]&body=Viva,%0D%0A%0D%0AA alteração pedida não pode ser efetuada.%0D%0A${exchangeMessage}%0D%0A%0D%0ACmpts,%0D%0ADaniel Silva%0D%0A(pela comissão de inscrição em turmas)`; | ||
} else { | ||
|
@@ -51,11 +54,14 @@ const acceptRequest = async ( | |
await exchangeRequestService.adminAcceptExchangeRequest(requestType, id); | ||
|
||
const a = document.createElement('a'); | ||
a.target = "_blank"; | ||
a.rel = "noopener noreferrer"; | ||
if(requestType === AdminRequestType.DIRECT_EXCHANGE || requestType === AdminRequestType.URGENT_EXCHANGE) { | ||
a.href = `${mailtoStringBuilder(nmecs)}?subject=Pedido de Troca de Turma&[email protected]&body=Viva,%0D%0A%0D%0AA alteração pedida foi efetuada.%0D%0A${exchangeMessage}%0D%0A%0D%0ACmpts,%0D%0ADaniel Silva%0D%0A(pela comissão de inscrição em turmas)`; | ||
} else { | ||
a.href = `${mailtoStringBuilder(nmecs)}?subject=Pedido de Inscrição em Unidades Curriculares&[email protected]&body=Viva,%0D%0A%0D%0AA alteração pedida foi efetuada.%0D%0A${exchangeMessage}%0D%0A%0D%0ACmpts,%0D%0ADaniel Silva%0D%0A(pela comissão de inscrição em turmas)`; | ||
} | ||
|
||
a.click(); | ||
} catch (e) { | ||
console.error(e); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.