-
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 branch 'dev' into bugfix/139/responsive-website
- Loading branch information
Showing
34 changed files
with
2,446 additions
and
67 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 +1,2 @@ | ||
JWT_SECRET_KEY = "My_secret-key" | ||
POSTGRES_PASSWORD=example |
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 +1,2 @@ | ||
JWT_SECRET_KEY=defaultvalue | ||
JWT_SECRET_KEY=defaultvalue | ||
POSTGRES_PASSWORD=example |
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 +1,3 @@ | ||
.env | ||
img/node_modules | ||
frontend/src/generated/graphql-types.ts |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 { Reservation } from "../interface/types"; | ||
import { | ||
GetCurrentReservationByUserIdDocument, | ||
GetReservationsByUserIdDocument, | ||
} from "../generated/graphql-types"; | ||
|
||
function CancelReservationButton({ reservation }: Reservation) { | ||
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; |
Oops, something went wrong.