Improve navbar
This commit is contained in:
parent
93008ff051
commit
2bb2cb1f38
5 changed files with 29 additions and 32 deletions
12
justfile
12
justfile
|
|
@ -20,14 +20,4 @@ update-types:
|
|||
npx supabase gen types typescript --project-id "mhcafqvzbrrwvahpvvzd" --schema public > ui/src/types/database.types.ts && cp ui/src/types/database.types.ts api/src/database.types.ts
|
||||
|
||||
deploy-api:
|
||||
gcloud run deploy xablo-api
|
||||
--source api
|
||||
--region europe-west1
|
||||
--set-env-vars "SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co"
|
||||
--set-env-vars "SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0MTI0MTMyMSwiZXhwIjoyMDU2ODE3MzIxfQ.9r33CUsu6ZR4vyv4ed-UY6cLE1FZzSSxTNE8pFUKjN4"
|
||||
--set-env-vars "STREAM_CHAT_API_KEY=t5vvvddteapa"
|
||||
--set-env-vars "STREAM_CHAT_API_SECRET=zrr32sqenw3atpv9rnz2nhhyyncf7bunr7fmfqy9r7e69fcw978dhzevmhpxa2jj"
|
||||
--set-env-vars "FRONTEND_URL=https://develop.xtablo-source.pages.dev"
|
||||
--set-env-vars "EMAIL_USER=baptiste@xtablo.com"
|
||||
--set-env-vars "EMAIL_KEY=jayf pzpj nrsv vtim"
|
||||
--set-env-vars "XTABLO_URL=https://develop.xtablo-source.pages.dev"
|
||||
gcloud run deploy xablo-api --source api --region europe-west1 --set-env-vars "SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co" --set-env-vars "SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0MTI0MTMyMSwiZXhwIjoyMDU2ODE3MzIxfQ.9r33CUsu6ZR4vyv4ed-UY6cLE1FZzSSxTNE8pFUKjN4" --set-env-vars "STREAM_CHAT_API_KEY=t5vvvddteapa" --set-env-vars "STREAM_CHAT_API_SECRET=zrr32sqenw3atpv9rnz2nhhyyncf7bunr7fmfqy9r7e69fcw978dhzevmhpxa2jj" --set-env-vars "FRONTEND_URL=https://develop.xtablo-source.pages.dev" --set-env-vars "EMAIL_USER=baptiste@xtablo.com" --set-env-vars "EMAIL_KEY=jayf pzpj nrsv vtim" --set-env-vars "XTABLO_URL=https://develop.xtablo-source.pages.dev"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
CREATE FUNCTION
|
||||
public.create_profile_for_new_user()
|
||||
CREATE OR REPLACE FUNCTION
|
||||
public.handle_new_user()
|
||||
RETURNS TRIGGER AS
|
||||
$$
|
||||
BEGIN
|
||||
INSERT INTO public.profiles (id, full_name, email)
|
||||
VALUES (
|
||||
NEW.id,
|
||||
NEW.raw_user_meta_data ->> 'user_name',
|
||||
NEW.email
|
||||
);
|
||||
RETURN NEW;
|
||||
END;
|
||||
DECLARE name TEXT;
|
||||
BEGIN
|
||||
IF new.raw_user_meta_data ->> 'name' IS NOT NULL
|
||||
THEN
|
||||
name = new.raw_user_meta_data ->> 'name';
|
||||
ELSE
|
||||
name = CONCAT (new.raw_user_meta_data ->> 'first_name', ' ', new.raw_user_meta_data ->> 'last_name');
|
||||
END IF;
|
||||
|
||||
INSERT INTO public.profiles (id, name, email, avatar_url)
|
||||
VALUES (new.id, name, new.email, new.raw_user_meta_data ->> 'avatar_url');
|
||||
RETURN new;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql SECURITY DEFINER;
|
||||
|
|
@ -15,6 +15,10 @@ CREATE TABLE IF NOT EXISTS tablo_access (
|
|||
-- Unique constraint to prevent duplicate access records
|
||||
CONSTRAINT unique_tablo_access
|
||||
UNIQUE (tablo_id, user_id)
|
||||
|
||||
-- Foreign key constraint to users table (auth.users)
|
||||
CONSTRAINT fk_tablo_access_user_id
|
||||
FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE,
|
||||
);
|
||||
|
||||
-- Create indexes for performance
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ import { AvailableIcon } from "@ui/ui-library/icons";
|
|||
import { useState, useRef } from "react";
|
||||
import logo from "../assets/icon.jpg";
|
||||
import { ThemeSwitcher } from "./ThemeSwitcher";
|
||||
import { useSession } from "../contexts/SessionContext";
|
||||
import { Text } from "@ui/ui-library/text";
|
||||
import { SignOutButton } from "./SignOutButton";
|
||||
import { useUser } from "@ui/providers/UserStoreProvider";
|
||||
|
||||
type NavLinkItem = {
|
||||
isActive?: boolean;
|
||||
|
|
@ -90,7 +90,7 @@ function NavLink(props: NavLinkProps) {
|
|||
}
|
||||
|
||||
export function UserMenuPopover({ isCollapsed }: { isCollapsed: boolean }) {
|
||||
const { session } = useSession();
|
||||
const user = useUser();
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
const ref = useRef(null);
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ export function UserMenuPopover({ isCollapsed }: { isCollapsed: boolean }) {
|
|||
>
|
||||
<Avatar
|
||||
className="rounded-full size-7"
|
||||
src={session?.user?.user_metadata?.avatar_url}
|
||||
src={user.avatar_url ?? undefined}
|
||||
alt="Avatar"
|
||||
/>
|
||||
<Text
|
||||
|
|
@ -117,7 +117,7 @@ export function UserMenuPopover({ isCollapsed }: { isCollapsed: boolean }) {
|
|||
isCollapsed ? "opacity-0 w-0" : "opacity-100"
|
||||
)}
|
||||
>
|
||||
{session?.user?.user_metadata?.full_name}
|
||||
{user.name}
|
||||
</Text>
|
||||
</Button>
|
||||
<Popover
|
||||
|
|
@ -130,15 +130,13 @@ export function UserMenuPopover({ isCollapsed }: { isCollapsed: boolean }) {
|
|||
<div className="flex flex-col gap-2 p-3">
|
||||
<div className="flex gap-4">
|
||||
<Avatar
|
||||
src={session?.user?.user_metadata?.avatar_url}
|
||||
alt={session?.user?.user_metadata?.first_name}
|
||||
src={user.avatar_url ?? undefined}
|
||||
alt={user.name ?? "User avatar"}
|
||||
>
|
||||
<AvatarBadge badge={<AvailableIcon aria-label="Available" />} />
|
||||
</Avatar>
|
||||
<div className="flex flex-col">
|
||||
<Text className="font-bold text-gray-300/90">
|
||||
{session?.user?.user_metadata?.full_name}
|
||||
</Text>
|
||||
<Text className="font-bold text-gray-300/90">{user.name}</Text>
|
||||
<SignOutButton />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { User } from "@supabase/supabase-js";
|
|||
import userEvent from "@testing-library/user-event";
|
||||
import { queryClient } from "@ui/lib/api";
|
||||
import { QueryClientProvider } from "@tanstack/react-query";
|
||||
import { UserStoreProvider } from "@ui/providers/UserStoreProvider";
|
||||
|
||||
export const renderWithRouter = (ui: React.ReactNode, { route = "/" } = {}) => {
|
||||
window.history.pushState({}, "Test page", route);
|
||||
|
|
@ -40,7 +41,7 @@ export const renderWithProviders = (
|
|||
}
|
||||
}
|
||||
>
|
||||
{ui}
|
||||
<UserStoreProvider>{ui}</UserStoreProvider>
|
||||
</SessionTestProvider>
|
||||
</QueryClientProvider>
|
||||
</ThemeProvider>
|
||||
|
|
|
|||
Loading…
Reference in a new issue