fix: hooks de listagem de OFs modificados para buscar dados diretos de ordens_fabricacao ativas em vez de ficha_tecnica, inibindo exibir OFs removidas ou excluidas no dropdown, conforme solicitado na revisão
This commit is contained in:
+16
-5
@@ -182,17 +182,28 @@ export const useTasks = () => {
|
||||
queryFn: async () => {
|
||||
console.log('🔍 Fetching available OFs...');
|
||||
const { data, error } = await supabase
|
||||
.from('ficha_tecnica_contratos')
|
||||
.select('of_number, cliente')
|
||||
.order('of_number');
|
||||
.from('ordens_fabricacao')
|
||||
.select(`
|
||||
num_of,
|
||||
ficha_tecnica_contratos (
|
||||
cliente
|
||||
)
|
||||
`)
|
||||
.eq('status', 'ativa')
|
||||
.order('num_of');
|
||||
|
||||
if (error) {
|
||||
console.error('❌ Error fetching OFs:', error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log('✅ Available OFs fetched:', data?.length || 0);
|
||||
return data || [];
|
||||
const mappedData = data?.map((of: any) => ({
|
||||
of_number: of.num_of,
|
||||
cliente: of.ficha_tecnica_contratos?.cliente
|
||||
}));
|
||||
|
||||
console.log('✅ Available OFs fetched:', mappedData?.length || 0);
|
||||
return mappedData || [];
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user