Skip to content

Commit

Permalink
feat: add new services
Browse files Browse the repository at this point in the history
  • Loading branch information
ialexanderbrito committed Apr 6, 2022
1 parent 2d08976 commit 58792e1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 19 deletions.
19 changes: 19 additions & 0 deletions src/services/get/cliente.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { supabase } from 'services/supabase';

export async function getCliente(id: string) {
const { data, error, status } = await supabase.rpc('busca_filtrada_usuarios', {
p_id: id,
p_name: '',
p_ocupacao: 'cliente',
p_fullname: '',
p_email: '',
p_picture: '',
p_avatar_url: '',
p_page: 0,
p_limit: 10,
p_orderby: 'name',
p_ascordsc: 'asc',
});

return { data, error, status };
}
19 changes: 0 additions & 19 deletions src/services/get/clientes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,3 @@ export async function getClientes(barberId: string, selectDayFormatted: string)

return { data, error, status };
}

export async function getHorarioMarcadoCliente(clientId: string, selectDayFormatted: string) {
const { data, error, status } = await supabase.rpc('busca_filtrada_schedules', {
p_id: [],
p_barber_id: [],
p_client_id: [clientId],
p_dt_inicio:
atualDayFormatted === selectDayFormatted
? `${selectDayFormatted}T${atualHourFormatted}`
: `${selectDayFormatted}T00:00`,
p_dt_fim: `${selectDayFormatted}T23:59`,
p_page: 0,
p_limit: 10,
p_orderby: 'hour',
p_ascordsc: 'asc',
});

return { data, error, status };
}
41 changes: 41 additions & 0 deletions src/services/get/horarioMarcado.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { format } from 'date-fns';

import { supabase } from 'services/supabase';

const atualDayFormatted = format(new Date(), 'yyyy-MM-dd');
const atualHourFormatted = format(new Date(), 'HH:mm');

export async function getHorarioMarcadoCliente(clientId: string, selectDayFormatted: string) {
const { data, error, status } = await supabase.rpc('busca_filtrada_schedules', {
p_id: [],
p_barber_id: [],
p_client_id: [clientId],
p_dt_inicio:
atualDayFormatted === selectDayFormatted
? `${selectDayFormatted}T${atualHourFormatted}`
: `${selectDayFormatted}T00:00`,
p_dt_fim: `${selectDayFormatted}T23:59`,
p_page: 0,
p_limit: 10,
p_orderby: 'hour',
p_ascordsc: 'asc',
});

return { data, error, status };
}

export async function getHorarioSelecionado(clientId: string, selectDayFormatted: string, hour: string) {
const { data, error, status } = await supabase.rpc('busca_filtrada_schedules', {
p_id: [],
p_barber_id: [],
p_client_id: [clientId],
p_dt_inicio: `${selectDayFormatted}T${hour}`,
p_dt_fim: `${selectDayFormatted}T${hour}`,
p_page: 0,
p_limit: 10,
p_orderby: 'hour',
p_ascordsc: 'asc',
});

return { data, error, status };
}

0 comments on commit 58792e1

Please sign in to comment.