Skip to content

Commit 7977c8f

Browse files
Merge pull request #116 from WildCodeSchool/fix_prod
fix prod 3
2 parents cfebeee + 488eca7 commit 7977c8f

File tree

3 files changed

+100
-36
lines changed

3 files changed

+100
-36
lines changed

frontend/src/pages/CreateChallengePage/EcogesturesSelect.tsx

Lines changed: 96 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
21
import { useState } from "react";
32
import { useGetEcogesturesQuery } from "@/generated/graphql-types";
43
import { Button } from "@/components/ui/button";
5-
import { Trash2, ArrowLeft, ArrowRight, Check, ChevronsUpDown } from "lucide-react";
4+
import {
5+
Trash2,
6+
ArrowLeft,
7+
ArrowRight,
8+
Check,
9+
ChevronsUpDown,
10+
} from "lucide-react";
611
import { cn } from "@/lib/utils";
712
import {
813
Command,
914
CommandGroup,
1015
CommandItem,
1116
CommandList,
1217
} from "../../components/ui/command";
13-
import { Popover, PopoverContent, PopoverTrigger } from "../../components/ui/popover";
18+
import {
19+
Popover,
20+
PopoverContent,
21+
PopoverTrigger,
22+
} from "../../components/ui/popover";
1423

1524
const ecogestureDetailStyle = {
16-
backgroundColor: 'white !important',
17-
borderColor: '#e5e7eb !important'
25+
backgroundColor: "white !important",
26+
borderColor: "#e5e7eb !important",
1827
};
1928

2029
function EcogesturesSelect({
@@ -30,14 +39,17 @@ function EcogesturesSelect({
3039
const [showAll, setShowAll] = useState(false);
3140
const maxSelectionToShow = 4;
3241

33-
3442
if (loading) return <p>Chargement...</p>;
3543
if (error) return <p>Erreur lors du chargement</p>;
3644

3745
const ecogestures = data?.getEcogestures?.ecogestures ?? [];
38-
const selectedEco = ecogestures.find((eco) => eco.id.toString() === selectedId);
46+
const selectedEco = ecogestures.find(
47+
(eco) => eco.id.toString() === selectedId,
48+
);
3949

40-
const currentIndex = ecogestures.findIndex((eco) => eco.id.toString() === selectedId);
50+
const currentIndex = ecogestures.findIndex(
51+
(eco) => eco.id.toString() === selectedId,
52+
);
4153
const canGoPrev = currentIndex > 0;
4254
const canGoNext = currentIndex >= 0 && currentIndex < ecogestures.length - 1;
4355
const goPrev = () => {
@@ -70,7 +82,8 @@ function EcogesturesSelect({
7082
onClick={() => setOpenCombobox((prev) => !prev)}
7183
>
7284
{selectedId
73-
? ecogestures.find((eco) => eco.id.toString() === selectedId)?.label
85+
? ecogestures.find((eco) => eco.id.toString() === selectedId)
86+
?.label
7487
: "Sélectionner un écogeste..."}
7588
<ChevronsUpDown className="opacity-50" />
7689
</Button>
@@ -83,7 +96,7 @@ function EcogesturesSelect({
8396
<CommandItem
8497
key={eco.id}
8598
value={eco.id.toString()}
86-
onSelect={(currentValue: string | undefined) => {
99+
onSelect={(currentValue: string) => {
87100
if (currentValue) {
88101
setSelectedId(currentValue);
89102
setOpenCombobox(false);
@@ -94,7 +107,9 @@ function EcogesturesSelect({
94107
<Check
95108
className={cn(
96109
"ml-auto",
97-
selectedId === eco.id.toString() ? "opacity-100" : "opacity-0"
110+
selectedId === eco.id.toString()
111+
? "opacity-100"
112+
: "opacity-0",
98113
)}
99114
/>
100115
</CommandItem>
@@ -107,7 +122,10 @@ function EcogesturesSelect({
107122

108123
{/* Détail de l'écogeste sélectionné */}
109124
{selectedEco && (
110-
<div className="border rounded bg-white p-3 mb-2 w-full max-w-full break-words relative ecogesture-detail-card" style={ecogestureDetailStyle}>
125+
<div
126+
className="border rounded bg-white p-3 mb-2 w-full max-w-full break-words relative ecogesture-detail-card"
127+
style={ecogestureDetailStyle}
128+
>
111129
{/* Flèches de navigation */}
112130
<button
113131
type="button"
@@ -116,7 +134,10 @@ function EcogesturesSelect({
116134
disabled={!canGoPrev}
117135
aria-label="Précédent"
118136
>
119-
<ArrowLeft size={20} className={canGoPrev ? "text-gray-700" : "text-gray-300"} />
137+
<ArrowLeft
138+
size={20}
139+
className={canGoPrev ? "text-gray-700" : "text-gray-300"}
140+
/>
120141
</button>
121142
<button
122143
type="button"
@@ -125,15 +146,26 @@ function EcogesturesSelect({
125146
disabled={!canGoNext}
126147
aria-label="Suivant"
127148
>
128-
<ArrowRight size={20} className={canGoNext ? "text-gray-700" : "text-gray-300"} />
149+
<ArrowRight
150+
size={20}
151+
className={canGoNext ? "text-gray-700" : "text-gray-300"}
152+
/>
129153
</button>
130154
<div className="flex items-center gap-3 mb-2">
131155
{selectedEco.pictureUrl && (
132-
<img src={selectedEco.pictureUrl} alt={selectedEco.label} className="w-10 h-10 object-contain" />
156+
<img
157+
src={selectedEco.pictureUrl}
158+
alt={selectedEco.label}
159+
className="w-10 h-10 object-contain"
160+
/>
133161
)}
134-
<span className="font-semibold text-lg text-black">{selectedEco.label}</span>
162+
<span className="font-semibold text-lg text-black">
163+
{selectedEco.label}
164+
</span>
135165
</div>
136-
<p className="text-sm text-gray-700 mb-2">{selectedEco.description}</p>
166+
<p className="text-sm text-gray-700 mb-2">
167+
{selectedEco.description}
168+
</p>
137169
<ul className="text-xs text-gray-600 list-disc ml-5">
138170
<li>Niveau 1 : {selectedEco.level1Expectation}</li>
139171
<li>Niveau 2 : {selectedEco.level2Expectation}</li>
@@ -145,7 +177,9 @@ function EcogesturesSelect({
145177
disabled={value.includes(selectedEco.id.toString())}
146178
onClick={handleAdd}
147179
>
148-
{value.includes(selectedEco.id.toString()) ? "Déjà sélectionné" : "Ajouter à la liste"}
180+
{value.includes(selectedEco.id.toString())
181+
? "Déjà sélectionné"
182+
: "Ajouter à la liste"}
149183
</Button>
150184
</div>
151185
</div>
@@ -154,29 +188,55 @@ function EcogesturesSelect({
154188

155189
{/* Liste des écogestes sélectionnés */}
156190
<div className="w-full md:w-1/2 ">
157-
<div className="w-full mb-2 p-3 bg-white border rounded-lg shadow-sm" style={ecogestureDetailStyle}>
158-
<div className="text-center font-semibold text-black">Votre sélection</div>
191+
<div
192+
className="w-full mb-2 p-3 bg-white border rounded-lg shadow-sm"
193+
style={ecogestureDetailStyle}
194+
>
195+
<div className="text-center font-semibold text-black">
196+
Votre sélection
197+
</div>
159198
</div>
160199
{value.length > 0 && (
161-
<ul className="flex flex-col gap-2 bg-white p-2 rounded" style={ecogestureDetailStyle}>
162-
{(showAll ? value : value.slice(0, maxSelectionToShow)).map((ecoId) => {
163-
const eco = ecogestures.find((e) => e.id.toString() === ecoId);
164-
if (!eco) return null;
165-
return (
166-
<li key={ecoId} className="flex items-center gap-2 bg-gray-100 rounded px-3 py-2 text-black hover:bg-gray-200">
167-
<span className="flex-1 text-black text-sm">{eco.label}</span>
168-
<Button type="button" size="icon" variant="ghost" onClick={() => handleRemove(ecoId)}>
169-
<Trash2 size={18} className="text-red-500" />
170-
</Button>
171-
</li>
172-
);
173-
})}
200+
<ul
201+
className="flex flex-col gap-2 bg-white p-2 rounded"
202+
style={ecogestureDetailStyle}
203+
>
204+
{(showAll ? value : value.slice(0, maxSelectionToShow)).map(
205+
(ecoId) => {
206+
const eco = ecogestures.find((e) => e.id.toString() === ecoId);
207+
if (!eco) return null;
208+
return (
209+
<li
210+
key={ecoId}
211+
className="flex items-center gap-2 bg-gray-100 rounded px-3 py-2 text-black hover:bg-gray-200"
212+
>
213+
<span className="flex-1 text-black text-sm">
214+
{eco.label}
215+
</span>
216+
<Button
217+
type="button"
218+
size="icon"
219+
variant="ghost"
220+
onClick={() => handleRemove(ecoId)}
221+
>
222+
<Trash2 size={18} className="text-red-500" />
223+
</Button>
224+
</li>
225+
);
226+
},
227+
)}
174228
</ul>
175229
)}
176230
{value.length > maxSelectionToShow && (
177231
<div className="flex justify-center mt-2">
178-
<Button size="sm" type="button" onClick={() => setShowAll(!showAll)}>
179-
{showAll ? "Voir moins" : `Voir plus (${value.length - maxSelectionToShow})`}
232+
<Button
233+
size="sm"
234+
type="button"
235+
onClick={() => setShowAll(!showAll)}
236+
>
237+
{showAll
238+
? "Voir moins"
239+
: `Voir plus (${value.length - maxSelectionToShow})`}
180240
</Button>
181241
</div>
182242
)}
@@ -185,4 +245,4 @@ function EcogesturesSelect({
185245
);
186246
}
187247

188-
export default EcogesturesSelect;
248+
export default EcogesturesSelect;

frontend/src/stores/__tests__/authStore.unit.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe("authStore - Unit Tests", () => {
1414
id: 1,
1515
email: "test@example.com",
1616
username: "testuser",
17+
pictureUrl: null,
1718
};
1819

1920
useAuthStore.getState().setUser(mockUser);
@@ -39,6 +40,7 @@ describe("authStore - Unit Tests", () => {
3940
id: 1,
4041
email: "test@example.com",
4142
username: "testuser",
43+
pictureUrl: null,
4244
});
4345

4446
// Log out
@@ -68,6 +70,7 @@ describe("authStore - Unit Tests", () => {
6870
id: 1,
6971
email: "test@example.com",
7072
username: "testuser",
73+
pictureUrl: null,
7174
};
7275
useAuthStore.getState().setUser(mockUser);
7376
useAuthStore.getState().setAuthLoading(false);

gateway/Dockerfile.prod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM node:lts-alpine AS frontend-builder
22
ARG VITE_API_URL_FROM_CLIENT
33
ARG VITE_CLOUNDINARY_CLOUD_NAME
44
ARG VITE_CLOUNDINARY_UPLOAD_PRESET
5+
56
WORKDIR /app
67
COPY ./frontend/package*.json ./
78
RUN npm ci

0 commit comments

Comments
 (0)