Skip to content

Commit c945b48

Browse files
committed
more work on settings layout
1 parent b359048 commit c945b48

File tree

23 files changed

+202
-1321
lines changed

23 files changed

+202
-1321
lines changed

apps/desktop2/src/auth.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createClient, processLock, type Session, type SupportedStorage } from "@supabase/supabase-js";
1+
import { createClient, processLock, type Session, SupabaseClient, type SupportedStorage } from "@supabase/supabase-js";
22
import { getCurrentWindow } from "@tauri-apps/api/window";
33
import { createContext, useContext, useEffect, useState } from "react";
44

@@ -37,7 +37,12 @@ const supabase = env.VITE_SUPABASE_URL && env.VITE_SUPABASE_ANON_KEY
3737
})
3838
: null;
3939

40-
const AuthContext = createContext<any | undefined>(undefined);
40+
const AuthContext = createContext<
41+
{
42+
supabase: SupabaseClient | null;
43+
session: Session | null;
44+
} | null
45+
>(null);
4146

4247
export function AuthProvider({ children }: { children: React.ReactNode }) {
4348
const [session, setSession] = useState<Session | null>(null);

apps/desktop2/src/components/main/main-area.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { commands as windowsCommands } from "@hypr/plugin-windows";
22
import { useNavigate, useSearch } from "@tanstack/react-router";
33
import { clsx } from "clsx";
4-
import { PanelLeftOpenIcon } from "lucide-react";
4+
import { CogIcon, PanelLeftOpenIcon, PencilIcon } from "lucide-react";
55

66
import NoteEditor from "@hypr/tiptap/editor";
77
import { ChatPanelButton } from "@hypr/ui/components/block/chat-panel-button";
@@ -58,19 +58,17 @@ export function MainHeader() {
5858
)}
5959

6060
<div
61-
className="flex items-center justify-start"
61+
className="flex items-center justify-start gap-2"
6262
data-tauri-drag-region
6363
>
64-
<button
64+
<CogIcon
6565
onClick={handleClickSettings}
66-
>
67-
Setting
68-
</button>
69-
<button
66+
className="cursor-pointer h-5 w-5 text-muted-foreground hover:text-foreground"
67+
/>
68+
<PencilIcon
7069
onClick={handleClickNewNote}
71-
>
72-
New note
73-
</button>
70+
className="cursor-pointer h-5 w-5 text-muted-foreground hover:text-foreground"
71+
/>
7472
</div>
7573

7674
<ChatPanelButton

apps/desktop2/src/routeTree.gen.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { createFileRoute } from '@tanstack/react-router'
1313
import { Route as rootRouteImport } from './routes/__root'
1414
import { Route as AppRouteImport } from './routes/app'
1515
import { Route as AppSettingsRouteImport } from './routes/app/settings'
16+
import { Route as AppAuthRouteImport } from './routes/app/auth'
1617
import { Route as AppMainLayoutRouteImport } from './routes/app/main/_layout'
1718
import { Route as AppMainLayoutIndexRouteImport } from './routes/app/main/_layout.index'
1819

@@ -33,6 +34,11 @@ const AppSettingsRoute = AppSettingsRouteImport.update({
3334
path: '/settings',
3435
getParentRoute: () => AppRoute,
3536
} as any)
37+
const AppAuthRoute = AppAuthRouteImport.update({
38+
id: '/auth',
39+
path: '/auth',
40+
getParentRoute: () => AppRoute,
41+
} as any)
3642
const AppMainLayoutRoute = AppMainLayoutRouteImport.update({
3743
id: '/_layout',
3844
getParentRoute: () => AppMainRoute,
@@ -45,31 +51,35 @@ const AppMainLayoutIndexRoute = AppMainLayoutIndexRouteImport.update({
4551

4652
export interface FileRoutesByFullPath {
4753
'/app': typeof AppRouteWithChildren
54+
'/app/auth': typeof AppAuthRoute
4855
'/app/settings': typeof AppSettingsRoute
4956
'/app/main': typeof AppMainLayoutRouteWithChildren
5057
'/app/main/': typeof AppMainLayoutIndexRoute
5158
}
5259
export interface FileRoutesByTo {
5360
'/app': typeof AppRouteWithChildren
61+
'/app/auth': typeof AppAuthRoute
5462
'/app/settings': typeof AppSettingsRoute
5563
'/app/main': typeof AppMainLayoutIndexRoute
5664
}
5765
export interface FileRoutesById {
5866
__root__: typeof rootRouteImport
5967
'/app': typeof AppRouteWithChildren
68+
'/app/auth': typeof AppAuthRoute
6069
'/app/settings': typeof AppSettingsRoute
6170
'/app/main': typeof AppMainRouteWithChildren
6271
'/app/main/_layout': typeof AppMainLayoutRouteWithChildren
6372
'/app/main/_layout/': typeof AppMainLayoutIndexRoute
6473
}
6574
export interface FileRouteTypes {
6675
fileRoutesByFullPath: FileRoutesByFullPath
67-
fullPaths: '/app' | '/app/settings' | '/app/main' | '/app/main/'
76+
fullPaths: '/app' | '/app/auth' | '/app/settings' | '/app/main' | '/app/main/'
6877
fileRoutesByTo: FileRoutesByTo
69-
to: '/app' | '/app/settings' | '/app/main'
78+
to: '/app' | '/app/auth' | '/app/settings' | '/app/main'
7079
id:
7180
| '__root__'
7281
| '/app'
82+
| '/app/auth'
7383
| '/app/settings'
7484
| '/app/main'
7585
| '/app/main/_layout'
@@ -103,6 +113,13 @@ declare module '@tanstack/react-router' {
103113
preLoaderRoute: typeof AppSettingsRouteImport
104114
parentRoute: typeof AppRoute
105115
}
116+
'/app/auth': {
117+
id: '/app/auth'
118+
path: '/auth'
119+
fullPath: '/app/auth'
120+
preLoaderRoute: typeof AppAuthRouteImport
121+
parentRoute: typeof AppRoute
122+
}
106123
'/app/main/_layout': {
107124
id: '/app/main/_layout'
108125
path: '/main'
@@ -144,11 +161,13 @@ const AppMainRouteWithChildren =
144161
AppMainRoute._addFileChildren(AppMainRouteChildren)
145162

146163
interface AppRouteChildren {
164+
AppAuthRoute: typeof AppAuthRoute
147165
AppSettingsRoute: typeof AppSettingsRoute
148166
AppMainRoute: typeof AppMainRouteWithChildren
149167
}
150168

151169
const AppRouteChildren: AppRouteChildren = {
170+
AppAuthRoute: AppAuthRoute,
152171
AppSettingsRoute: AppSettingsRoute,
153172
AppMainRoute: AppMainRouteWithChildren,
154173
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { createFileRoute } from "@tanstack/react-router";
2+
import { useCallback } from "react";
3+
4+
import { useAuth } from "../../auth";
5+
6+
export const Route = createFileRoute("/app/auth")({
7+
component: Component,
8+
});
9+
10+
function Component() {
11+
const auth = useAuth();
12+
13+
const hh = useCallback(async () => {
14+
if (auth?.supabase) {
15+
const { error } = await auth.supabase.auth.signUp({
16+
17+
password: "example-password",
18+
options: {
19+
emailRedirectTo: window.location.origin,
20+
},
21+
});
22+
console.error(error);
23+
}
24+
}, [auth?.supabase]);
25+
26+
return (
27+
<div>
28+
<pre>session: {JSON.stringify(auth?.session, null, 2)}</pre>
29+
<button
30+
onClick={hh}
31+
>
32+
signup
33+
</button>
34+
</div>
35+
);
36+
}

apps/desktop2/src/routes/app/settings.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
11
import { createFileRoute } from "@tanstack/react-router";
22

3+
import clsx from "clsx";
4+
import { z } from "zod";
35
import { useValidatedRow } from "../../hooks/useValidatedRow";
46
import * as persisted from "../../tinybase/store/persisted";
57

8+
const TABS = ["general", "calendar", "account"] as const;
9+
10+
const validateSearch = z.object({
11+
tab: z.enum(TABS).default("general"),
12+
});
13+
614
export const Route = createFileRoute("/app/settings")({
15+
validateSearch,
716
component: Component,
817
});
918

1019
function Component() {
20+
const search = Route.useSearch();
21+
const navigate = Route.useNavigate();
22+
23+
return (
24+
<div>
25+
<div className="flex flex-col gap-2">
26+
{TABS.map((tab) => (
27+
<button
28+
key={tab}
29+
className={clsx(["w-32 px-2 py-1 rounded", search.tab === tab && "bg-gray-200"])}
30+
onClick={() => navigate({ search: { tab } })}
31+
>
32+
{tab}
33+
</button>
34+
))}
35+
</div>
36+
{search.tab === "general" && <SettingsGeneral />}
37+
</div>
38+
);
39+
}
40+
41+
function SettingsGeneral() {
1142
const rowIds = persisted.UI.useResultRowIds(
1243
persisted.QUERIES.configForUser,
1344
persisted.STORE_ID,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "configPath": "../../dist/server/wrangler.json", "auxiliaryWorkers": [] }

0 commit comments

Comments
 (0)