initial commit
This commit is contained in:
20
src/components/SeedInitializer.tsx
Normal file
20
src/components/SeedInitializer.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useMutation } from "convex/react";
|
||||
import { api } from "../../convex/_generated/api";
|
||||
|
||||
/** Legt Standard-Kategorien an, sobald die Auth-Session am Client aktiv ist. */
|
||||
export function SeedInitializer() {
|
||||
const ensureSeeded = useMutation(api.users.ensureSeeded);
|
||||
const ran = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (ran.current) return;
|
||||
ran.current = true;
|
||||
void ensureSeeded({}).catch((error) => {
|
||||
ran.current = false;
|
||||
console.error("ensureSeeded fehlgeschlagen:", error);
|
||||
});
|
||||
}, [ensureSeeded]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user