mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-11-02 02:19:43 +00:00
Add drag-and-drop reordering to categories page
- Replace up/down chevron buttons with @dnd-kit drag handles - Update pack generation and question review commands - Fix MCP bridge and add supabase package.json for Docker Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e05105bb0
commit
3009e80dd4
13 files changed
+1125
-1281
No files matched your search
@@ -12,6 +12,7 @@ export interface Question {
|
||||
intensity: number;
|
||||
pack_id: string;
|
||||
created_at: string | null;
|
||||
deleted_at: string | null;
|
||||
}
|
||||
|
||||
export interface QuestionFormData {
|
||||
@@ -25,15 +26,21 @@ export interface QuestionFormData {
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Fetch all questions for a pack
|
||||
* Fetch all questions for a pack (excludes soft-deleted by default)
|
||||
*/
|
||||
export async function fetchQuestionsForPack(packId: string): Promise<Question[]> {
|
||||
const { data, error } = await supabase
|
||||
export async function fetchQuestionsForPack(packId: string, includeDeleted = false): Promise<Question[]> {
|
||||
let query = supabase
|
||||
.from('questions')
|
||||
.select('*')
|
||||
.eq('pack_id', packId)
|
||||
.order('created_at', { ascending: true });
|
||||
|
||||
if (!includeDeleted) {
|
||||
query = query.is('deleted_at', null);
|
||||
}
|
||||
|
||||
const { data, error } = await query;
|
||||
|
||||
if (error) throw error;
|
||||
return data || [];
|
||||
}
|
||||
@@ -53,13 +60,14 @@ export async function fetchQuestionById(id: string): Promise<Question | null> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch question count for a pack
|
||||
* Fetch question count for a pack (excludes soft-deleted)
|
||||
*/
|
||||
export async function fetchQuestionCount(packId: string): Promise<number> {
|
||||
const { count, error } = await supabase
|
||||
.from('questions')
|
||||
.select('*', { count: 'exact', head: true })
|
||||
.eq('pack_id', packId);
|
||||
.eq('pack_id', packId)
|
||||
.is('deleted_at', null);
|
||||
|
||||
if (error) throw error;
|
||||
return count || 0;
|
||||
@@ -105,22 +113,36 @@ export async function updateQuestion(
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a question
|
||||
* Soft delete a question (sets deleted_at timestamp)
|
||||
*/
|
||||
export async function deleteQuestion(id: string): Promise<void> {
|
||||
const { error } = await auditedSupabase.delete('questions', id);
|
||||
const { error } = await auditedSupabase.update('questions', id, {
|
||||
deleted_at: new Date().toISOString(),
|
||||
});
|
||||
if (error) throw error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete multiple questions
|
||||
* Soft delete multiple questions
|
||||
*/
|
||||
export async function deleteQuestions(ids: string[]): Promise<void> {
|
||||
await Promise.all(
|
||||
ids.map(id => auditedSupabase.delete('questions', id))
|
||||
ids.map(id => auditedSupabase.update('questions', id, {
|
||||
deleted_at: new Date().toISOString(),
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a soft-deleted question
|
||||
*/
|
||||
export async function restoreQuestion(id: string): Promise<void> {
|
||||
const { error } = await auditedSupabase.update('questions', id, {
|
||||
deleted_at: null,
|
||||
});
|
||||
if (error) throw error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk create questions (for AI generation)
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user