import type { IDBPDatabase } from "idb";
import { createContext, useContext } from "react";

interface DbContextValues {
  db: IDBPDatabase | null;
  connected: boolean;
  setDb: (db: IDBPDatabase) => void;
}

export const DbContext = createContext<DbContextValues>({
  db: null,
  connected: false,
  setDb: () => {},
});

export const useDbContext = () => useContext(DbContext);
