feat: adicionar auto-load de avatar nos painéis de paciente e médico
This commit is contained in:
parent
4fbfc278bb
commit
7c68682e97
BIN
MEDICONNECT 2/avatar_download_test.png
Normal file
BIN
MEDICONNECT 2/avatar_download_test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 472 KiB |
@ -24,6 +24,7 @@ import { appointmentService, doctorService, reportService } from "../services";
|
||||
import type { Report } from "../services/reports/types";
|
||||
import AgendamentoConsulta from "../components/AgendamentoConsulta";
|
||||
import { AvatarUpload } from "../components/ui/AvatarUpload";
|
||||
import { avatarService } from "../services/avatars/avatarService";
|
||||
|
||||
interface Consulta {
|
||||
_id: string;
|
||||
@ -78,6 +79,33 @@ const AcompanhamentoPaciente: React.FC = () => {
|
||||
if (!user || !isPaciente) navigate("/paciente");
|
||||
}, [user, roles, navigate]);
|
||||
|
||||
// Carregar avatar ao montar componente
|
||||
useEffect(() => {
|
||||
if (user?.id) {
|
||||
// Tenta carregar avatar existente (testa png, jpg, webp)
|
||||
const extensions = ["png", "jpg", "webp"];
|
||||
const testAvatar = async () => {
|
||||
for (const ext of extensions) {
|
||||
try {
|
||||
const url = avatarService.getPublicUrl({
|
||||
userId: user.id,
|
||||
ext: ext as "jpg" | "png" | "webp"
|
||||
});
|
||||
const response = await fetch(url, { method: "HEAD" });
|
||||
if (response.ok) {
|
||||
setAvatarUrl(url);
|
||||
console.log(`[AcompanhamentoPaciente] Avatar encontrado: ${url}`);
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
// Continua testando próxima extensão
|
||||
}
|
||||
}
|
||||
};
|
||||
testAvatar();
|
||||
}
|
||||
}, [user?.id]);
|
||||
|
||||
const fetchConsultas = useCallback(async () => {
|
||||
if (!pacienteId) return;
|
||||
setLoading(true);
|
||||
|
||||
@ -36,6 +36,7 @@ import { useAuth } from "../hooks/useAuth";
|
||||
import DisponibilidadeMedico from "../components/DisponibilidadeMedico";
|
||||
import ConsultaModal from "../components/consultas/ConsultaModal";
|
||||
import { AvatarUpload } from "../components/ui/AvatarUpload";
|
||||
import { avatarService } from "../services/avatars/avatarService";
|
||||
|
||||
// Type aliases para compatibilidade
|
||||
type ServiceConsulta = Appointment;
|
||||
@ -100,6 +101,33 @@ const PainelMedico: React.FC = () => {
|
||||
if (!medicoId) navigate("/login-medico");
|
||||
}, [medicoId, navigate]);
|
||||
|
||||
// Carregar avatar ao montar componente
|
||||
useEffect(() => {
|
||||
if (user?.id) {
|
||||
// Tenta carregar avatar existente (testa png, jpg, webp)
|
||||
const extensions = ["png", "jpg", "webp"];
|
||||
const testAvatar = async () => {
|
||||
for (const ext of extensions) {
|
||||
try {
|
||||
const url = avatarService.getPublicUrl({
|
||||
userId: user.id,
|
||||
ext: ext as "jpg" | "png" | "webp"
|
||||
});
|
||||
const response = await fetch(url, { method: "HEAD" });
|
||||
if (response.ok) {
|
||||
setAvatarUrl(url);
|
||||
console.log(`[PainelMedico] Avatar encontrado: ${url}`);
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
// Continua testando próxima extensão
|
||||
}
|
||||
}
|
||||
};
|
||||
testAvatar();
|
||||
}
|
||||
}, [user?.id]);
|
||||
|
||||
const fetchConsultas = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user