From 4e40bba0b7f26a1f43e9c4dd2710da54bbe51bd9 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 14 Nov 2025 08:58:23 +0100 Subject: [PATCH 1/5] Update doc composant button --- .../{Button.stories.js => Button.stories.jsx} | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) rename src/stories/{Button.stories.js => Button.stories.jsx} (50%) diff --git a/src/stories/Button.stories.js b/src/stories/Button.stories.jsx similarity index 50% rename from src/stories/Button.stories.js rename to src/stories/Button.stories.jsx index 6438e9e..3f86188 100644 --- a/src/stories/Button.stories.js +++ b/src/stories/Button.stories.jsx @@ -2,25 +2,38 @@ import { fn } from 'storybook/test'; import Button from '../components/ui/button/button.jsx'; -// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export + export default { title: 'UI/Button', component: Button, parameters: { - // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout layout: 'centered', }, - // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs tags: ['autodocs'], - // More on argTypes: https://storybook.js.org/docs/api/argtypes argTypes: { - backgroundColor: { control: 'color' }, + children: { + control: "text", + description: "Texte/Composant à afficher dans le bouton", + }, + variant: { + control: { type: 'select' }, + options: ["primary", "default", "danger", "transparent"], + description: "Style du bouton" + }, + onClick: { + control: "function", + description: "Fonction appelée lors du clique du bouton", + } + }, + + args: { + children: "Button", + variant: "Primary", + onClick: fn() + }, - // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args - args: { onClick: fn() }, }; -// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args export const Primary = { args: { children: "Button", @@ -52,3 +65,11 @@ export const Danger = { onClick: fn(), }, }; + +export const Icon = { + args: { + children: icon, + variant: 'transparent', + onClick: fn(), + } +} \ No newline at end of file From b5bb7b643b53f70fc25a42a5198a1a1689518efe Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Sun, 16 Nov 2025 12:13:30 +0100 Subject: [PATCH 2/5] add of getUserNotifications function --- src/components/Header/Header.jsx | 16 ++++++++++------ src/utils/getUserNotifications.js | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 src/utils/getUserNotifications.js diff --git a/src/components/Header/Header.jsx b/src/components/Header/Header.jsx index c04a7ab..ea9ad80 100644 --- a/src/components/Header/Header.jsx +++ b/src/components/Header/Header.jsx @@ -1,20 +1,24 @@ import styles from "./Header.module.css" import { Link, NavLink } from "react-router"; import { useEffect, useRef, useState } from "react"; +import getUserNotifications from "../../utils/getUserNotifications.js"; function Header() { const [notificationMenu, setnotificationMenu] = useState(false); const [unreadNotification, setunreadNotification] = useState(true); const [mobileMenu, setMobileMenu] = useState(false); + const [notifications, setNotifications] = useState([]); const notificationRef = useRef(null); - const [notifications, setNotifications] = useState([ - "Vous avez un nouveau message !", - "Jean Paul est en attente de validation !", - "Vous avez un nouveau message !" - ]); + useEffect(() => { + async function loadNotifications() { + const notifData = await getUserNotifications(); + setNotifications(notifData || []); + } + + loadNotifications(); const handleClickOutside = (event) => { if ( notificationRef.current && @@ -109,7 +113,7 @@ function Header() { ) : ( notifications.map((notification, index) => (
-

{notification}

+

{notification.content}