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