diff --git a/src/App.jsx b/src/App.jsx index 3c52ccd..d7e1999 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -37,7 +37,7 @@ const App = () => { } /> } /> } /> - } /> + } /> } /> } /> } /> diff --git a/src/components/ConfirmationBar.jsx b/src/components/ConfirmationBar.jsx index 5c28e49..892a6eb 100644 --- a/src/components/ConfirmationBar.jsx +++ b/src/components/ConfirmationBar.jsx @@ -12,7 +12,7 @@ function ConfirmationBar({ orderNumber, isSuccesful }) { src={isSuccesful ? checkmark : xmark} /> -
+
{isSuccesful ? "Comanda nr " + diff --git a/src/components/Hero.js b/src/components/Hero.js index 07fd462..912a5f9 100644 --- a/src/components/Hero.js +++ b/src/components/Hero.js @@ -1,52 +1,52 @@ -import heroImage from '../images/hero_smile.png'; +import heroImage from "../images/hero_smile.png"; const Hero = () => { const heroStyle = { backgroundImage: `url(${heroImage})`, - backgroundSize: 'cover', - backgroundPosition: 'center', - margin: '0 auto', - position: 'relative', + backgroundSize: "cover", + backgroundPosition: "center", + margin: "0 auto", + position: "relative", }; const leftShadowGradientStyle = { content: '""', - position: 'absolute', + position: "absolute", top: 0, bottom: 0, - width: '60%', - background: 'linear-gradient(to right, rgba(0, 0, 0, 0.7), transparent)', - pointerEvents: 'none', + width: "60%", + background: "linear-gradient(to right, rgba(0, 0, 0, 0.7), transparent)", + pointerEvents: "none", }; const rightShadowGradientStyle = { content: '""', - position: 'absolute', + position: "absolute", top: 0, bottom: 0, - width: '25%', - background: 'linear-gradient(to left, rgba(0, 0, 0, 0.7), transparent)', - pointerEvents: 'none', + width: "25%", + background: "linear-gradient(to left, rgba(0, 0, 0, 0.7), transparent)", + pointerEvents: "none", }; const mobileLeftShadowGradientStyle = { content: '""', - position: 'absolute', + position: "absolute", top: 0, bottom: 0, - width: '40%', - background: 'linear-gradient(to right, rgba(0, 0, 0, 0.6), transparent)', - pointerEvents: 'none', + width: "40%", + background: "linear-gradient(to right, rgba(0, 0, 0, 0.6), transparent)", + pointerEvents: "none", }; const mobileRightShadowGradientStyle = { content: '""', - position: 'absolute', + position: "absolute", top: 0, bottom: 0, - width: '12%', - background: 'linear-gradient(to left, rgba(0, 0, 0, 0.4), transparent)', - pointerEvents: 'none', + width: "12%", + background: "linear-gradient(to left, rgba(0, 0, 0, 0.4), transparent)", + pointerEvents: "none", }; return ( @@ -55,14 +55,26 @@ const Hero = () => { style={heroStyle} > {/* Left shadow gradient */} -
+
{/* Right shadow gradient */} -
+
{/* Left shadow gradient */} -
+
{/* Right shadow gradient */} -
+
@@ -71,9 +83,9 @@ const Hero = () => {
- - CUMPĂRĂ EXPERIENȚE - + + CUMPĂRĂ EXPERIENȚE +
diff --git a/src/pages/Admin.js b/src/pages/Admin.js index fb9226d..12f6691 100644 --- a/src/pages/Admin.js +++ b/src/pages/Admin.js @@ -1,15 +1,15 @@ import React, { useState } from "react"; import ReactDOM from "react-dom"; -import useAuthentication from '../api/permissions'; -import axios_api from '../api/axios_api'; -import '../styles/styles.css'; -import { useNavigate } from 'react-router-dom'; +import useAuthentication from "../api/permissions"; +import axios_api from "../api/axios_api"; +import "../styles/styles.css"; +import { useNavigate } from "react-router-dom"; function Admin() { // React States const [errorMessages, setErrorMessages] = useState({}); const [isSubmitted, setIsSubmitted] = useState(false); - const [refreshToken, setRefreshToken] = useState(''); + const [refreshToken, setRefreshToken] = useState(""); const navigate = useNavigate(); const userRole = useAuthentication(); @@ -17,7 +17,7 @@ function Admin() { //Prevent page reload event.preventDefault(); - navigate("/adminAddService") + navigate("/adminAddService"); }; const handleDeleteService = async (event) => { @@ -26,21 +26,29 @@ function Admin() { var { email, pass } = document.forms[0]; localStorage.removeItem("token"); - axios_api.post("/login", { - email: email.value, - password: pass.value - }, {sameSite: 'none', withCredentials: true, - headers: { - // 'X-CSRFToken': csrfToken, // Set the CSRF token in the request headers - 'Content-Type': 'application/json' - }}) + axios_api + .post( + "/login", + { + email: email.value, + password: pass.value, + }, + { + sameSite: "none", + withCredentials: true, + headers: { + // 'X-CSRFToken': csrfToken, // Set the CSRF token in the request headers + "Content-Type": "application/json", + }, + } + ) .then((response) => { // Handle the response if (response.status == 200) { setIsSubmitted(true); - localStorage.setItem("token", response.data['access']); - localStorage.setItem("refresh", response.data['refresh']); - setRefreshToken(response.data['refresh']); + localStorage.setItem("token", response.data["access"]); + localStorage.setItem("refresh", response.data["refresh"]); + setRefreshToken(response.data["refresh"]); } else { console.log("Failed to send login data to the API"); } @@ -51,16 +59,18 @@ function Admin() { }); }; - if (userRole === 'admin' || userRole === 'staff') { + if (userRole === "admin" || userRole === "staff") { return (
-
This is the admin page. Please choose one of the following actions.
-
- -
-
- -
+
+ This is the admin page. Please choose one of the following actions. +
+
+ +
+
+ +
); } else { @@ -68,4 +78,4 @@ function Admin() { } } -export default Admin; \ No newline at end of file +export default Admin; diff --git a/src/pages/AdminAddService.js b/src/pages/AdminAddService.js index 4b77437..fee4723 100644 --- a/src/pages/AdminAddService.js +++ b/src/pages/AdminAddService.js @@ -1,14 +1,20 @@ -import React, { useState, useEffect, useRef } from "react"; -import axios_api from '../api/axios_api'; -import useAuthentication from '../api/permissions'; -import '../styles/styles.css'; -import { useNavigate } from 'react-router-dom'; -import { MapContainer, TileLayer, Marker, Popup, useMapEvents } from "react-leaflet"; -import L from 'leaflet'; -import marker_icon_png from '../images/marker_icon.png'; +import React, { useState, useEffect, useRef } from "react"; +import axios_api from "../api/axios_api"; +import useAuthentication from "../api/permissions"; +import "../styles/styles.css"; +import { useNavigate } from "react-router-dom"; +import { + MapContainer, + TileLayer, + Marker, + Popup, + useMapEvents, +} from "react-leaflet"; +import L from "leaflet"; +import marker_icon_png from "../images/marker_icon.png"; function AdminAddService() { - const initialQuestions = [ + const initialQuestions = [ "Ce include?", "Ce presupune?", "Ce face?", @@ -17,30 +23,30 @@ function AdminAddService() { ]; const categories = [ - 'Spiritualitate', - 'Excursii', - 'Sănătate', - 'Sport', - 'Divertisment', - 'Artă', - 'Cursuri de limbi străine', - 'Hobby', + "Spiritualitate", + "Excursii", + "Sănătate", + "Sport", + "Divertisment", + "Artă", + "Cursuri de limbi străine", + "Hobby", ]; const [formData, setFormData] = useState({ - name: '', - description: '', - image: '', + name: "", + description: "", + image: "", // ... Other fields from the Service model has_more_options: false, options_common_city: false, common_location: false, - location: '', - map_location: '', - city: '', - county: '', - category: '', - iban: '', + location: "", + map_location: "", + city: "", + county: "", + category: "", + iban: "", }); const [options, setOptions] = useState([]); const [selectedImage, setSelectedImage] = useState(null); @@ -81,27 +87,33 @@ function AdminAddService() { const markerIcon = new L.Icon({ iconUrl: marker_icon_png, iconRetinaUrl: marker_icon_png, - popupAnchor: [-0, -0], - iconSize: [25,25], -}); + popupAnchor: [-0, -0], + iconSize: [25, 25], + }); // Function to update the map location when the user selects a location const handleMapLocationChange = (e) => { setMapLocation([e.latlng.lat, e.latlng.lng]); setFormMarkerPosition([e.latlng.lat, e.latlng.lng]); - setFormData({ ...formData, map_location: `${e.latlng.lat}, ${e.latlng.lng}` }); + setFormData({ + ...formData, + map_location: `${e.latlng.lat}, ${e.latlng.lng}`, + }); }; - + const handleMarkerClick = (e) => { setFormMarkerPosition([e.latlng.lat, e.latlng.lng]); - setFormData({ ...formData, map_location: `${e.latlng.lat}, ${e.latlng.lng}` }); + setFormData({ + ...formData, + map_location: `${e.latlng.lat}, ${e.latlng.lng}`, + }); }; function MapEventsHandler({ handleMarkerClick }) { useMapEvents({ click: handleMarkerClick, }); - + return null; } @@ -152,7 +164,9 @@ function AdminAddService() { // Adjust the date to the desired timezone (Bucharest) const bucharestTimezoneOffset = -120; // Bucharest timezone offset in minutes (UTC+2) - selectedDate.setMinutes(selectedDate.getMinutes() - bucharestTimezoneOffset); + selectedDate.setMinutes( + selectedDate.getMinutes() - bucharestTimezoneOffset + ); // Format the date with the timezone offset const formattedDate = selectedDate.toISOString().slice(0, 16); @@ -165,50 +179,51 @@ function AdminAddService() { updatedOptions[index][name] = value; setOptions(updatedOptions); } - } - + }; + const handleRemoveOption = (index) => { const updatedOptions = [...options]; updatedOptions.splice(index, 1); setOptions(updatedOptions); }; - const handleAddService = async (event) => { event.preventDefault(); - + const formDataToSubmit = new FormData(); // Append all fields from formData Object.keys(formData).forEach((key) => { formDataToSubmit.append(key, formData[key]); }); - + // Append the image - formDataToSubmit.append('image', selectedImage); - + formDataToSubmit.append("image", selectedImage); + // Append other fields - formDataToSubmit.append('options', JSON.stringify(options)); + formDataToSubmit.append("options", JSON.stringify(options)); const sect = []; Object.keys(sectionText).forEach((section) => { sect.push({ question: section, answer: sectionText[section] }); }); - formDataToSubmit.append('sections', JSON.stringify({sections: sect})); - - axios_api.post("/create_service/", - formDataToSubmit - , {withCredentials: true, - headers: { - // 'X-CSRFToken': `${localStorage.getItem('csrftoken')}`, // Set the CSRF token in the request headers - 'Authorization': `Bearer ${localStorage.getItem('token')}`, - 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryEXAMPLE' - }}) + formDataToSubmit.append("sections", JSON.stringify({ sections: sect })); + + axios_api + .post("/create_service/", formDataToSubmit, { + withCredentials: true, + headers: { + // 'X-CSRFToken': `${localStorage.getItem('csrftoken')}`, // Set the CSRF token in the request headers + Authorization: `Bearer ${localStorage.getItem("token")}`, + "Content-Type": + "multipart/form-data; boundary=----WebKitFormBoundaryEXAMPLE", + }, + }) .then((response) => { // Handle the response if (response.status == 200) { setIsSubmitted(true); - // navigate("/admin") + // navigate("/admin") } else { console.log("Failed to create service."); } @@ -224,8 +239,6 @@ function AdminAddService() { setSelectedImage(file); }; - - const renderSectionDropdown = () => (