feat: authentication integration

This commit is contained in:
2025-05-28 20:51:34 +02:00
parent a1ed1113d9
commit aa152a4127
26 changed files with 1371 additions and 662 deletions

29
web/src/store/db.ts Normal file
View File

@ -0,0 +1,29 @@
import { openDB, type IDBPDatabase } from "idb";
import { create } from "zustand";
export interface IDbStore {
db: IDBPDatabase | null;
connecting: boolean;
connect: () => void;
}
export const useDbStore = create<IDbStore>((set, get) => ({
db: null,
connecting: false,
connect: async () => {
if (get().connecting) return;
set({ connecting: true, db: null });
const dbPromise = openDB("guard-local", 3, {
upgrade: (db) => {
if (!db.objectStoreNames.contains("accounts")) {
db.createObjectStore("accounts", { keyPath: "accountId" });
}
},
});
const conn = await dbPromise;
set({ db: conn, connecting: false });
},
}));