- Wrap application root with IDBProvider and GuideProvider
- Replace mock data in App component with real guides from useGuides hook
- Update useNewGuide hook to save compiled guides to IndexedDB and update global state
19 lines
439 B
TypeScript
19 lines
439 B
TypeScript
import { openDB, type DBSchema, type IDBPDatabase } from "idb";
|
|
import type { CompiledGuideType } from "./schemas";
|
|
|
|
export interface MyDB extends DBSchema {
|
|
guides: {
|
|
key: string;
|
|
value: CompiledGuideType;
|
|
};
|
|
}
|
|
|
|
export type AppDB = IDBPDatabase<MyDB>;
|
|
|
|
export function initDB(): Promise<AppDB> {
|
|
return openDB<MyDB>("my-guides", 1, {
|
|
upgrade(db) {
|
|
db.createObjectStore("guides", { keyPath: "id" });
|
|
},
|
|
});
|
|
}
|