Skip to content

Commit

Permalink
Merge pull request #79 from lachouettecoop/feat/remove-week-pattern
Browse files Browse the repository at this point in the history
Feat/remove week pattern
  • Loading branch information
mejjjor authored Nov 21, 2024
2 parents 86fe8fa + 3d8dd63 commit 1ed94de
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 17 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:16-alpine AS builder

RUN mkdir -p /app
WORKDIR /app
COPY . .
RUN yarn install --frozen-lockfile && yarn build

EXPOSE 3000
CMD [ "yarn", "start" ]
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.8'

services:

nginx:
build: .
networks:
default:
traefik_web:
labels:
traefik.enable: "true"
traefik.docker.network: "traefik_web"
traefik.http.routers.planning.entrypoints: "web,websecure"
traefik.http.routers.planning.rule: "Host(`planningtest.lachouettecoop.fr`)"
traefik.http.routers.planning.tls: "true"
traefik.http.routers.planning.tls.certresolver: "myresolver"
traefik.http.services.planning.loadbalancer.server.port: "3000"

networks:
default:
internal: true
driver_opts:
encrypted: 1
traefik_web:
external: true

2 changes: 2 additions & 0 deletions src/components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const Calendar = ({ start, end, list }: Props) => {

if (node.creneauGenerique) {
week.weekId = getWeekId(node.creneauGenerique.frequence)
} else {
week.weekId = "A"
}
})

Expand Down
11 changes: 5 additions & 6 deletions src/components/CalendarDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { formatDateShort } from "src/helpers/date"
type TimeStatus = "past" | "present" | "future"

const WEEK_COLORS: Record<IWeekId, string> = {
A: "#89C7A8",
B: "#638F79",
C: "#3A5447",
D: "#27382F",
A: "#638F79",
B: "#89C7A8",
C: "#27382F",
D: "#3A5447",
}

const Header = styled.div<{ $weekId?: IWeekId }>`
Expand Down Expand Up @@ -49,7 +49,6 @@ interface Props {
const CalendarDay = ({ day, weekId }: Props) => {
const { start, slots } = day
const today = isToday(start)
const monday = start.getDay() === 1 || start.getDate() === 1

return (
<Container
Expand All @@ -60,7 +59,7 @@ const CalendarDay = ({ day, weekId }: Props) => {
}
}}
>
<Header $weekId={weekId}>{monday && weekId && `Semaine ${weekId}`}</Header>
<Header $weekId={weekId}></Header>
<Typography variant="h3">{capitalize(formatDateShort(start))}</Typography>
<List>
{slots.map((slot) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,19 @@ const BottomCaption = styled.div`
padding: 20px 10px;
`

const orderSlotsByDate = (left: Creneau, right: Creneau) => (left.debut > right.debut ? 1 : -1)

const PlanningPage = () => {
const Planning = ({ slots }: { slots: Creneau[] | undefined }) => {
const { user } = useUser<true>()
const [displayPrivacyPolicyDialog, setDisplayPrivacyPolicyDialog] = useState(false)
useEffect(() => {
if (user) setDisplayPrivacyPolicyDialog(!user.affichageDonneesPersonnelles)
}, [user])

const { goBack, goForward, goToday, start, end, data, error, loading } = useDatePlanning()
const { goBack, goForward, goToday, start, end, error, loading } = useDatePlanning()
if (error) {
return <ErrorBlock error={error} />
}

const slots = data?.creneaus.filter(({ horsMag }) => !horsMag).sort(orderSlotsByDate)
// const slots = data?.creneaus.filter(({ horsMag }) => !horsMag).sort(orderSlotsByDate)

return (
<>
Expand Down Expand Up @@ -166,4 +164,4 @@ const PlanningPage = () => {
)
}

export default PlanningPage
export default Planning
2 changes: 2 additions & 0 deletions src/components/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
ArrowBack as ArrowBackIcon,
Home as HomeIcon,
Event as EventIcon,
EventNote as EventNoteIcon,
Storefront as StorefrontIcon,
CardMembership as CardMembershipIcon,
History as HistoryIcon,
Expand Down Expand Up @@ -133,6 +134,7 @@ const ITEMS = [
{ title: "Historique des PIAF", href: "/history", Icon: HistoryIcon, roles: [RoleId.Chouettos] },
{ title: "Groupe MAG", href: "/magasin", Icon: StorefrontIcon, roles: [RoleId.AdminMag] },
{ title: "Groupe BdM", href: "/bdm", Icon: CardMembershipIcon, roles: [RoleId.AdminBdM] },
{ title: "Planning BdM", href: "/planning-bdm", Icon: EventNoteIcon, roles: [RoleId.AdminBdM] },
{
title: "Espace membre",
href: "https://espace-membres.lachouettecoop.fr/page/homepage",
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/planning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Creneau } from "src/types/model"

export const orderSlotsByDate = (left: Creneau, right: Creneau) => (left.debut > right.debut ? 1 : -1)
17 changes: 17 additions & 0 deletions src/pages/authenticated/PlanningBdm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useDatePlanning } from "src/providers/datePlanning"
import { ErrorBlock } from "src/helpers/errors"
import Planning from "src/components/Planning"
import { orderSlotsByDate } from "src/helpers/planning"

const PlanningBdmPage = () => {
const { data, error } = useDatePlanning()
if (error) {
return <ErrorBlock error={error} />
}

const slots = data?.creneaus.filter(({ horsMag }) => horsMag).sort(orderSlotsByDate)

return <Planning slots={slots} />
}

export default PlanningBdmPage
17 changes: 17 additions & 0 deletions src/pages/authenticated/PlanningChouettos.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useDatePlanning } from "src/providers/datePlanning"
import { ErrorBlock } from "src/helpers/errors"
import Planning from "src/components/Planning"
import { orderSlotsByDate } from "src/helpers/planning"

const PlanningBdmPage = () => {
const { data, error } = useDatePlanning()
if (error) {
return <ErrorBlock error={error} />
}

const slots = data?.creneaus.filter(({ horsMag }) => !horsMag).sort(orderSlotsByDate)

return <Planning slots={slots} />
}

export default PlanningBdmPage
6 changes: 4 additions & 2 deletions src/pages/authenticated/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Menu from "src/components/menu"
import MenuBottom from "src/components/menuBottom"

import HomePage from "src/pages/authenticated/Home"
import PlanningPage from "src/pages/authenticated/Planning"
import PlanningChouettosPage from "src/pages/authenticated/PlanningChouettos"
import PlanningBdmPage from "src/pages/authenticated/PlanningBdm"
import ProfilePage from "src/pages/authenticated/Profile"
import ReservePage from "src/pages/authenticated/Reserve"
import MagasinPage from "src/pages/authenticated/Magasin"
Expand Down Expand Up @@ -38,7 +39,8 @@ const Authenticated = () => {
<Content>
<Switch>
<RestrictedRoute path="/home" component={HomePage} roleIds={[RoleId.Chouettos]} redirectionPath="/planning" />
<Route path="/planning" component={PlanningPage} />
<Route path="/planning" component={PlanningChouettosPage} />
<Route path="/planning-bdm" component={PlanningBdmPage} />
<RestrictedRoute
path="/profile"
component={ProfilePage}
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3622,9 +3622,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001208:
version "1.0.30001309"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001309.tgz"
integrity sha512-Pl8vfigmBXXq+/yUz1jUwULeq9xhMJznzdc/xwl4WclDAuebcTHVefpz8lE/bMI+UN7TOkSSe7B7RnZd6+dzjA==
version "1.0.30001680"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz"
integrity sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==

capture-exit@^2.0.0:
version "2.0.0"
Expand Down

0 comments on commit 1ed94de

Please sign in to comment.