🚀 Auto-deploy: GPI atualizado em 03/04/2026 20:24:53
This commit is contained in:
@@ -33,13 +33,18 @@ export const createProject = async (data: ProjectData & { organizationId?: strin
|
|||||||
|
|
||||||
export const getAllProjects = async (organizationId?: string, isGlobalAdmin?: boolean, status?: string) => {
|
export const getAllProjects = async (organizationId?: string, isGlobalAdmin?: boolean, status?: string) => {
|
||||||
try {
|
try {
|
||||||
const { data: projects, error } = await supabase
|
let query = supabase
|
||||||
.from('projects')
|
.from('projects')
|
||||||
.select('*');
|
.select('*, painting_schemes(*)');
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
query = query.eq('status', status);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: projects, error } = await query;
|
||||||
|
|
||||||
// Se tabela não existir, retorna array vazio
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log('Projects table not found, returning empty array');
|
console.log('Error fetching projects:', error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +59,7 @@ export const getDashboardProjects = async (organizationId?: string) => {
|
|||||||
try {
|
try {
|
||||||
const { data: projects, error } = await supabase
|
const { data: projects, error } = await supabase
|
||||||
.from('projects')
|
.from('projects')
|
||||||
.select('*');
|
.select('*, painting_schemes(*)');
|
||||||
|
|
||||||
if (error) return [];
|
if (error) return [];
|
||||||
return projects || [];
|
return projects || [];
|
||||||
@@ -91,7 +96,7 @@ export const archiveProject = async (id: string, organizationId?: string, isGlob
|
|||||||
export const getProjectById = async (id: string) => {
|
export const getProjectById = async (id: string) => {
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('projects')
|
.from('projects')
|
||||||
.select('*')
|
.select('*, painting_schemes(*)')
|
||||||
.eq('id', id)
|
.eq('id', id)
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user