import React, {useState, useEffect} from 'react' import {Header} from "./Header"; import {Link, useNavigate} from "react-router-dom"; import {Button, Card, DatePicker, Form, Image, Input, Modal, notification, Rate, Spin} from "antd"; import placeholderImage from '../src/Assets/placeholder.png' import AddNewReservation from "./Dashboard/AddNewReservation"; import axios from "axios"; import env from "./env"; import Review from "./Dashboard/Review"; const FrontPage = ({user, logout}) => { const [restaurant, setRestaurant] = useState({name:'Sample Restaurant name', address: 'Sample street 1', city:'Sample'}); const [newReservationModal, setNewReservationModal] = useState(false); const [saveModalLoading, setSaveModalLoading] = useState(false); const [newReviewModal, setNewReviewModal] = useState(false); const [loading, setLoading] = useState(true); const [refreshToggle, setRefreshToggle] = useState(false); const history = useNavigate(); useEffect(()=>{ setLoading(true); axios.get(env.api + 'Restaurants').then(res=>{ setRestaurant(res.data); setLoading(false); }); },[]) useEffect(()=>{ if(user && !user.isConfirmed) { notification['warning']({ message:
Вашиот емаил не е потврден. Потврдете го тука
}); } },[user]) const saveNewReview = data =>{ setSaveModalLoading(true) axios.post(env.api + 'Reviews',data,{ headers: {Authorization: localStorage.getItem('Auth')}}).then(res=>{ setNewReviewModal(false) setSaveModalLoading(false) notification['success']({ message: 'Успешно зачувано', }); setRefreshToggle(ref => !ref); }).catch(err=>{ setSaveModalLoading(false) notification['error']({ message: 'Се случи проблем при зачувување', }); }); } return({el.description}
{el.price} ден.