2025-06-01 20:55:44 +03:00
|
|
|
|
import {Link, useParams} from 'react-router-dom';
|
2025-06-02 19:39:54 +03:00
|
|
|
|
import { Institution, Profession, Specialty } from '../../types/survey.ts';
|
2025-06-01 16:48:44 +03:00
|
|
|
|
import ReactMarkdown from 'react-markdown';
|
2025-06-02 19:39:54 +03:00
|
|
|
|
import { LoadingData } from '../../components/LoadingData.tsx';
|
|
|
|
|
|
import { LoadingList } from '../../components/LoadingList.tsx';
|
|
|
|
|
|
import {useCachedData, useData, useDataPage} from "../../API/hooks.ts";
|
2025-06-01 16:48:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function ProfessionPage() {
|
|
|
|
|
|
const { professionId } = useParams<{ professionId: string }>();
|
|
|
|
|
|
const profession = useData<Profession>('surveys', 'professions', professionId || 0);
|
|
|
|
|
|
const specialties = useDataPage<Specialty>('surveys', 'specialties', { profession: professionId || 0 }, !!profession);
|
|
|
|
|
|
|
2025-06-01 20:55:44 +03:00
|
|
|
|
const institutions = useCachedData<Institution>("surveys", "institutions");
|
2025-06-01 16:48:44 +03:00
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<LoadingData data={profession}>
|
|
|
|
|
|
<h1>{profession?.name}</h1>
|
|
|
|
|
|
<div className="description">
|
|
|
|
|
|
<ReactMarkdown>{profession?.description || ''}</ReactMarkdown>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="specialties-block">
|
2025-06-01 20:55:44 +03:00
|
|
|
|
{specialties.items != null ? <h2>Где можно обучиться</h2>:null}
|
2025-06-01 16:48:44 +03:00
|
|
|
|
<LoadingList
|
|
|
|
|
|
data={specialties.items}
|
2025-06-01 20:55:44 +03:00
|
|
|
|
listElement={specialty => (
|
2025-06-01 16:48:44 +03:00
|
|
|
|
<SpecialtyBlock
|
|
|
|
|
|
key={specialty.id}
|
|
|
|
|
|
specialty={specialty as Specialty}
|
2025-06-02 17:30:35 +03:00
|
|
|
|
institution={institutions.get((specialty as Specialty).institution)}
|
2025-06-01 16:48:44 +03:00
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</LoadingData>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function SpecialtyBlock({
|
|
|
|
|
|
specialty,
|
|
|
|
|
|
institution,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
specialty: Specialty;
|
2025-06-01 20:55:44 +03:00
|
|
|
|
institution: Institution | undefined | null;
|
2025-06-01 16:48:44 +03:00
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="specialty-block">
|
2025-06-01 20:55:44 +03:00
|
|
|
|
<h3>Учебное заведение: {institution?.name || 'Загрузка...'}</h3>
|
|
|
|
|
|
<p className={"specialty-name"}>{specialty.name}</p>
|
|
|
|
|
|
{specialty.link?<Link to={specialty.link} className={"site"}>Открыть сайт</Link>:null}
|
|
|
|
|
|
|
2025-06-01 16:48:44 +03:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|