Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into MDA-Map
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/app/api/journeys/route.ts
  • Loading branch information
MaximeDan committed Jun 25, 2024
2 parents 0de4043 + 7a8c787 commit 514b16a
Show file tree
Hide file tree
Showing 32 changed files with 506 additions and 113 deletions.
1 change: 1 addition & 0 deletions src/apiClient/registerUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const registerUserApi = async (data: {
password: string;
confirmPassword: string;
username: string;
confirmPassword: string;
name: string;
lastName: string;
dateOfBirth?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/(app)/evenements/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Event = () => {
return (
<>
<TopBar />
<main>
<main className="container">
<section className="flex flex-col gap-7 px-5 pb-40">
<Suspense fallback={<div>Loading...</div>}>
<EventsFeed />
Expand Down
4 changes: 2 additions & 2 deletions src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import MobileNav from "@/components/MobileNav";
import Nav from "@/components/Nav";
import { ReactParallaxProvider } from "@/providers/Providers";

export default function AppLayout({
Expand All @@ -10,7 +10,7 @@ export default function AppLayout({
return (
<ReactParallaxProvider>
{children}
<MobileNav />
<Nav />
</ReactParallaxProvider>
);
}
4 changes: 2 additions & 2 deletions src/app/(app)/parcours/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const Parcours = () => {
return (
<>
<TopBar />
<main>
<section className="flex flex-col gap-7 px-5 pb-40">
<main className="container">
<section className="grid grid-cols-1 gap-7 pb-40 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
<Suspense fallback={<div>Loading...</div>}>
<JourneysFeed />
</Suspense>
Expand Down
15 changes: 15 additions & 0 deletions src/app/(app)/profil/evenements/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import TopBar from "@/components/TopBar";

const Event = () => {
return (
<>
<TopBar />
<main>
<h1>Mes évènements</h1>
</main>
</>
);
};

export default Event;
67 changes: 67 additions & 0 deletions src/app/(app)/profil/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from "react";
import TopBar from "@/components/TopBar";
import Link from "next/link";
import { Icons } from "@/components/Icons";
import { Button } from "@/components/ui/button";

const Profil = () => {
return (
<>
<TopBar />
<main className="flex flex-col gap-7 px-5 pb-40">
<h1 className="text-3xl font-bold text-orange">{`Bonjour {Prénom} !`}</h1>
<section>
<h2 className="mb-4 text-2xl font-semibold">Créations</h2>
<div className="flex flex-col gap-3">
<Button type="button" className="w-fit">
<Link className="flex" href="/profil/parcours">
<h3>Mes parcours</h3>
<Icons.arrowLink className="ml-2" />
</Link>
</Button>
<Button type="button" className="w-fit">
<Link className="flex" href="/profil/evenements">
<h3>Mes évènements</h3>
<Icons.arrowLink className="ml-2" />
</Link>
</Button>
</div>
</section>
<section className="flex flex-col rounded-lg bg-gray px-5 py-4">
<Link href="/" className="flex h-8 items-center gap-5 text-sm">
<div className="flex size-5 items-center justify-center">
<Icons.questionMark fill="#CEC0AD" />
</div>
<span className="font-semibold">Signaler un problème</span>
</Link>
<Link href="/" className="flex h-8 items-center gap-5 text-sm">
<div className="flex size-5 items-center justify-center">
<Icons.file fill="#CEC0AD" />
</div>
<span className="font-semibold">
Conditions générales d’utilisation
</span>
</Link>
<Link href="/" className="flex h-8 items-center gap-5 text-sm">
<div className="flex size-5 items-center justify-center">
<Icons.eye fill="#CEC0AD" />
</div>
<span className="font-semibold">Politique de confidentialité</span>
</Link>
<Link href="/" className="flex h-8 items-center gap-5 text-sm">
<div className="flex size-5 items-center justify-center">
<Icons.legals fill="#CEC0AD" />
</div>
<span className="font-semibold">Mentions légales</span>
</Link>
</section>
<Button isSignOut variant="danger">
Déconnexion
</Button>
<Button variant="dangerFilled">Supprimer mon compte</Button>
</main>
</>
);
};

export default Profil;
13 changes: 13 additions & 0 deletions src/app/(app)/profil/parcours/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import TopBar from "@/components/TopBar";

const Parcours = () => {
return (
<>
<TopBar />
<main>Mes parcours</main>
</>
);
};

export default Parcours;
25 changes: 8 additions & 17 deletions src/app/api/journeys/route.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {
handleException,
handlePrismaException,
} from "@/utils/errorHandlerUtils";
import { handleException } from "@/app/utils/errorHandlerUtils";
import {
getAllJourneys,
registerOrModifyJourney,
} from "@/services/journeyService";
import { BadRequestException } from "@/types/exceptions";
import { JourneyWithoutDates } from "@/types/journey";
import { StepWithoutDates } from "@/types/step";
import { journeyBodySchema } from "@/validators/api/journeySchema";
import { Prisma } from "@prisma/client";
import { NextRequest, NextResponse } from "next/server";

/**
Expand All @@ -34,22 +31,16 @@ export async function POST(request: NextRequest) {
try {
const body = await request.json();
// Parse the body with zod to get the journey and steps
const parsedBody = journeyBodySchema.parse(body);
const journey: JourneyWithoutDates = parsedBody.journey;
const steps: StepWithoutDates[] = parsedBody.steps;
const parsedBody = journeyBodySchema.safeParse(body);
if (parsedBody.error) {
throw new BadRequestException("Invalid request body");
}
const journey: JourneyWithoutDates = body.journey;
const steps: StepWithoutDates[] = body.steps;

const result = await registerOrModifyJourney(null, journey, steps);
return NextResponse.json({ data: result }, { status: 201 });
} catch (error: any) {
if (
error instanceof Prisma.PrismaClientKnownRequestError ||
error instanceof Prisma.PrismaClientUnknownRequestError ||
error instanceof Prisma.PrismaClientRustPanicError ||
error instanceof Prisma.PrismaClientInitializationError ||
error instanceof Prisma.PrismaClientValidationError
) {
return handlePrismaException(error);
}
return handleException(error);
}
}
1 change: 1 addition & 0 deletions src/app/api/steps/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function PUT(
const id: number = Number(params.id);
const body = await request.json();
// Parse the body with zod to get the step
// @ts-ignore
const step: StepWithoutDates = stepBodySchema.parse(body).step;

const result = await registerOrModifyStep(id, step);
Expand Down
1 change: 1 addition & 0 deletions src/app/api/steps/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function POST(request: NextRequest) {
try {
const body = await request.json();
// Parse the body with zod to get the step
// @ts-ignore
const step: StepWithoutDates = stepBodySchema.parse(body).step;

const result = await registerOrModifyStep(null, step);
Expand Down
8 changes: 7 additions & 1 deletion src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
--camel: #a3987e;
--cadetblue: #65878e;
--cadetblue-600: #a3b7bb;
--gray: #191919;
--gray: #252525;
--light-gray: #534e48;
--radius: 6px;

Expand Down Expand Up @@ -65,3 +65,9 @@
@apply bg-background text-foreground;
}
}

@media (min-width: 640px) {
.container {
@apply px-8;
}
}
2 changes: 1 addition & 1 deletion src/components/AddButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const AddButton = ({ action }: AddButtonProps) => {
onClick={() => {
action === "journey" ? showModal() : showModal();
}}
className="fixed bottom-24 right-[20px] cursor-pointer rounded-lg bg-orange p-4 shadow-lg"
className="fixed bottom-24 right-5 cursor-pointer rounded-lg bg-orange p-4 shadow-lg sm:bottom-7 2xl:right-[calc(50%_-_668px)]"
>
<Icons.plus color="#fff" />
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/EventAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ const EventAccordion: React.FC<EventAccordionProps> = ({ events }) => {
<AccordionTrigger className="py-2 text-lg font-medium">
{formatted}
</AccordionTrigger>
<AccordionContent className="space-y-4">
<AccordionContent className="grid grid-cols-1 gap-7 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{groupedEvents[original].map((event) => (
<div key={event.id} className=" rounded-lg border p-4 shadow">
<div key={event.id} className="flex flex-col rounded-lg bg-gray">
<Link href={`/evenements/${event.id}`}>
<Image
src={`${event.image}200`}
Expand Down
1 change: 0 additions & 1 deletion src/components/EventsFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ async function getData() {
const result = await getAllEvents();
return result;
} catch (error: any) {
console.log(error, "error");
handleException(error);
}
}
Expand Down
67 changes: 67 additions & 0 deletions src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,71 @@ export const Icons = {
<path d="M1 13L13 1M13 13L1 1" stroke="#D8552B" strokeWidth="2" />
</svg>
),
check: (props: LucideProps) => (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path d="m10 15.586-3.293-3.293-1.414 1.414L10 18.414l9.707-9.707-1.414-1.414z"></path>
</svg>
),
questionMark: (props: LucideProps) => (
<svg
width="20"
height="20"
viewBox="0 0 20 20"
{...props}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10 0C8.02219 0 6.08879 0.58649 4.4443 1.6853C2.79981 2.78412 1.51809 4.3459 0.761209 6.17316C0.00433284 8.00042 -0.1937 10.0111 0.192152 11.9509C0.578004 13.8907 1.53041 15.6725 2.92894 17.0711C4.32746 18.4696 6.10929 19.422 8.0491 19.8078C9.98891 20.1937 11.9996 19.9957 13.8268 19.2388C15.6541 18.4819 17.2159 17.2002 18.3147 15.5557C19.4135 13.9112 20 11.9778 20 10C19.9972 7.34869 18.9427 4.80678 17.068 2.93202C15.1932 1.05727 12.6513 0.00279983 10 0ZM10 16.1538C9.77179 16.1538 9.54871 16.0862 9.35896 15.9594C9.16921 15.8326 9.02132 15.6524 8.93399 15.4416C8.84666 15.2307 8.82381 14.9987 8.86833 14.7749C8.91285 14.5511 9.02274 14.3455 9.18411 14.1841C9.34548 14.0227 9.55107 13.9128 9.7749 13.8683C9.99872 13.8238 10.2307 13.8467 10.4416 13.934C10.6524 14.0213 10.8326 14.1692 10.9594 14.359C11.0862 14.5487 11.1538 14.7718 11.1538 15C11.1538 15.306 11.0323 15.5995 10.8159 15.8159C10.5995 16.0323 10.306 16.1538 10 16.1538ZM10.7692 11.4692V11.5385C10.7692 11.7425 10.6882 11.9381 10.5439 12.0824C10.3997 12.2266 10.204 12.3077 10 12.3077C9.79599 12.3077 9.60033 12.2266 9.45607 12.0824C9.31182 11.9381 9.23077 11.7425 9.23077 11.5385V10.7692C9.23077 10.5652 9.31182 10.3696 9.45607 10.2253C9.60033 10.081 9.79599 10 10 10C11.2721 10 12.3077 9.13461 12.3077 8.07692C12.3077 7.01923 11.2721 6.15384 10 6.15384C8.72789 6.15384 7.69231 7.01923 7.69231 8.07692V8.46154C7.69231 8.66555 7.61127 8.86121 7.46701 9.00546C7.32275 9.14972 7.12709 9.23077 6.92308 9.23077C6.71907 9.23077 6.52341 9.14972 6.37915 9.00546C6.23489 8.86121 6.15385 8.66555 6.15385 8.46154V8.07692C6.15385 6.16827 7.87885 4.61538 10 4.61538C12.1212 4.61538 13.8462 6.16827 13.8462 8.07692C13.8462 9.74807 12.5231 11.1471 10.7692 11.4692Z"
fill={props.fill}
/>
</svg>
),
file: (props: LucideProps) => (
<svg
{...props}
width="16"
height="20"
viewBox="0 0 16 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M15.7873 5.60962L10.6964 0.225C10.6288 0.153589 10.5485 0.0969631 10.4603 0.0583569C10.372 0.0197506 10.2774 -7.92199e-05 10.1818 2.37845e-07H1.45455C1.06878 2.37845e-07 0.698807 0.162088 0.426026 0.450605C0.153246 0.739123 0 1.13044 0 1.53846V18.4615C0 18.8696 0.153246 19.2609 0.426026 19.5494C0.698807 19.8379 1.06878 20 1.45455 20H14.5455C14.9312 20 15.3012 19.8379 15.574 19.5494C15.8468 19.2609 16 18.8696 16 18.4615V6.15385C16.0001 6.0528 15.9813 5.95273 15.9448 5.85935C15.9083 5.76597 15.8548 5.68111 15.7873 5.60962ZM10.1818 6.15385V1.92308L14.1818 6.15385H10.1818Z"
fill={props.fill}
/>
</svg>
),
eye: (props: LucideProps) => (
<svg
width="21"
height="17"
viewBox="0 0 21 17"
{...props}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.63 7.801C20.6008 7.722 19.895 5.843 18.3258 3.96C16.235 1.451 13.5942 0.125 10.6875 0.125C7.78083 0.125 5.14 1.451 3.04916 3.96C1.47999 5.843 0.770825 7.725 0.744992 7.801C0.707086 7.90331 0.6875 8.01403 0.6875 8.126C0.6875 8.23797 0.707086 8.34869 0.744992 8.451C0.774159 8.53 1.47999 10.408 3.04916 12.291C5.14 14.799 7.78083 16.125 10.6875 16.125C13.5942 16.125 16.235 14.799 18.3258 12.291C19.895 10.408 20.6008 8.53 20.63 8.451C20.6679 8.34869 20.6875 8.23797 20.6875 8.126C20.6875 8.01403 20.6679 7.90331 20.63 7.801ZM10.6875 12.125C10.0282 12.125 9.38376 11.8904 8.8356 11.4509C8.28743 11.0114 7.86019 10.3866 7.6079 9.65573C7.35561 8.92483 7.2896 8.12056 7.41821 7.34464C7.54683 6.56872 7.8643 5.85598 8.33048 5.29657C8.79665 4.73716 9.39059 4.3562 10.0372 4.20186C10.6838 4.04752 11.354 4.12673 11.9631 4.42948C12.5722 4.73223 13.0928 5.24492 13.4591 5.90272C13.8253 6.56052 14.0208 7.33387 14.0208 8.125C14.0208 9.18587 13.6696 10.2033 13.0445 10.9534C12.4194 11.7036 11.5716 12.125 10.6875 12.125Z"
fill={props.fill}
/>
</svg>
),
legals: (props: LucideProps) => (
<svg
width="16"
height="20"
viewBox="0 0 16 20"
{...props}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M14.5455 1.48136H11.2491C10.8405 1.01536 10.3398 0.642516 9.77988 0.387237C9.21997 0.131959 8.61345 0 8 0C7.38656 0 6.78003 0.131959 6.22012 0.387237C5.66021 0.642516 5.15955 1.01536 4.75091 1.48136H1.45455C1.06878 1.48136 0.698807 1.63744 0.426026 1.91528C0.153246 2.19311 0 2.56993 0 2.96285V18.5185C0 18.9114 0.153246 19.2882 0.426026 19.5661C0.698807 19.8439 1.06878 20 1.45455 20H14.5455C14.9312 20 15.3012 19.8439 15.574 19.5661C15.8468 19.2882 16 18.9114 16 18.5185V2.96285C16 2.56993 15.8468 2.19311 15.574 1.91528C15.3012 1.63744 14.9312 1.48136 14.5455 1.48136ZM8 1.48136C8.77154 1.48136 9.51148 1.79353 10.057 2.34919C10.6026 2.90486 10.9091 3.65851 10.9091 4.44434H5.09091C5.09091 3.65851 5.3974 2.90486 5.94296 2.34919C6.48852 1.79353 7.22846 1.48136 8 1.48136ZM10.9091 13.3333H5.09091C4.89802 13.3333 4.71304 13.2552 4.57665 13.1163C4.44026 12.9774 4.36364 12.789 4.36364 12.5925C4.36364 12.3961 4.44026 12.2077 4.57665 12.0688C4.71304 11.9298 4.89802 11.8518 5.09091 11.8518H10.9091C11.102 11.8518 11.287 11.9298 11.4234 12.0688C11.5597 12.2077 11.6364 12.3961 11.6364 12.5925C11.6364 12.789 11.5597 12.9774 11.4234 13.1163C11.287 13.2552 11.102 13.3333 10.9091 13.3333ZM10.9091 10.3703H5.09091C4.89802 10.3703 4.71304 10.2923 4.57665 10.1533C4.44026 10.0144 4.36364 9.82602 4.36364 9.62956C4.36364 9.4331 4.44026 9.24469 4.57665 9.10577C4.71304 8.96686 4.89802 8.88881 5.09091 8.88881H10.9091C11.102 8.88881 11.287 8.96686 11.4234 9.10577C11.5597 9.24469 11.6364 9.4331 11.6364 9.62956C11.6364 9.82602 11.5597 10.0144 11.4234 10.1533C11.287 10.2923 11.102 10.3703 10.9091 10.3703Z"
fill={props.fill}
/>
</svg>
),
};
Loading

0 comments on commit 514b16a

Please sign in to comment.