diff --git a/src/components/AddJobListing.jsx b/src/components/AddJobListing.jsx index 61275a4..d4640a8 100644 --- a/src/components/AddJobListing.jsx +++ b/src/components/AddJobListing.jsx @@ -6,8 +6,8 @@ import StepFourJoblisting from './StepFourJoblisting' const AddJobListing = () => { const [currentStep, setCurrentStep] = useState(1) const [formData, setFormData] = useState({ - 'postingOption': 'Opcja 2', - 'requireSalary': true + 'posting_option': 'S', + 'requiresalary': true }) const nextStep = () => { setCurrentStep(currentStep + 1); diff --git a/src/components/ImageUpload.jsx b/src/components/ImageUpload.jsx index d14ae87..acef528 100644 --- a/src/components/ImageUpload.jsx +++ b/src/components/ImageUpload.jsx @@ -1,16 +1,19 @@ import React, { useState, useRef, useEffect } from 'react'; -import { IzaacLOGO, placeholderImage } from '../assets' +import { placeholderImage } from '../assets'; +import axios from 'axios'; -const ImageUpload = ({setFormData}) => { + +const ImageUpload = ({setFormData, data}) => { const [imageSrc, setImageSrc] = useState(placeholderImage); const fileInputRef = useRef(); // Referencja do ukrytego inputu plików - const handleImageChange = (e) => { + const handleImageChange = async (e) => { const file = e.target.files[0]; if (file) { const reader = new FileReader(); - reader.onload = (e) => { - setImageSrc(e.target.result); // Aktualizujemy stan obrazkiem użytkownika + reader.onload = async (e) => { + // Aktualizujemy stan obrazkiem użytkownika + const uploadedImageData = await uploadImage(file); }; reader.readAsDataURL(file); } @@ -20,6 +23,25 @@ const ImageUpload = ({setFormData}) => { fileInputRef.current.click(); // Programowe kliknięcie na ukrytym inpucie plików }; + const uploadImage = async (imageFile) => { + const formData = new FormData(); + formData.append('company_logo', imageFile); + formData.append('company_name', data.company_name) + try { + const response = await axios.post('http://izaac.izaac.pl/api/jobposting/companylogo/', formData, { + headers: { + "Content-Type": 'multipart/form-data' + } + }); + console.log(response) + const url = response.data.company_logo + setImageSrc(url) + } + catch (error) { + console.error('Błąd podczas przesyłania obrazka:', e) + } + } + useEffect(() => { // Aktualizujemy dane w hooku nadrzędnym za każdym razem, gdy zmienia się imageSrc if (imageSrc !== placeholderImage) { diff --git a/src/components/NavBar.jsx b/src/components/NavBar.jsx index 1155468..9d94ae7 100644 --- a/src/components/NavBar.jsx +++ b/src/components/NavBar.jsx @@ -28,7 +28,10 @@ const NavBar = () => { {currentLinks.map((nav, index) => (
  • {nav.title}
  • @@ -50,12 +53,18 @@ const NavBar = () => { alt="menu" className='w-[28px] h-[28px] object-contain' onClick={() => setToggle((prev) => !prev)}/> -
    -