import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuthStore } from '../stores/authStore';

export default function MyClinicPage() {
  const { dbUuid, fetchMe } = useAuthStore();
  const navigate = useNavigate();

  useEffect(() => {
    if (dbUuid) {
      navigate(`/admin/clinics/${dbUuid}`, { replace: true });
    } else {
      fetchMe().then(() => {
        const uuid = useAuthStore.getState().dbUuid;
        if (uuid) navigate(`/admin/clinics/${uuid}`, { replace: true });
      });
    }
  }, [dbUuid, fetchMe, navigate]);

  return (
    <div style={{ padding: 40, textAlign: 'center' }}>
      <p style={{ color: 'var(--text-3)', fontSize: 14 }}>در حال بارگذاری اطلاعات کلینیک...</p>
    </div>
  );
}
