Migrate remaining Tailwind utilities to v4 names and apply formatting; center auth form elements and unify the CoHaiSe Cloud branding header; use the activity icon for audio file placeholders. --------- Co-authored-by: xEsiah <[email protected]> Reviewed-on: #24 Reviewed-by: Esiah <[email protected]> Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #24.
This commit is contained in:
@@ -1,4 +1,10 @@
|
|||||||
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
import {
|
||||||
|
createContext,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
import { NavLink, Outlet } from "react-router-dom";
|
import { NavLink, Outlet } from "react-router-dom";
|
||||||
import { cn } from "../ui/index.js";
|
import { cn } from "../ui/index.js";
|
||||||
import { useSession } from "../lib/session.js";
|
import { useSession } from "../lib/session.js";
|
||||||
@@ -41,7 +47,11 @@ const ADMIN_NAV: NavItem[] = [
|
|||||||
{ to: "/admin/audit", label: "Journal", icon: ActivityIcon },
|
{ to: "/admin/audit", label: "Journal", icon: ActivityIcon },
|
||||||
];
|
];
|
||||||
|
|
||||||
const ACCOUNT_NAV: NavItem = { to: "/profile", label: "Mon compte", icon: SettingsIcon };
|
const ACCOUNT_NAV: NavItem = {
|
||||||
|
to: "/profile",
|
||||||
|
label: "Mon compte",
|
||||||
|
icon: SettingsIcon,
|
||||||
|
};
|
||||||
|
|
||||||
const navClass = ({ isActive }: { isActive: boolean }) =>
|
const navClass = ({ isActive }: { isActive: boolean }) =>
|
||||||
cn(
|
cn(
|
||||||
@@ -78,7 +88,11 @@ export const AppShell = () => {
|
|||||||
const allNav = [...NAV, ...(isAdmin ? ADMIN_NAV : []), ACCOUNT_NAV];
|
const allNav = [...NAV, ...(isAdmin ? ADMIN_NAV : []), ACCOUNT_NAV];
|
||||||
|
|
||||||
const brand = (
|
const brand = (
|
||||||
<NavLink to="/files" className="flex items-center gap-2" onClick={() => setMenuOpen(false)}>
|
<NavLink
|
||||||
|
to="/files"
|
||||||
|
className="flex items-center gap-2"
|
||||||
|
onClick={() => setMenuOpen(false)}
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
src="/icon.png"
|
src="/icon.png"
|
||||||
alt=""
|
alt=""
|
||||||
@@ -99,7 +113,12 @@ export const AppShell = () => {
|
|||||||
const renderLink = (item: NavItem) => {
|
const renderLink = (item: NavItem) => {
|
||||||
const Icon = item.icon;
|
const Icon = item.icon;
|
||||||
return (
|
return (
|
||||||
<NavLink key={item.to} to={item.to} className={navClass} onClick={() => setMenuOpen(false)}>
|
<NavLink
|
||||||
|
key={item.to}
|
||||||
|
to={item.to}
|
||||||
|
className={navClass}
|
||||||
|
onClick={() => setMenuOpen(false)}
|
||||||
|
>
|
||||||
<Icon className="h-4 w-4" />
|
<Icon className="h-4 w-4" />
|
||||||
{t(item.label)}
|
{t(item.label)}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
@@ -107,7 +126,9 @@ export const AppShell = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageHeaderContext.Provider value={{ header: pageHeader, setHeader: setPageHeader }}>
|
<PageHeaderContext.Provider
|
||||||
|
value={{ header: pageHeader, setHeader: setPageHeader }}
|
||||||
|
>
|
||||||
<div className="relative grid h-dvh grid-cols-[auto_1fr] grid-rows-[auto_1fr] overflow-hidden bg-background">
|
<div className="relative grid h-dvh grid-cols-[auto_1fr] grid-rows-[auto_1fr] overflow-hidden bg-background">
|
||||||
<ColorBendsBackdrop variant="shell" />
|
<ColorBendsBackdrop variant="shell" />
|
||||||
|
|
||||||
@@ -117,11 +138,17 @@ export const AppShell = () => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="text-muted-foreground lg:hidden"
|
className="text-muted-foreground lg:hidden"
|
||||||
aria-label={menuOpen ? t("Fermer le menu") : t("Ouvrir le menu")}
|
aria-label={
|
||||||
|
menuOpen ? t("Fermer le menu") : t("Ouvrir le menu")
|
||||||
|
}
|
||||||
aria-expanded={menuOpen}
|
aria-expanded={menuOpen}
|
||||||
onClick={() => setMenuOpen((value) => !value)}
|
onClick={() => setMenuOpen((value) => !value)}
|
||||||
>
|
>
|
||||||
{menuOpen ? <CloseIcon className="h-5 w-5" /> : <MenuIcon className="h-5 w-5" />}
|
{menuOpen ? (
|
||||||
|
<CloseIcon className="h-5 w-5" />
|
||||||
|
) : (
|
||||||
|
<MenuIcon className="h-5 w-5" />
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
{brand}
|
{brand}
|
||||||
</div>
|
</div>
|
||||||
@@ -149,7 +176,6 @@ export const AppShell = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<aside className="relative z-40 col-start-1 row-start-2 hidden w-60 flex-col gap-1 overflow-y-auto border-r border-border/50 bg-surface/70 p-3 backdrop-blur-md lg:flex">
|
<aside className="relative z-40 col-start-1 row-start-2 hidden w-60 flex-col gap-1 overflow-y-auto border-r border-border/50 bg-surface/70 p-3 backdrop-blur-md lg:flex">
|
||||||
@@ -167,7 +193,11 @@ export const AppShell = () => {
|
|||||||
|
|
||||||
{menuOpen ? (
|
{menuOpen ? (
|
||||||
<div className="lg:hidden">
|
<div className="lg:hidden">
|
||||||
<div className="fixed inset-0 z-40 bg-black/50 backdrop-blur-sm" onClick={() => setMenuOpen(false)} aria-hidden="true" />
|
<div
|
||||||
|
className="fixed inset-0 z-40 bg-black/50 backdrop-blur-sm"
|
||||||
|
onClick={() => setMenuOpen(false)}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
<nav className="fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-lg transition-transform duration-300 sm:absolute sm:inset-y-0 sm:left-0 sm:w-72 sm:inset-x-auto">
|
<nav className="fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-lg transition-transform duration-300 sm:absolute sm:inset-y-0 sm:left-0 sm:w-72 sm:inset-x-auto">
|
||||||
<div className="flex items-center justify-between border-b border-border/50 px-4 py-3">
|
<div className="flex items-center justify-between border-b border-border/50 px-4 py-3">
|
||||||
{brand}
|
{brand}
|
||||||
@@ -190,8 +220,10 @@ export const AppShell = () => {
|
|||||||
<div className="relative z-10 col-start-2 row-start-2 min-h-0 overflow-hidden">
|
<div className="relative z-10 col-start-2 row-start-2 min-h-0 overflow-hidden">
|
||||||
<div className="h-full w-full bg-surface/30 backdrop-blur-lg">
|
<div className="h-full w-full bg-surface/30 backdrop-blur-lg">
|
||||||
<div className="flex h-full flex-col">
|
<div className="flex h-full flex-col">
|
||||||
{pageHeader ? <div className="relative z-30 shrink-0">{pageHeader}</div> : null}
|
{pageHeader ? (
|
||||||
<main className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 pb-6 pt-4 [scrollbar-gutter:stable]">
|
<div className="relative z-30 shrink-0">{pageHeader}</div>
|
||||||
|
) : null}
|
||||||
|
<main className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 pb-6 pt-4 scrollbar-gutter-stable">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const AuthLayout = () => (
|
|||||||
<ColorBendsBackdrop variant="auth" />
|
<ColorBendsBackdrop variant="auth" />
|
||||||
<div
|
<div
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className="pointer-events-none absolute inset-0 bg-gradient-to-b from-background/10 via-background/40 to-background/80 dark:from-background/25 dark:via-background/50 dark:to-background/85"
|
className="pointer-events-none absolute inset-0 bg-linear-to-b from-background/10 via-background/40 to-background/80 dark:from-background/25 dark:via-background/50 dark:to-background/85"
|
||||||
/>
|
/>
|
||||||
<div className="relative z-10 flex w-full justify-center">
|
<div className="relative z-10 flex w-full justify-center">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ const POLL_MEMBERS_MS = 30_000;
|
|||||||
const GROUP_WINDOW_MS = 5 * 60 * 1000;
|
const GROUP_WINDOW_MS = 5 * 60 * 1000;
|
||||||
|
|
||||||
const timeOf = (value: string): string =>
|
const timeOf = (value: string): string =>
|
||||||
new Date(value).toLocaleTimeString(getLocale(), { hour: "2-digit", minute: "2-digit" });
|
new Date(value).toLocaleTimeString(getLocale(), {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
});
|
||||||
|
|
||||||
const dayOf = (value: string): string =>
|
const dayOf = (value: string): string =>
|
||||||
new Date(value).toLocaleDateString(getLocale(), {
|
new Date(value).toLocaleDateString(getLocale(), {
|
||||||
@@ -56,7 +59,8 @@ const isSameDay = (a: string, b: string): boolean =>
|
|||||||
const fullName = (
|
const fullName = (
|
||||||
member: { first_name: string | null; last_name: string | null },
|
member: { first_name: string | null; last_name: string | null },
|
||||||
fallback: string,
|
fallback: string,
|
||||||
): string => `${member.first_name ?? ""} ${member.last_name ?? ""}`.trim() || fallback;
|
): string =>
|
||||||
|
`${member.first_name ?? ""} ${member.last_name ?? ""}`.trim() || fallback;
|
||||||
|
|
||||||
const MAX_ID = (list: ChatMessage[]): number =>
|
const MAX_ID = (list: ChatMessage[]): number =>
|
||||||
list.reduce((max, message) => Math.max(max, message.id), 0);
|
list.reduce((max, message) => Math.max(max, message.id), 0);
|
||||||
@@ -72,7 +76,13 @@ export interface ChatFolder {
|
|||||||
* admin n'ouvre aucun acces supplementaire) ; le serveur reevalue cet acces a
|
* admin n'ouvre aucun acces supplementaire) ; le serveur reevalue cet acces a
|
||||||
* chaque requete, l'interface ne fait que l'afficher.
|
* chaque requete, l'interface ne fait que l'afficher.
|
||||||
*/
|
*/
|
||||||
export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: () => void }) => {
|
export const FolderChat = ({
|
||||||
|
folder,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
folder: ChatFolder;
|
||||||
|
onClose: () => void;
|
||||||
|
}) => {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { user } = useSession();
|
const { user } = useSession();
|
||||||
const confirm = useConfirm();
|
const confirm = useConfirm();
|
||||||
@@ -126,8 +136,13 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
// d'epinglage : on ne remplace que si la version recue est plus
|
// d'epinglage : on ne remplace que si la version recue est plus
|
||||||
// recente, pour ne pas ecraser une edition locale toute recente.
|
// recente, pour ne pas ecraser une edition locale toute recente.
|
||||||
const knownEdited = known.edited_at ? Date.parse(known.edited_at) : 0;
|
const knownEdited = known.edited_at ? Date.parse(known.edited_at) : 0;
|
||||||
const incomingEdited = message.edited_at ? Date.parse(message.edited_at) : 0;
|
const incomingEdited = message.edited_at
|
||||||
if (incomingEdited > knownEdited || message.is_pinned !== known.is_pinned) {
|
? Date.parse(message.edited_at)
|
||||||
|
: 0;
|
||||||
|
if (
|
||||||
|
incomingEdited > knownEdited ||
|
||||||
|
message.is_pinned !== known.is_pinned
|
||||||
|
) {
|
||||||
index.set(message.id, { ...known, ...message });
|
index.set(message.id, { ...known, ...message });
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -169,7 +184,11 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
setError(null);
|
setError(null);
|
||||||
} catch (caught) {
|
} catch (caught) {
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
setError(caught instanceof ApiError ? caught.message : t("Chargement impossible."));
|
setError(
|
||||||
|
caught instanceof ApiError
|
||||||
|
? caught.message
|
||||||
|
: t("Chargement impossible."),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
if (active) {
|
if (active) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -189,7 +208,12 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
if (document.hidden) return;
|
if (document.hidden) return;
|
||||||
try {
|
try {
|
||||||
const [result, pinResult] = await Promise.all([
|
const [result, pinResult] = await Promise.all([
|
||||||
api.chatMessages(folderId, lastIdRef.current, 100, editedSinceRef.current),
|
api.chatMessages(
|
||||||
|
folderId,
|
||||||
|
lastIdRef.current,
|
||||||
|
100,
|
||||||
|
editedSinceRef.current,
|
||||||
|
),
|
||||||
api.chatPins(folderId),
|
api.chatPins(folderId),
|
||||||
]);
|
]);
|
||||||
// Le curseur avance avec la reponse : le serveur le calcule avant la
|
// Le curseur avance avec la reponse : le serveur le calcule avant la
|
||||||
@@ -236,7 +260,8 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
const onScroll = () => {
|
const onScroll = () => {
|
||||||
const node = scrollRef.current;
|
const node = scrollRef.current;
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
stickToBottomRef.current = node.scrollHeight - node.scrollTop - node.clientHeight < 80;
|
stickToBottomRef.current =
|
||||||
|
node.scrollHeight - node.scrollTop - node.clientHeight < 80;
|
||||||
};
|
};
|
||||||
|
|
||||||
const send = async (event: FormEvent) => {
|
const send = async (event: FormEvent) => {
|
||||||
@@ -251,7 +276,11 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
mergeMessages([message]);
|
mergeMessages([message]);
|
||||||
setDraft("");
|
setDraft("");
|
||||||
} catch (caught) {
|
} catch (caught) {
|
||||||
setError(caught instanceof ApiError ? caught.message : t("Envoi du message impossible."));
|
setError(
|
||||||
|
caught instanceof ApiError
|
||||||
|
? caught.message
|
||||||
|
: t("Envoi du message impossible."),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setSending(false);
|
setSending(false);
|
||||||
}
|
}
|
||||||
@@ -270,11 +299,17 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
setDeletingId(message.id);
|
setDeletingId(message.id);
|
||||||
try {
|
try {
|
||||||
await api.chatDeleteMessage(folderId, message.id);
|
await api.chatDeleteMessage(folderId, message.id);
|
||||||
setMessages((previous) => previous.filter((item) => item.id !== message.id));
|
setMessages((previous) =>
|
||||||
|
previous.filter((item) => item.id !== message.id),
|
||||||
|
);
|
||||||
// Un message retire disparait aussi des epingles.
|
// Un message retire disparait aussi des epingles.
|
||||||
setPins((previous) => previous.filter((item) => item.id !== message.id));
|
setPins((previous) => previous.filter((item) => item.id !== message.id));
|
||||||
} catch (caught) {
|
} catch (caught) {
|
||||||
setError(caught instanceof ApiError ? caught.message : t("Suppression impossible."));
|
setError(
|
||||||
|
caught instanceof ApiError
|
||||||
|
? caught.message
|
||||||
|
: t("Suppression impossible."),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setDeletingId(null);
|
setDeletingId(null);
|
||||||
}
|
}
|
||||||
@@ -296,14 +331,24 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
setSavingEdit(true);
|
setSavingEdit(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
const { message: updated } = await api.chatEditMessage(folderId, message.id, body);
|
const { message: updated } = await api.chatEditMessage(
|
||||||
|
folderId,
|
||||||
|
message.id,
|
||||||
|
body,
|
||||||
|
);
|
||||||
mergeMessages([updated]);
|
mergeMessages([updated]);
|
||||||
setPins((previous) =>
|
setPins((previous) =>
|
||||||
previous.map((item) => (item.id === updated.id ? { ...item, ...updated } : item)),
|
previous.map((item) =>
|
||||||
|
item.id === updated.id ? { ...item, ...updated } : item,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
} catch (caught) {
|
} catch (caught) {
|
||||||
setError(caught instanceof ApiError ? caught.message : t("Modification impossible."));
|
setError(
|
||||||
|
caught instanceof ApiError
|
||||||
|
? caught.message
|
||||||
|
: t("Modification impossible."),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setSavingEdit(false);
|
setSavingEdit(false);
|
||||||
}
|
}
|
||||||
@@ -326,13 +371,19 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
// veut voir ce qu'il vient de mettre de cote.
|
// veut voir ce qu'il vient de mettre de cote.
|
||||||
if (pinned) setPinsOpen(true);
|
if (pinned) setPinsOpen(true);
|
||||||
} catch (caught) {
|
} catch (caught) {
|
||||||
setError(caught instanceof ApiError ? caught.message : t("Épinglage impossible."));
|
setError(
|
||||||
|
caught instanceof ApiError
|
||||||
|
? caught.message
|
||||||
|
: t("Épinglage impossible."),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setPinningId(null);
|
setPinningId(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onComposerKeyDown = (event: ReactKeyboardEvent<HTMLTextAreaElement>) => {
|
const onComposerKeyDown = (
|
||||||
|
event: ReactKeyboardEvent<HTMLTextAreaElement>,
|
||||||
|
) => {
|
||||||
if (event.key === "Enter" && !event.shiftKey) {
|
if (event.key === "Enter" && !event.shiftKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.currentTarget.form?.requestSubmit();
|
event.currentTarget.form?.requestSubmit();
|
||||||
@@ -343,12 +394,14 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
() =>
|
() =>
|
||||||
messages.map((message, index) => {
|
messages.map((message, index) => {
|
||||||
const previous = index > 0 ? messages[index - 1] : null;
|
const previous = index > 0 ? messages[index - 1] : null;
|
||||||
const newDay = !previous || !isSameDay(previous.created_at, message.created_at);
|
const newDay =
|
||||||
|
!previous || !isSameDay(previous.created_at, message.created_at);
|
||||||
const continuation =
|
const continuation =
|
||||||
!newDay &&
|
!newDay &&
|
||||||
previous !== null &&
|
previous !== null &&
|
||||||
previous.user_id === message.user_id &&
|
previous.user_id === message.user_id &&
|
||||||
new Date(message.created_at).getTime() - new Date(previous.created_at).getTime() <
|
new Date(message.created_at).getTime() -
|
||||||
|
new Date(previous.created_at).getTime() <
|
||||||
GROUP_WINDOW_MS;
|
GROUP_WINDOW_MS;
|
||||||
const own = message.user_id === user?.id;
|
const own = message.user_id === user?.id;
|
||||||
const canDelete = own;
|
const canDelete = own;
|
||||||
@@ -366,7 +419,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
<aside
|
<aside
|
||||||
className={cn(
|
className={cn(
|
||||||
"absolute inset-y-0 left-0 z-20 flex w-64 flex-col border-r border-border bg-surface transition-transform md:static md:z-auto md:translate-x-0",
|
"absolute inset-y-0 left-0 z-20 flex w-64 flex-col border-r border-border bg-surface transition-transform md:static md:z-auto md:translate-x-0",
|
||||||
membersOpen ? "translate-x-0 shadow-lg md:shadow-none" : "-translate-x-full",
|
membersOpen
|
||||||
|
? "translate-x-0 shadow-lg md:shadow-none"
|
||||||
|
: "-translate-x-full",
|
||||||
)}
|
)}
|
||||||
aria-label={t("Membres du dossier")}
|
aria-label={t("Membres du dossier")}
|
||||||
>
|
>
|
||||||
@@ -374,11 +429,16 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
<span className="font-display text-xs font-semibold uppercase tracking-label text-foreground">
|
<span className="font-display text-xs font-semibold uppercase tracking-label text-foreground">
|
||||||
{t("Membres")}
|
{t("Membres")}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-subtle-foreground">{members.length}</span>
|
<span className="text-xs text-subtle-foreground">
|
||||||
|
{members.length}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<ul className="min-h-0 flex-1 overflow-y-auto p-2">
|
<ul className="min-h-0 flex-1 overflow-y-auto p-2">
|
||||||
{members.map((member) => (
|
{members.map((member) => (
|
||||||
<li key={member.id} className="flex items-center gap-3 rounded-md px-2 py-2">
|
<li
|
||||||
|
key={member.id}
|
||||||
|
className="flex items-center gap-3 rounded-md px-2 py-2"
|
||||||
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
userId={member.id}
|
userId={member.id}
|
||||||
firstName={member.first_name}
|
firstName={member.first_name}
|
||||||
@@ -391,7 +451,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
<p className="flex items-center gap-1.5 truncate text-xs font-medium text-foreground">
|
<p className="flex items-center gap-1.5 truncate text-xs font-medium text-foreground">
|
||||||
{fullName(member, t("Compte supprimé"))}
|
{fullName(member, t("Compte supprimé"))}
|
||||||
{member.is_self ? (
|
{member.is_self ? (
|
||||||
<span className="text-subtle-foreground">{t("(vous)")}</span>
|
<span className="text-subtle-foreground">
|
||||||
|
{t("(vous)")}
|
||||||
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</p>
|
</p>
|
||||||
<p className="truncate text-[0.6875rem] text-subtle-foreground">
|
<p className="truncate text-[0.6875rem] text-subtle-foreground">
|
||||||
@@ -402,7 +464,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
: t("Jamais connecté")}
|
: t("Jamais connecté")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{member.role_slug === "admin" ? <Badge tone="accent">Admin</Badge> : null}
|
{member.role_slug === "admin" ? (
|
||||||
|
<Badge tone="accent">Admin</Badge>
|
||||||
|
) : null}
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -421,7 +485,11 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="text-muted-foreground md:hidden"
|
className="text-muted-foreground md:hidden"
|
||||||
aria-label={membersOpen ? t("Masquer les membres") : t("Afficher les membres")}
|
aria-label={
|
||||||
|
membersOpen
|
||||||
|
? t("Masquer les membres")
|
||||||
|
: t("Afficher les membres")
|
||||||
|
}
|
||||||
aria-expanded={membersOpen}
|
aria-expanded={membersOpen}
|
||||||
onClick={() => setMembersOpen((value) => !value)}
|
onClick={() => setMembersOpen((value) => !value)}
|
||||||
>
|
>
|
||||||
@@ -484,7 +552,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
{timeOf(pin.created_at)}
|
{timeOf(pin.created_at)}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p className="mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground">
|
<p className="mt-1 whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground">
|
||||||
{pin.body}
|
{pin.body}
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
@@ -514,144 +582,168 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
) : (
|
) : (
|
||||||
<ol className="flex flex-col gap-1">
|
<ol className="flex flex-col gap-1">
|
||||||
{rendered.map(
|
{rendered.map(
|
||||||
({ message, newDay, continuation, own, canDelete, canEdit }) => (
|
({
|
||||||
<li key={message.id}>
|
message,
|
||||||
{newDay ? (
|
newDay,
|
||||||
<div className="my-3 flex items-center gap-3" role="separator">
|
continuation,
|
||||||
<span className="h-px flex-1 bg-border" />
|
own,
|
||||||
<span className="font-display text-[0.625rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
canDelete,
|
||||||
{dayOf(message.created_at)}
|
canEdit,
|
||||||
</span>
|
}) => (
|
||||||
<span className="h-px flex-1 bg-border" />
|
<li key={message.id}>
|
||||||
</div>
|
{newDay ? (
|
||||||
) : null}
|
<div
|
||||||
<div
|
className="my-3 flex items-center gap-3"
|
||||||
className={cn(
|
role="separator"
|
||||||
"group flex items-start gap-3 rounded-md px-2 py-1.5 backdrop-blur-sm transition-colors hover:bg-surface/50",
|
>
|
||||||
continuation && "mt-0",
|
<span className="h-px flex-1 bg-border" />
|
||||||
)}
|
<span className="font-display text-[0.625rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||||
>
|
{dayOf(message.created_at)}
|
||||||
{continuation ? (
|
</span>
|
||||||
<span className="w-9 shrink-0" aria-hidden="true" />
|
<span className="h-px flex-1 bg-border" />
|
||||||
) : (
|
</div>
|
||||||
<Avatar
|
) : null}
|
||||||
userId={message.user_id ?? message.first_name ?? "unknown"}
|
<div
|
||||||
firstName={message.first_name ?? "?"}
|
className={cn(
|
||||||
lastName={message.last_name ?? ""}
|
"group flex items-start gap-3 rounded-md px-2 py-1.5 backdrop-blur-sm transition-colors hover:bg-surface/50",
|
||||||
hasAvatar={message.has_avatar}
|
continuation && "mt-0",
|
||||||
avatarUpdatedAt={message.avatar_updated_at}
|
|
||||||
className="h-9 w-9"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
{continuation ? null : (
|
|
||||||
<p className="flex items-center gap-2 text-xs">
|
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
"font-medium",
|
|
||||||
own ? "text-accent" : "text-foreground",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{fullName(message, t("Compte supprimé"))}
|
|
||||||
</span>
|
|
||||||
<span className="text-[0.6875rem] text-subtle-foreground">
|
|
||||||
{timeOf(message.created_at)}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
)}
|
)}
|
||||||
{editingId === message.id ? (
|
>
|
||||||
<div className="mt-1 flex flex-col gap-2">
|
{continuation ? (
|
||||||
<textarea
|
<span className="w-9 shrink-0" aria-hidden="true" />
|
||||||
value={editDraft}
|
|
||||||
autoFocus
|
|
||||||
onChange={(event) => setEditDraft(event.target.value.slice(0, MAX_LENGTH))}
|
|
||||||
onKeyDown={(event) => {
|
|
||||||
if (event.key === "Enter" && !event.shiftKey) {
|
|
||||||
event.preventDefault();
|
|
||||||
void saveEdit(message);
|
|
||||||
}
|
|
||||||
if (event.key === "Escape") {
|
|
||||||
event.preventDefault();
|
|
||||||
cancelEdit();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
rows={2}
|
|
||||||
maxLength={MAX_LENGTH}
|
|
||||||
aria-label={t("Modifier le message")}
|
|
||||||
className="max-h-40 min-h-[2.5rem] resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
|
|
||||||
/>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
size="sm"
|
|
||||||
isLoading={savingEdit}
|
|
||||||
disabled={editDraft.trim().length === 0}
|
|
||||||
onClick={() => void saveEdit(message)}
|
|
||||||
>
|
|
||||||
{t("Enregistrer")}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
size="sm"
|
|
||||||
variant="ghost"
|
|
||||||
onClick={cancelEdit}
|
|
||||||
>
|
|
||||||
{t("Annuler")}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
) : (
|
||||||
<>
|
<Avatar
|
||||||
<p className="whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground">
|
userId={
|
||||||
{message.body}
|
message.user_id ?? message.first_name ?? "unknown"
|
||||||
</p>
|
}
|
||||||
{message.edited_at ? (
|
firstName={message.first_name ?? "?"}
|
||||||
<p
|
lastName={message.last_name ?? ""}
|
||||||
className="mt-0.5 text-[0.6875rem] text-subtle-foreground"
|
hasAvatar={message.has_avatar}
|
||||||
title={formatDateTimeSeconds(message.edited_at)}
|
avatarUpdatedAt={message.avatar_updated_at}
|
||||||
>
|
className="h-9 w-9"
|
||||||
{t("(modifié)")}
|
/>
|
||||||
</p>
|
|
||||||
) : null}
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
<div className="min-w-0 flex-1">
|
||||||
{/* L'epinglage est ouvert a tous les participants ; l'edition
|
{continuation ? null : (
|
||||||
|
<p className="flex items-center gap-2 text-xs">
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"font-medium",
|
||||||
|
own ? "text-accent" : "text-foreground",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{fullName(message, t("Compte supprimé"))}
|
||||||
|
</span>
|
||||||
|
<span className="text-[0.6875rem] text-subtle-foreground">
|
||||||
|
{timeOf(message.created_at)}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{editingId === message.id ? (
|
||||||
|
<div className="mt-1 flex flex-col gap-2">
|
||||||
|
<textarea
|
||||||
|
value={editDraft}
|
||||||
|
autoFocus
|
||||||
|
onChange={(event) =>
|
||||||
|
setEditDraft(
|
||||||
|
event.target.value.slice(0, MAX_LENGTH),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (
|
||||||
|
event.key === "Enter" &&
|
||||||
|
!event.shiftKey
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
void saveEdit(message);
|
||||||
|
}
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
event.preventDefault();
|
||||||
|
cancelEdit();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
rows={2}
|
||||||
|
maxLength={MAX_LENGTH}
|
||||||
|
aria-label={t("Modifier le message")}
|
||||||
|
className="max-h-40 min-h-10 resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
|
||||||
|
/>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="sm"
|
||||||
|
isLoading={savingEdit}
|
||||||
|
disabled={editDraft.trim().length === 0}
|
||||||
|
onClick={() => void saveEdit(message)}
|
||||||
|
>
|
||||||
|
{t("Enregistrer")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
onClick={cancelEdit}
|
||||||
|
>
|
||||||
|
{t("Annuler")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<p className="whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground">
|
||||||
|
{message.body}
|
||||||
|
</p>
|
||||||
|
{message.edited_at ? (
|
||||||
|
<p
|
||||||
|
className="mt-0.5 text-[0.6875rem] text-subtle-foreground"
|
||||||
|
title={formatDateTimeSeconds(
|
||||||
|
message.edited_at,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{t("(modifié)")}
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{/* L'epinglage est ouvert a tous les participants ; l'edition
|
||||||
et la suppression restent reservees a l'auteur. */}
|
et la suppression restent reservees a l'auteur. */}
|
||||||
<span className="flex shrink-0 items-center opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100">
|
<span className="flex shrink-0 items-center opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100">
|
||||||
<IconAction
|
<IconAction
|
||||||
label={
|
label={
|
||||||
message.is_pinned
|
message.is_pinned
|
||||||
? t("Désépingler le message")
|
? t("Désépingler le message")
|
||||||
: t("Épingler le message")
|
: t("Épingler le message")
|
||||||
}
|
}
|
||||||
isLoading={pinningId === message.id}
|
isLoading={pinningId === message.id}
|
||||||
icon={
|
icon={
|
||||||
<PinIcon
|
<PinIcon
|
||||||
className={cn("h-3.5 w-3.5", message.is_pinned && "text-accent")}
|
className={cn(
|
||||||
|
"h-3.5 w-3.5",
|
||||||
|
message.is_pinned && "text-accent",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onClick={() => void togglePin(message)}
|
||||||
|
/>
|
||||||
|
{canEdit ? (
|
||||||
|
<IconAction
|
||||||
|
label={t("Modifier le message")}
|
||||||
|
icon={<PenIcon className="h-3.5 w-3.5" />}
|
||||||
|
onClick={() => startEdit(message)}
|
||||||
/>
|
/>
|
||||||
}
|
) : null}
|
||||||
onClick={() => void togglePin(message)}
|
{canDelete ? (
|
||||||
/>
|
<IconAction
|
||||||
{canEdit ? (
|
label={t("Supprimer le message")}
|
||||||
<IconAction
|
tone="danger"
|
||||||
label={t("Modifier le message")}
|
isLoading={deletingId === message.id}
|
||||||
icon={<PenIcon className="h-3.5 w-3.5" />}
|
icon={<TrashIcon className="h-3.5 w-3.5" />}
|
||||||
onClick={() => startEdit(message)}
|
onClick={() => void remove(message)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{canDelete ? (
|
</span>
|
||||||
<IconAction
|
</div>
|
||||||
label={t("Supprimer le message")}
|
</li>
|
||||||
tone="danger"
|
|
||||||
isLoading={deletingId === message.id}
|
|
||||||
icon={<TrashIcon className="h-3.5 w-3.5" />}
|
|
||||||
onClick={() => void remove(message)}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
</ol>
|
</ol>
|
||||||
@@ -664,7 +756,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
value={draft}
|
value={draft}
|
||||||
onChange={(event) => setDraft(event.target.value.slice(0, MAX_LENGTH))}
|
onChange={(event) =>
|
||||||
|
setDraft(event.target.value.slice(0, MAX_LENGTH))
|
||||||
|
}
|
||||||
onKeyDown={onComposerKeyDown}
|
onKeyDown={onComposerKeyDown}
|
||||||
rows={1}
|
rows={1}
|
||||||
maxLength={MAX_LENGTH}
|
maxLength={MAX_LENGTH}
|
||||||
@@ -672,7 +766,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
|||||||
"Écrire un message… (Entrée pour envoyer, Maj+Entrée pour retour à la ligne)",
|
"Écrire un message… (Entrée pour envoyer, Maj+Entrée pour retour à la ligne)",
|
||||||
)}
|
)}
|
||||||
aria-label={t("Votre message")}
|
aria-label={t("Votre message")}
|
||||||
className="max-h-40 min-h-[2.5rem] flex-1 resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground placeholder:text-subtle-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
|
className="max-h-40 min-h-10 flex-1 resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground placeholder:text-subtle-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
|
||||||
/>
|
/>
|
||||||
<IconAction
|
<IconAction
|
||||||
label={t("Envoyer")}
|
label={t("Envoyer")}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export const PlayIcon = (props: IconProps) => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const AudioIcon = (props: IconProps) => (
|
export const AudioIcon = (props: IconProps) => (
|
||||||
<ImgIcon src="/icons/file.webp" {...props} />
|
<ImgIcon src="/icons/activity.webp" {...props} />
|
||||||
);
|
);
|
||||||
|
|
||||||
export const ArchiveIcon = (props: IconProps) => (
|
export const ArchiveIcon = (props: IconProps) => (
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { createContext, useCallback, useContext, useState, type ReactNode } from "react";
|
import {
|
||||||
|
createContext,
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useState,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
import { cn } from "../ui/index.js";
|
import { cn } from "../ui/index.js";
|
||||||
import { useI18n } from "../lib/i18n.js";
|
import { useI18n } from "../lib/i18n.js";
|
||||||
import { CloseIcon } from "./icons.js";
|
import { CloseIcon } from "./icons.js";
|
||||||
@@ -37,34 +43,51 @@ export const ToastProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
setToasts((prev) => prev.filter((t) => t.id !== id));
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const toast = useCallback((message: string, tone: ToastTone = "info", duration = 4000) => {
|
const toast = useCallback(
|
||||||
const id = ++toastId;
|
(message: string, tone: ToastTone = "info", duration = 4000) => {
|
||||||
setToasts((prev) => [...prev, { id, message, tone, duration }]);
|
const id = ++toastId;
|
||||||
if (duration > 0) {
|
setToasts((prev) => [...prev, { id, message, tone, duration }]);
|
||||||
setTimeout(() => remove(id), duration);
|
if (duration > 0) {
|
||||||
}
|
setTimeout(() => remove(id), duration);
|
||||||
}, [remove]);
|
}
|
||||||
|
},
|
||||||
|
[remove],
|
||||||
|
);
|
||||||
|
|
||||||
const success = useCallback((message: string, duration = 4000) => toast(message, "success", duration), [toast]);
|
const success = useCallback(
|
||||||
const error = useCallback((message: string, duration = 5000) => toast(message, "error", duration), [toast]);
|
(message: string, duration = 4000) => toast(message, "success", duration),
|
||||||
const info = useCallback((message: string, duration = 4000) => toast(message, "info", duration), [toast]);
|
[toast],
|
||||||
|
);
|
||||||
|
const error = useCallback(
|
||||||
|
(message: string, duration = 5000) => toast(message, "error", duration),
|
||||||
|
[toast],
|
||||||
|
);
|
||||||
|
const info = useCallback(
|
||||||
|
(message: string, duration = 4000) => toast(message, "info", duration),
|
||||||
|
[toast],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToastContext.Provider value={{ toast, success, error, info }}>
|
<ToastContext.Provider value={{ toast, success, error, info }}>
|
||||||
{children}
|
{children}
|
||||||
<div className="fixed left-4 right-4 top-6 z-[100] flex flex-col gap-2 sm:left-auto sm:right-4 sm:max-w-sm">
|
<div className="fixed left-4 right-4 top-6 z-100 flex flex-col gap-2 sm:left-auto sm:right-4 sm:max-w-sm">
|
||||||
{toasts.map((toastItem) => (
|
{toasts.map((toastItem) => (
|
||||||
<div
|
<div
|
||||||
key={toastItem.id}
|
key={toastItem.id}
|
||||||
className={cn(
|
className={cn(
|
||||||
"animate-in slide-in-from-right fade-in flex min-w-[280px] max-w-sm items-start gap-3 rounded-lg border px-4 py-3 shadow-lg backdrop-blur",
|
"animate-in slide-in-from-right fade-in flex min-w-70 max-w-sm items-start gap-3 rounded-lg border px-4 py-3 shadow-lg backdrop-blur",
|
||||||
toastItem.tone === "success" && "border-accent/40 bg-accent/10 text-foreground",
|
toastItem.tone === "success" &&
|
||||||
toastItem.tone === "error" && "border-destructive/40 bg-destructive/10 text-destructive",
|
"border-accent/40 bg-accent/10 text-foreground",
|
||||||
toastItem.tone === "info" && "border-border bg-surface text-foreground",
|
toastItem.tone === "error" &&
|
||||||
|
"border-destructive/40 bg-destructive/10 text-destructive",
|
||||||
|
toastItem.tone === "info" &&
|
||||||
|
"border-border bg-surface text-foreground",
|
||||||
)}
|
)}
|
||||||
role="status"
|
role="status"
|
||||||
>
|
>
|
||||||
<p className="flex-1 text-sm leading-relaxed">{toastItem.message}</p>
|
<p className="flex-1 text-sm leading-relaxed">
|
||||||
|
{toastItem.message}
|
||||||
|
</p>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => remove(toastItem.id)}
|
onClick={() => remove(toastItem.id)}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const ChangePassword = () => {
|
|||||||
CoHaiSe
|
CoHaiSe
|
||||||
</p>
|
</p>
|
||||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||||
{t("Nouveau mot de passe")}
|
Cloud
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -59,7 +59,7 @@ export const ChangePassword = () => {
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader className="text-center">
|
||||||
<CardTitle>{t("Changement requis")}</CardTitle>
|
<CardTitle>{t("Changement requis")}</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
{t("Les autres sessions ouvertes sur ce compte seront fermées.")}
|
{t("Les autres sessions ouvertes sur ce compte seront fermées.")}
|
||||||
@@ -68,6 +68,7 @@ export const ChangePassword = () => {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Mot de passe actuel")}
|
label={t("Mot de passe actuel")}
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
@@ -77,6 +78,7 @@ export const ChangePassword = () => {
|
|||||||
onChange={(event) => setCurrent(event.target.value)}
|
onChange={(event) => setCurrent(event.target.value)}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Nouveau mot de passe")}
|
label={t("Nouveau mot de passe")}
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
@@ -87,6 +89,7 @@ export const ChangePassword = () => {
|
|||||||
onChange={(event) => setNext(event.target.value)}
|
onChange={(event) => setNext(event.target.value)}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Confirmation")}
|
label={t("Confirmation")}
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
@@ -95,7 +98,7 @@ export const ChangePassword = () => {
|
|||||||
value={confirm}
|
value={confirm}
|
||||||
onChange={(event) => setConfirm(event.target.value)}
|
onChange={(event) => setConfirm(event.target.value)}
|
||||||
/>
|
/>
|
||||||
{error ? <Alert>{error}</Alert> : null}
|
{error ? <Alert className="text-center">{error}</Alert> : null}
|
||||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||||
{t("Enregistrer")}
|
{t("Enregistrer")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -49,14 +49,14 @@ export const ConfirmEmail = () => {
|
|||||||
CoHaiSe
|
CoHaiSe
|
||||||
</p>
|
</p>
|
||||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||||
{t("Changement d'adresse")}
|
Cloud
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader className="text-center">
|
||||||
<CardTitle>{t("Confirmation")}</CardTitle>
|
<CardTitle>{t("Confirmation")}</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex flex-col gap-4">
|
<CardContent className="flex flex-col gap-4">
|
||||||
@@ -66,7 +66,7 @@ export const ConfirmEmail = () => {
|
|||||||
</div>
|
</div>
|
||||||
) : state === "success" ? (
|
) : state === "success" ? (
|
||||||
<>
|
<>
|
||||||
<Alert tone="success">{t("Votre adresse e-mail a été mise à jour.")}</Alert>
|
<Alert tone="success" className="text-center">{t("Votre adresse e-mail a été mise à jour.")}</Alert>
|
||||||
<Link to="/files">
|
<Link to="/files">
|
||||||
<Button size="lg" fullWidth>
|
<Button size="lg" fullWidth>
|
||||||
{t("Accéder à mes fichiers")}
|
{t("Accéder à mes fichiers")}
|
||||||
@@ -75,7 +75,7 @@ export const ConfirmEmail = () => {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Alert>{error}</Alert>
|
<Alert className="text-center">{error}</Alert>
|
||||||
<Link to="/profile">
|
<Link to="/profile">
|
||||||
<Button size="lg" fullWidth>
|
<Button size="lg" fullWidth>
|
||||||
{t("Mon compte")}
|
{t("Mon compte")}
|
||||||
|
|||||||
@@ -40,15 +40,15 @@ export const ForgotPassword = () => {
|
|||||||
CoHaiSe
|
CoHaiSe
|
||||||
</p>
|
</p>
|
||||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||||
{t("Mot de passe oublié")}
|
Cloud
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader className="text-center">
|
||||||
<CardTitle>{t("Réinitialisation")}</CardTitle>
|
<CardTitle>{t("Mot de passe oublié")}</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
{t("Nous vous enverrons un lien valable une heure.")}
|
{t("Nous vous enverrons un lien valable une heure.")}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
@@ -56,7 +56,7 @@ export const ForgotPassword = () => {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
{sent ? (
|
{sent ? (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Alert tone="success">
|
<Alert tone="success" className="text-center">
|
||||||
{t("Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.")}
|
{t("Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.")}
|
||||||
</Alert>
|
</Alert>
|
||||||
<Link
|
<Link
|
||||||
@@ -72,6 +72,7 @@ export const ForgotPassword = () => {
|
|||||||
onSubmit={(event) => void submit(event)}
|
onSubmit={(event) => void submit(event)}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Adresse e-mail")}
|
label={t("Adresse e-mail")}
|
||||||
type="email"
|
type="email"
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
@@ -80,7 +81,7 @@ export const ForgotPassword = () => {
|
|||||||
value={email}
|
value={email}
|
||||||
onChange={(event) => setEmail(event.target.value)}
|
onChange={(event) => setEmail(event.target.value)}
|
||||||
/>
|
/>
|
||||||
{error ? <Alert>{error}</Alert> : null}
|
{error ? <Alert className="text-center">{error}</Alert> : null}
|
||||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||||
{t("Envoyer le lien")}
|
{t("Envoyer le lien")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -55,13 +55,14 @@ export const Login = () => {
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader className="text-center">
|
||||||
<CardTitle>{t("Connexion")}</CardTitle>
|
<CardTitle>{t("Connexion")}</CardTitle>
|
||||||
<CardDescription>{t("Votre session reste ouverte 14 jours.")}</CardDescription>
|
<CardDescription>{t("Votre session reste ouverte 14 jours.")}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Adresse e-mail")}
|
label={t("Adresse e-mail")}
|
||||||
type="email"
|
type="email"
|
||||||
autoComplete="username"
|
autoComplete="username"
|
||||||
@@ -71,6 +72,7 @@ export const Login = () => {
|
|||||||
onChange={(event) => setEmail(event.target.value)}
|
onChange={(event) => setEmail(event.target.value)}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Mot de passe")}
|
label={t("Mot de passe")}
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
|
|||||||
@@ -47,21 +47,21 @@ export const ResetPassword = () => {
|
|||||||
CoHaiSe
|
CoHaiSe
|
||||||
</p>
|
</p>
|
||||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||||
{t("Nouveau mot de passe")}
|
Cloud
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader className="text-center">
|
||||||
<CardTitle>{t("Réinitialisation")}</CardTitle>
|
<CardTitle>{t("Réinitialisation")}</CardTitle>
|
||||||
<CardDescription>{t("Choisissez un mot de passe robuste.")}</CardDescription>
|
<CardDescription>{t("Choisissez un mot de passe robuste.")}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{!token ? (
|
{!token ? (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Alert>{t("Ce lien est incomplet ou invalide.")}</Alert>
|
<Alert className="text-center">{t("Ce lien est incomplet ou invalide.")}</Alert>
|
||||||
<Link
|
<Link
|
||||||
to="/forgot-password"
|
to="/forgot-password"
|
||||||
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||||
@@ -71,7 +71,7 @@ export const ResetPassword = () => {
|
|||||||
</div>
|
</div>
|
||||||
) : done ? (
|
) : done ? (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Alert tone="success">
|
<Alert tone="success" className="text-center">
|
||||||
{t("Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.")}
|
{t("Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.")}
|
||||||
</Alert>
|
</Alert>
|
||||||
<Link to="/login">
|
<Link to="/login">
|
||||||
@@ -83,6 +83,7 @@ export const ResetPassword = () => {
|
|||||||
) : (
|
) : (
|
||||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Nouveau mot de passe")}
|
label={t("Nouveau mot de passe")}
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
@@ -94,6 +95,7 @@ export const ResetPassword = () => {
|
|||||||
onChange={(event) => setPassword(event.target.value)}
|
onChange={(event) => setPassword(event.target.value)}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
|
centered
|
||||||
label={t("Confirmation")}
|
label={t("Confirmation")}
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
@@ -102,7 +104,7 @@ export const ResetPassword = () => {
|
|||||||
value={confirm}
|
value={confirm}
|
||||||
onChange={(event) => setConfirm(event.target.value)}
|
onChange={(event) => setConfirm(event.target.value)}
|
||||||
/>
|
/>
|
||||||
{error ? <Alert>{error}</Alert> : null}
|
{error ? <Alert className="text-center">{error}</Alert> : null}
|
||||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||||
{t("Réinitialiser")}
|
{t("Réinitialiser")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|||||||
hint?: ReactNode;
|
hint?: ReactNode;
|
||||||
error?: ReactNode;
|
error?: ReactNode;
|
||||||
sizeVariant?: "sm" | "md" | "lg";
|
sizeVariant?: "sm" | "md" | "lg";
|
||||||
|
/** Centre le libellé, le texte saisi et le message d'aide/erreur. */
|
||||||
|
centered?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputSize = {
|
const inputSize = {
|
||||||
@@ -20,6 +22,7 @@ export const Input = ({
|
|||||||
hint,
|
hint,
|
||||||
error,
|
error,
|
||||||
sizeVariant = "md",
|
sizeVariant = "md",
|
||||||
|
centered = false,
|
||||||
id,
|
id,
|
||||||
className,
|
className,
|
||||||
disabled,
|
disabled,
|
||||||
@@ -31,7 +34,7 @@ export const Input = ({
|
|||||||
const isInvalid = error !== undefined && error !== null && error !== "";
|
const isInvalid = error !== undefined && error !== null && error !== "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full flex-col gap-1.5">
|
<div className={cn("flex w-full flex-col gap-1.5", centered && "text-center")}>
|
||||||
{label ? (
|
{label ? (
|
||||||
<label
|
<label
|
||||||
htmlFor={inputId}
|
htmlFor={inputId}
|
||||||
@@ -53,6 +56,7 @@ export const Input = ({
|
|||||||
"disabled:cursor-not-allowed disabled:bg-surface-muted disabled:opacity-60",
|
"disabled:cursor-not-allowed disabled:bg-surface-muted disabled:opacity-60",
|
||||||
isInvalid ? "border-destructive focus-visible:ring-destructive" : "border-border-control",
|
isInvalid ? "border-destructive focus-visible:ring-destructive" : "border-border-control",
|
||||||
inputSize[sizeVariant],
|
inputSize[sizeVariant],
|
||||||
|
centered && "text-center",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -62,7 +66,7 @@ export const Input = ({
|
|||||||
<p
|
<p
|
||||||
id={messageId}
|
id={messageId}
|
||||||
role={isInvalid ? "alert" : undefined}
|
role={isInvalid ? "alert" : undefined}
|
||||||
className={cn("text-xs leading-relaxed", isInvalid ? "text-destructive" : "text-muted-foreground")}
|
className={cn("text-xs leading-relaxed", centered && "text-center", isInvalid ? "text-destructive" : "text-muted-foreground")}
|
||||||
>
|
>
|
||||||
{isInvalid ? error : hint}
|
{isInvalid ? error : hint}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user