diff --git a/apps/main/src/App.tsx b/apps/main/src/App.tsx index 542c506..349f443 100644 --- a/apps/main/src/App.tsx +++ b/apps/main/src/App.tsx @@ -2,10 +2,10 @@ import { SessionProvider } from "@xtablo/shared/contexts/SessionContext"; import { ThemeProvider } from "@xtablo/shared/contexts/ThemeContext"; import { Toaster } from "@xtablo/ui/components/sonner"; import { BrowserRouter as Router, useRoutes } from "react-router-dom"; -import { NotFoundPage } from "./pages/NotFoundPage"; import { publicRoutes } from "./lib/publicRoutes"; import { routes } from "./lib/routes"; import { supabase } from "./lib/supabase"; +import { NotFoundPage } from "./pages/NotFoundPage"; import { DatadogRumProvider } from "./providers/DatadogRumProvider"; import { UserStoreProvider } from "./providers/UserStoreProvider"; diff --git a/apps/main/src/components/EventModal.tsx b/apps/main/src/components/EventModal.tsx index 17823fd..6f35b98 100644 --- a/apps/main/src/components/EventModal.tsx +++ b/apps/main/src/components/EventModal.tsx @@ -1,4 +1,5 @@ import { getLocalTimeZone, parseDate, today } from "@internationalized/date"; +import { toast } from "@xtablo/shared"; import { Event, EventInsert } from "@xtablo/shared/types/events.types"; import { Button } from "@xtablo/ui/components/button"; import { DatePicker } from "@xtablo/ui/components/date-picker"; @@ -26,7 +27,7 @@ import { useTranslation } from "react-i18next"; import { useNavigate, useParams, useSearchParams } from "react-router-dom"; import { useCreateEvents, useEvent, useUpdateEvent } from "../hooks/events"; import { useTablosList } from "../hooks/tablos"; -import { useUser } from "../providers/UserStoreProvider"; +import { useIsReadOnlyUser, useUser } from "../providers/UserStoreProvider"; export const EventModal = ({ mode }: { mode: "create" | "edit" }) => { const { t, i18n } = useTranslation("components"); @@ -34,6 +35,7 @@ export const EventModal = ({ mode }: { mode: "create" | "edit" }) => { const { data: event } = useEvent(event_id as string); const user = useUser(); + const isReadOnly = useIsReadOnlyUser(); const [searchParams] = useSearchParams(); const tablo_id = searchParams.get("tablo_id"); const dateFromParams = searchParams.get("date"); @@ -237,6 +239,18 @@ export const EventModal = ({ mode }: { mode: "create" | "edit" }) => { diff --git a/apps/main/src/components/NavigationBar.tsx b/apps/main/src/components/NavigationBar.tsx index f6d0864..752e4e5 100644 --- a/apps/main/src/components/NavigationBar.tsx +++ b/apps/main/src/components/NavigationBar.tsx @@ -35,7 +35,7 @@ import { Link as RouterLink, useLocation } from "react-router-dom"; import { twMerge } from "tailwind-merge"; import { useLogout } from "../hooks/auth"; import { isProd, isStaging } from "../lib/env"; -import { useUser } from "../providers/UserStoreProvider"; +import { useIsReadOnlyUser, useUser } from "../providers/UserStoreProvider"; import { getXtabloIcon } from "../utils/iconHelpers"; import { ThemeSwitcher } from "./ThemeSwitcher"; @@ -276,6 +276,7 @@ export const SideNavigation = ({ isMobileMenuOpen }: { isMobileMenuOpen: boolean export function MainNavigation({ isCollapsed }: { isCollapsed: boolean }) { const location = useLocation(); + const isReadOnly = useIsReadOnlyUser(); const { t } = useTranslation("navigation"); type List = T[]; @@ -291,47 +292,61 @@ export function MainNavigation({ isCollapsed }: { isCollapsed: boolean }) { | { isHorizontalBar: boolean; } - > = [ - { - path: "/", - label: t("projects"), - icon: , - }, - { isHorizontalBar: true }, - { - path: "/events", - label: t("myEvents"), - icon: , - }, - { - path: "/kanban", - label: t("kanban"), - icon: , - isDisabled: true, - }, - { - path: "/chantiers", - label: t("chantiers"), - icon: , - isDisabled: true, - }, - { isHorizontalBar: true }, - { - path: "/planning", - label: t("planning"), - icon: , - }, - { - path: "/chat", - label: t("discussions"), - icon: , - }, - { - path: "/notes", - label: t("notes"), - icon: , - }, - ]; + > = isReadOnly + ? [ + { + path: "/", + label: t("projects"), + icon: , + }, + { + path: "/planning", + label: t("planning"), + icon: , + }, + ] + : [ + { + path: "/", + label: t("projects"), + icon: , + }, + { isHorizontalBar: true }, + { + path: "/events", + label: t("myEvents"), + icon: , + isDisabled: isReadOnly, + }, + { + path: "/kanban", + label: t("kanban"), + icon: , + isDisabled: true, + }, + { + path: "/chantiers", + label: t("chantiers"), + icon: , + isDisabled: true, + }, + { isHorizontalBar: true }, + { + path: "/planning", + label: t("planning"), + icon: , + }, + { + path: "/chat", + label: t("discussions"), + icon: , + }, + { + path: "/notes", + label: t("notes"), + icon: , + }, + ]; return (