Merge branch 'dev' into 'features/eventsPage'
# Conflicts: # src/index.css # vite.config.js
This commit is contained in:
@@ -1,20 +1,24 @@
|
|||||||
import styles from "./Header.module.css"
|
import styles from "./Header.module.css"
|
||||||
import { Link, NavLink } from "react-router";
|
import { Link, NavLink } from "react-router";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import getUserNotifications from "../../utils/getUserNotifications.js";
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
const [notificationMenu, setnotificationMenu] = useState(false);
|
const [notificationMenu, setnotificationMenu] = useState(false);
|
||||||
const [unreadNotification, setunreadNotification] = useState(true);
|
const [unreadNotification, setunreadNotification] = useState(true);
|
||||||
const [mobileMenu, setMobileMenu] = useState(false);
|
const [mobileMenu, setMobileMenu] = useState(false);
|
||||||
|
const [notifications, setNotifications] = useState([]);
|
||||||
const notificationRef = useRef(null);
|
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(() => {
|
useEffect(() => {
|
||||||
|
async function loadNotifications() {
|
||||||
|
const notifData = await getUserNotifications();
|
||||||
|
setNotifications(notifData || []);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadNotifications();
|
||||||
const handleClickOutside = (event) => {
|
const handleClickOutside = (event) => {
|
||||||
if (
|
if (
|
||||||
notificationRef.current &&
|
notificationRef.current &&
|
||||||
@@ -109,7 +113,7 @@ function Header() {
|
|||||||
) : (
|
) : (
|
||||||
notifications.map((notification, index) => (
|
notifications.map((notification, index) => (
|
||||||
<div className={styles.notification} key={index}>
|
<div className={styles.notification} key={index}>
|
||||||
<p>{notification}</p>
|
<p>{notification.content}</p>
|
||||||
<button
|
<button
|
||||||
className={styles.closeBtn}
|
className={styles.closeBtn}
|
||||||
onClick={() => setNotifications(prev => prev.filter((_, i) => i !== index))}
|
onClick={() => setNotifications(prev => prev.filter((_, i) => i !== index))}
|
||||||
|
|||||||
@@ -10,9 +10,6 @@
|
|||||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
/* color-scheme: light dark;
|
|
||||||
color: rgba(255, 255, 255, 0.87);
|
|
||||||
background-color: #242424;*/
|
|
||||||
|
|
||||||
font-synthesis: none;
|
font-synthesis: none;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
@@ -25,7 +22,6 @@
|
|||||||
.content {
|
.content {
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
min-height: 100vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,25 +2,38 @@ import { fn } from 'storybook/test';
|
|||||||
|
|
||||||
import Button from '../components/ui/button/button.jsx';
|
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 {
|
export default {
|
||||||
title: 'UI/Button',
|
title: 'UI/Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
parameters: {
|
parameters: {
|
||||||
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
||||||
layout: 'centered',
|
layout: 'centered',
|
||||||
},
|
},
|
||||||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
||||||
tags: ['autodocs'],
|
tags: ['autodocs'],
|
||||||
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
||||||
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 = {
|
export const Primary = {
|
||||||
args: {
|
args: {
|
||||||
children: "Button",
|
children: "Button",
|
||||||
@@ -52,3 +65,11 @@ export const Danger = {
|
|||||||
onClick: fn(),
|
onClick: fn(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const Icon = {
|
||||||
|
args: {
|
||||||
|
children: <img src={"/src/assets/person.svg"} alt="icon" />,
|
||||||
|
variant: 'transparent',
|
||||||
|
onClick: fn(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
export default async function getUserNotifications() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
'http://localhost:8000/api/users/1/notifications',
|
||||||
|
{
|
||||||
|
method: 'GET',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const data = await response.json();
|
||||||
|
return data.data;
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Erreur :", err);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -4,7 +4,7 @@ export default async function login(email, password) {
|
|||||||
const csrfToken = await getXSRFToken();
|
const csrfToken = await getXSRFToken();
|
||||||
|
|
||||||
|
|
||||||
await fetch('http://localhost:8000/api/login', {
|
await fetch('http://localhost:8000/api/users/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
+25
-25
@@ -11,29 +11,29 @@ const dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(file
|
|||||||
|
|
||||||
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
|
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
base: "/",
|
base: '/',
|
||||||
test: {
|
test: {
|
||||||
projects: [{
|
projects: [{
|
||||||
extends: true,
|
extends: true,
|
||||||
plugins: [
|
plugins: [
|
||||||
// The plugin will run tests for the stories defined in your Storybook config
|
// The plugin will run tests for the stories defined in your Storybook config
|
||||||
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
||||||
storybookTest({
|
storybookTest({
|
||||||
configDir: path.join(dirname, '.storybook')
|
configDir: path.join(dirname, '.storybook')
|
||||||
})],
|
})],
|
||||||
test: {
|
test: {
|
||||||
name: 'storybook',
|
name: 'storybook',
|
||||||
browser: {
|
browser: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
headless: true,
|
headless: true,
|
||||||
provider: playwright({}),
|
provider: playwright({}),
|
||||||
instances: [{
|
instances: [{
|
||||||
browser: 'chromium'
|
browser: 'chromium'
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
setupFiles: ['.storybook/vitest.setup.js']
|
setupFiles: ['.storybook/vitest.setup.js']
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user