forked from RiseUP/riseup-squad21
Merge pull request 'ajustes simples' (#10) from refatoracao-doctor into refatoração
Reviewed-on: #10
This commit is contained in:
commit
0174189d6d
@ -49,8 +49,7 @@ export default function PatientDashboard() {
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
// TODO: Remover ID fixo e obter do usuário logado
|
||||
const doctorId = "3bb9ee4a-cfdd-4d81-b628-383907dfa225";
|
||||
const doctorId = JSON.parse(localStorage.getItem("user_info") || "{}")?.id;;
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
|
||||
@ -19,7 +19,7 @@ export default function AvailabilityPage() {
|
||||
const router = useRouter();
|
||||
|
||||
// TODO: Substituir pelo ID do médico autenticado
|
||||
const doctorIdTemp = "3bb9ee4a-cfdd-4d81-b628-383907dfa225";
|
||||
const doctorId = JSON.parse(localStorage.getItem("user_info") || "{}")?.id;
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
@ -47,8 +47,8 @@ export default function AvailabilityPage() {
|
||||
|
||||
const formData = new FormData(e.currentTarget);
|
||||
const apiPayload = {
|
||||
doctor_id: doctorIdTemp,
|
||||
created_by: doctorIdTemp, // TODO: Substituir pelo ID do usuário autenticado
|
||||
doctor_id: doctorId,
|
||||
created_by: doctorId, // TODO: Substituir pelo ID do usuário autenticado
|
||||
weekday: (formData.get("weekday") as string) || undefined,
|
||||
start_time: (formData.get("horarioEntrada") as string) || undefined,
|
||||
end_time: (formData.get("horarioSaida") as string) || undefined,
|
||||
@ -68,8 +68,8 @@ export default function AvailabilityPage() {
|
||||
setError(err?.message || "Não foi possível cadastrar a disponibilidade.");
|
||||
toast({
|
||||
title: "Erro",
|
||||
description: err?.message || "Não foi possível cadastrar a disponibilidade.",
|
||||
variant: "destructive",
|
||||
description: err?.message || "Não foi possível cadastrar a disponibilidade.",
|
||||
|
||||
});
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
|
||||
@ -45,7 +45,7 @@ export function LoginForm({ children }: LoginFormProps) {
|
||||
const handleRoleSelection = (selectedDashboardRole: string) => {
|
||||
const user = authenticatedUser;
|
||||
if (!user) {
|
||||
toast({ title: "Erro de Sessão", description: "Não foi possível encontrar os dados do usuário. Tente novamente.", variant: "destructive" });
|
||||
toast({ title: "Erro de Sessão", description: "Não foi possível encontrar os dados do usuário. Tente novamente."});
|
||||
setUserRoles([]); // Volta para a tela de login
|
||||
return;
|
||||
}
|
||||
@ -68,7 +68,7 @@ export function LoginForm({ children }: LoginFormProps) {
|
||||
toast({ title: `Entrando como ${selectedDashboardRole}...` });
|
||||
router.push(redirectPath);
|
||||
} else {
|
||||
toast({ title: "Erro", description: "Perfil selecionado inválido.", variant: "destructive" });
|
||||
toast({ title: "Erro", description: "Perfil selecionado inválido."});
|
||||
}
|
||||
};
|
||||
|
||||
@ -148,8 +148,7 @@ export function LoginForm({ children }: LoginFormProps) {
|
||||
|
||||
toast({
|
||||
title: "Erro no Login",
|
||||
description: error instanceof Error ? error.message : "Ocorreu um erro inesperado.",
|
||||
variant: "destructive",
|
||||
description: error instanceof Error ? error.message : "Ocorreu um erro inesperado."
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
||||
@ -31,7 +31,7 @@ const toastVariants = cva(
|
||||
variant: {
|
||||
default: 'border bg-background text-foreground',
|
||||
destructive:
|
||||
'destructive group border-destructive bg-destructive text-destructive-foreground',
|
||||
'destructive group border-destructive bg-destructive text-foreground',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
|
||||
@ -12,12 +12,12 @@ export interface Availability {
|
||||
|
||||
export const disponibilidadeApi = {
|
||||
list: async (): Promise<Availability[]> => {
|
||||
const response = await api.get<Availability[]>('/rest/v1/doctor_availability?select=*');
|
||||
const response = await api.get<Availability[]>('/rest/v1/doctor_availability');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getById: async (id: string): Promise<Availability> => {
|
||||
const response = await api.get<Availability>(`/rest/v1/doctor_availability?id=eq.${id}&select=*`, {
|
||||
const response = await api.get<Availability>(`/rest/v1/doctor_availability?id=eq.${id}`, {
|
||||
headers: { Accept: 'application/vnd.pgrst.object+json' },
|
||||
});
|
||||
return response.data;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user