feat: add authenticated settings page.

This commit is contained in:
liqupan
2026-02-02 20:12:19 +08:00
parent cb3e16cd16
commit 6c32d845a7
259 changed files with 24685 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
import { supabase } from '@/lib/supabase';
import { Character } from './schema';
export async function getCharacters() {
const { data, error } = await supabase
.from('characters')
.select('*')
.order('created_at', { ascending: false });
if (error) {
throw error;
}
// Optimize: validate schema? For now trust Supabase or partial validate
return data as Character[];
}
export async function createCharacter(character: Omit<Character, 'id' | 'created_at' | 'updated_at'>) {
const { data, error } = await supabase
.from('characters')
.insert(character)
.select()
.single();
if (error) {
throw error;
}
return data;
}
export async function updateCharacter(character: Character) {
const { id, ...updates } = character;
if (!id) throw new Error('ID is required for update');
const { data, error } = await supabase
.from('characters')
.update(updates)
.eq('id', id)
.select()
.single();
if (error) {
throw error;
}
return data;
}
export async function deleteCharacter(id: string) {
const { error } = await supabase
.from('characters')
.delete()
.eq('id', id);
if (error) {
throw error;
}
}