import { Head, Link } from '@inertiajs/react'; import { useEffect, useState } from 'react'; import { type BreadcrumbItem } from '@/types'; import AppLayout from '@/layouts/app-layout'; import AttachmentsList from '@/components/attachments-list'; const breadcrumbs: BreadcrumbItem[] = [ { title: 'Strona Główna', href: '/', }, { title: 'Oferty pracy', href: '/oferty-pracy', }, ]; interface Attachment { id: number; file_name: string; file_path: string; file_size: number; file_type: string; created_at: string; updated_at: string; } interface Photo { id: number; image_name: string; image_path: string; image_size: number; image_type: string; created_at: string; updated_at: string; } interface JobOffer { id: number; title: string; slug: string; thumbnail: string; body: string; active: boolean; published_at: string; created_at: string; updated_at: string; user_id: number; attachments?: Attachment[]; photos?: Photo[]; } interface JobOffersApiResponse { jobOffers: JobOffer[]; } export default function JobOffers() { const [jobOffers, setJobOffers] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { setLoading(true); fetch(`/api/joboffers`) .then(response => response.json()) .then(data => { setJobOffers(data); setLoading(false); }) .catch(error => { setJobOffers(null); setLoading(false); console.error('Error fetching job offers data:', error); }); }, []); return (

Oferty pracy

{loading ? (
Wczytywanie...
) : !jobOffers || jobOffers.jobOffers.length === 0 ? (
Brak ofert pracy.
) : (
{jobOffers.jobOffers.map((jobOffer) => { return (

{jobOffer.title}

Data publikacji: {new Date(jobOffer.published_at).toLocaleDateString('pl-PL')}
); })}
)}
); }