Skip to content
Snippets Groups Projects
Commit a75ef609 authored by Fatih20's avatar Fatih20
Browse files

Initial work on gym pages.

parent 0364ac65
Branches
Tags
No related merge requests found
VITE_NODE_JS_API=http://localhost:3000 VITE_NODE_JS_API=http://localhost:3000
VITE_NODE_JS_KEY=mbdmatkul4sks VITE_NODE_JS_KEY=mbdmatkul4sks
VITE_GYM_MEDIA_URL=http://localhost:8000/gym
...@@ -13,7 +13,8 @@ import HomeLayout from "@/components/HomeLayout"; ...@@ -13,7 +13,8 @@ import HomeLayout from "@/components/HomeLayout";
import Register from "@/pages/Register"; import Register from "@/pages/Register";
import UserProvider from "@/utils/context/AuthProvider"; import UserProvider from "@/utils/context/AuthProvider";
import Profile from "@/pages/Profile"; import Profile from "@/pages/Profile";
import Gym from "@/pages/Gym"; import Gym from "@/pages/gym/Gym";
import GymIndividual from "@/pages/gym/GymIndividual";
const queryClient = new QueryClient(); const queryClient = new QueryClient();
const router = createBrowserRouter( const router = createBrowserRouter(
...@@ -23,7 +24,8 @@ const router = createBrowserRouter( ...@@ -23,7 +24,8 @@ const router = createBrowserRouter(
<Route path="" element={<Home />} /> <Route path="" element={<Home />} />
<Route path="/profile" element={<Profile />} /> <Route path="/profile" element={<Profile />} />
<Route path="/applications" element={<Home />} /> <Route path="/applications" element={<Home />} />
<Route path="/gyms" element={<Gym />} /> <Route path="/gyms" element={<Gym />}></Route>
<Route path="/gyms/:id" element={<GymIndividual />} />
</Route> </Route>
<Route element={<HomeLayout />}> <Route element={<HomeLayout />}>
<Route path="/login" element={<Login />} /> <Route path="/login" element={<Login />} />
......
import config from "@/utils/config";
import { GymReturned } from "@/utils/validationSchema/gym";
import React from "react";
import { Link } from "react-router-dom";
function GymCard({
gym: { averageRating, cityName, monthlyPrice, name, pictureId, id },
}: {
gym: GymReturned;
}) {
return (
<Link to={`./${id}`}>
<article className="flex flex-col rounded-lg items-start justify-start bg-slate-600 text-white font-normal gap-2">
<img
src={`${config.GYM_MEDIA_URL}/${pictureId}.jpg`}
className="w-full rounded-t-lg self-center"
/>
<div className="flex flex-col items-start justify-start px-4 pb-4">
<h3>{name}</h3>
<p>{cityName}</p>
<p>{`${averageRating} stars`}</p>
<p>{`${monthlyPrice}/month`}</p>
</div>
</article>
</Link>
);
}
export default GymCard;
import GymCard from "@/components/gym/GymCard";
import { useAllGyms } from "@/utils/context/GymProvider"; import { useAllGyms } from "@/utils/context/GymProvider";
import React, { useEffect } from "react"; import { useEffect } from "react";
function Gym() { function Gym() {
const { allGyms, allGymsStatus } = useAllGyms(); const { allGyms, allGymsStatus } = useAllGyms();
...@@ -12,10 +13,12 @@ function Gym() { ...@@ -12,10 +13,12 @@ function Gym() {
} }
return ( return (
<div> <div className="w-full flex flex-col items-center justify-start py-4 lg:py-6">
{allGyms.map(({ id }) => ( <div className="grid gap-4 lg:gap-6 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 max-w-7xl">
<p>{id}</p> {allGyms.map((gym) => (
))} <GymCard gym={gym} key={gym.id} />
))}
</div>
</div> </div>
); );
} }
......
import { useParams } from "react-router-dom";
function GymIndividual() {
const { id } = useParams();
return <div>{id}</div>;
}
export default GymIndividual;
const config = { const config = {
NODE_JS_API: import.meta.env.VITE_NODE_JS_API as string, NODE_JS_API: import.meta.env.VITE_NODE_JS_API as string,
NODE_JS_KEY: import.meta.env.VITE_NODE_JS_KEY as string, NODE_JS_KEY: import.meta.env.VITE_NODE_JS_KEY as string,
GYM_MEDIA_URL: import.meta.env.VITE_GYM_MEDIA_URL as string,
}; };
export default config; export default config;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment