-
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.
- Loading branch information
Showing
34 changed files
with
654 additions
and
180 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
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,2 +1,3 @@ | ||
.env | ||
img/node_modules | ||
frontend/src/generated/graphql-types.ts |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/playwright:v1.48.0-jammy | ||
FROM mcr.microsoft.com/playwright:v1.49.1-jammy | ||
|
||
WORKDIR /app | ||
|
||
|
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,16 @@ | ||
import { useContext } from "react"; | ||
import { Navigate } from "react-router-dom"; | ||
import { UserContext } from "./Layout"; | ||
import { Role } from "../interface/types"; | ||
|
||
function AdminRouteProtection({ children }: { children: React.ReactNode }) { | ||
const userInfo = useContext(UserContext); | ||
|
||
if (!userInfo.isLoggedIn || userInfo.role !== Role.Admin) { | ||
return <Navigate to="/" replace />; | ||
} | ||
|
||
return <>{children}</>; | ||
} | ||
|
||
export default AdminRouteProtection; |
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,67 @@ | ||
import { Card, Divider } from "antd"; | ||
import { ReservationData } from "../interface/types"; | ||
import ValidateReservationButton from "./ValidateReservationButton"; | ||
import CancelReservationButton from "./CancelReservationButton"; | ||
import DeleteArticleReservationButton from "./DeleteArticleReservationButton"; | ||
|
||
export const ArticleReservationCard = ({ | ||
reservationData, | ||
}: { | ||
reservationData: ReservationData; | ||
}) => { | ||
const articles = reservationData.reservation.articles; | ||
|
||
return ( | ||
<> | ||
{reservationData.reservation.status === "pending" ? ( | ||
<Card title={"Détails de votre réservation"} style={{ width: 500 }}> | ||
{articles.map((article) => ( | ||
<Card style={{ margin: 20 }} key={article.product?.id}> | ||
<div | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
}} | ||
> | ||
<div style={{ display: "flex", alignItems: "center" }}> | ||
<img | ||
src={article.product?.imgUrl} | ||
alt="product img" | ||
style={{ height: 100, marginRight: 20 }} | ||
/> | ||
<div> | ||
<p style={{ margin: 0, fontWeight: "bold" }}> | ||
{article.product?.name} | ||
</p> | ||
<p style={{ margin: 0 }}>{article.product?.price}€</p> | ||
</div> | ||
</div> | ||
<DeleteArticleReservationButton | ||
articleId={article.id} | ||
reservationData={reservationData} | ||
/> | ||
</div> | ||
</Card> | ||
))} | ||
<div style={{ display: "flex", justifyContent: "space-around" }}> | ||
{reservationData.reservation.status === "pending" && ( | ||
<ValidateReservationButton | ||
reservation={reservationData.reservation} | ||
/> | ||
)} | ||
{reservationData.reservation.status === "pending" && ( | ||
<CancelReservationButton | ||
reservation={reservationData.reservation} | ||
/> | ||
)} | ||
</div> | ||
</Card> | ||
) : ( | ||
<h1>Aucune réservation en cours.</h1> | ||
)} | ||
|
||
<Divider dashed /> | ||
</> | ||
); | ||
}; |
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,45 @@ | ||
import { useMutation } from "@apollo/client"; | ||
import { Button, message, Popconfirm } from "antd"; | ||
import { CANCEL_RESERVATION } from "../graphql/mutations"; | ||
import { ReservationData } from "../interface/types"; | ||
import { | ||
GetCurrentReservationByUserIdDocument, | ||
GetReservationsByUserIdDocument, | ||
} from "../generated/graphql-types"; | ||
|
||
function CancelReservationButton({ reservation }: ReservationData) { | ||
const [cancelReservation] = useMutation(CANCEL_RESERVATION, { | ||
onCompleted: () => { | ||
message.success("La réservation a bien été annulée."); | ||
}, | ||
onError: () => { | ||
message.error("Une erreur est survenue lors de l'annulation."); | ||
}, | ||
refetchQueries: [ | ||
GetReservationsByUserIdDocument, | ||
GetCurrentReservationByUserIdDocument, | ||
], | ||
}); | ||
|
||
return ( | ||
<> | ||
<Popconfirm | ||
title="Annuler cette réservation ?" | ||
description="La réservation sera définitivement annulée." | ||
okText="Oui" | ||
cancelText="Non" | ||
onConfirm={() => | ||
cancelReservation({ | ||
variables: { | ||
reservationId: reservation.id.toString(), | ||
}, | ||
}) | ||
} | ||
> | ||
<Button danger>Annuler la réservation</Button> | ||
</Popconfirm> | ||
</> | ||
); | ||
} | ||
|
||
export default CancelReservationButton; |
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,10 +1,12 @@ | ||
import { ReservationData } from "../interface/types"; | ||
import { ReservationCard } from "./ReservationCard"; | ||
import { ArticleReservationCard } from "./ArticleReservationCard"; | ||
|
||
export const CurrentReservation = ({ reservationData }: { reservationData: ReservationData }) => { | ||
return ( | ||
<ReservationCard reservationData={reservationData} /> | ||
); | ||
export const CurrentReservation = ({ | ||
reservationData, | ||
}: { | ||
reservationData: ReservationData; | ||
}) => { | ||
return <ArticleReservationCard reservationData={reservationData} />; | ||
}; | ||
|
||
export default CurrentReservation; |
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.