feat: order comments, duplicate button, improved status timeline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 11:37:45 +03:00
parent 12cca64f61
commit b2dd497d1f
3 changed files with 160 additions and 11 deletions
+30
View File
@@ -0,0 +1,30 @@
import { useState, useEffect, useCallback } from 'react';
import { supabase } from '../../lib/supabase';
export function useOrderComments(orderId) {
const [comments, setComments] = useState([]);
const [loading, setLoading] = useState(false);
const fetch = useCallback(async () => {
if (!orderId) return;
const { data } = await supabase
.from('order_comments')
.select('*')
.eq('order_id', orderId)
.order('created_at', { ascending: true });
setComments(data ?? []);
}, [orderId]);
useEffect(() => { fetch(); }, [fetch]);
const addComment = async (author, body) => {
setLoading(true);
const { error } = await supabase.from('order_comments')
.insert({ order_id: orderId, author, body });
if (!error) await fetch();
setLoading(false);
return { error };
};
return { comments, loading, addComment };
}