Skip to content

Commit

Permalink
feat: add buscar agendamento por dia
Browse files Browse the repository at this point in the history
  • Loading branch information
ialexanderbrito committed Apr 5, 2022
1 parent 673a4c4 commit 3f07840
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/contexts/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,28 @@ export function UserProvider({ children }: any) {
setStatus('success');
}

async function buscarAgendamentosData(diaSelecionado: string) {
if (!clientId) return;

const { data, error, status } = await getHorarioMarcadoCliente(clientId, diaSelecionado);

if (error) {
switch (status) {
default:
throw new Error('Erro ao buscar clientes');
}
}

if (!data) return;

if (data[0].j === null) {
setHorariosAgendados([]);
throw new Error('Erro ao buscar clientes');
}

setHorariosAgendados(data[0].j);
}

useEffect(() => {
buscarBarbeiros();
}, []);
Expand Down Expand Up @@ -306,6 +328,7 @@ export function UserProvider({ children }: any) {
isDataEHorarioPassado,
verificaDataEHoraSelecionada,
horariosAgendados,
buscarAgendamentosData,
}}
>
{children}
Expand Down

0 comments on commit 3f07840

Please sign in to comment.