Changeset e35d0e9


Ignore:
Timestamp:
03/03/24 20:18:46 (15 months ago)
Author:
Aleksandar Panovski <apano77@…>
Branches:
main
Children:
a7d40aa
Parents:
9293100
Message:

RetaurantServiceImpl problemi
isAvailable od tableEntity...

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • my-react-app/src/App.js

    r9293100 re35d0e9  
    1 import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
     1import {BrowserRouter as Router, Route, Routes, useNavigate} from 'react-router-dom';
    22import Customers from './components/Customers';
    33import Layout from "./components/Layout";
     
    3939
    4040const Home = () => {
     41    const navigate = useNavigate();
     42
    4143    const todayDate = new Date().toISOString().split('T')[0]; // Get today's date in 'YYYY-MM-DD' format
    4244
    4345    const [date, setDate] = useState(todayDate);
    4446    const [selectedTime, setSelectedTime] = useState('');
    45     const [formatedDateTime, setFormatedDateTime] = useState('')
    4647    const [numPeople, setNumPeople] = useState(2);
    4748    const [searchValue, setSearchValue] = useState('');
    4849    const [timeSlots, setTimeSlots] = useState([]);
    49 
    5050    let [filteredRestaurants, setFilteredRestaurants] = useState([]);
     51
    5152    const cuisineTypes = useContext(CuisineContext);
    5253    const [showCuisineSearch, setShowCuisineSearch] = useState(true);
     54
     55    const [formatedDateTime, setFormatedDateTime] = useState('')
    5356
    5457    useEffect(() => {
     
    165168    };
    166169
     170    const handleTimeSlotClick = (table, timeSlot, restaurant) => {
     171        const tableNumber = table.id;
     172        const formattedTimeSlot = timeSlot;
     173        const restaurantId = restaurant.restaurantId;
     174
     175        const encodedTableNumber = encodeURI(tableNumber);
     176        const encodedTimeSlot = encodeURIComponent(formattedTimeSlot);
     177        const encodedRestaurantId = encodeURIComponent(restaurantId);
     178
     179        navigate(`/reservationConfirmation/${encodedTableNumber}/${encodedTimeSlot}/${encodedRestaurantId}`);
     180    }
     181
    167182    const renderTimeSlots = (tablesList, restaurant) => {
    168183        const [year, month, day] = date.split("-");
     
    179194        return tablesList.flatMap(table => {
    180195            // Render capacity header when encountering a new capacity
    181             if (!renderedTimeSlots[table.capacity]) {
     196            if (!renderedTimeSlots[table.capacity] && numPeople <= table.capacity) {
    182197                renderedTimeSlots[table.capacity] = 0;
    183198                return (
     
    185200                        <h3>Table for: {table.capacity}</h3>
    186201                        {table.timeSlots.map((timeSlot, index) => {
    187                             const timeSlotTime = new Date(timeSlot).getTime();
     202                            let timeSlotTime = new Date(timeSlot).getTime();
     203
    188204                            const tableCapacity = table.capacity;
    189205                            // Check if the time slot is after the current time, numPeople is less than or equal to tableCapacity, and limit to 5 slots
    190                             if (timeSlotTime > timestamp && numPeople <= tableCapacity && renderedTimeSlots[tableCapacity] < 5) {
     206                            if (timeSlotTime >= timestamp && numPeople <= tableCapacity && renderedTimeSlots[tableCapacity] < 5) {
    191207                                renderedTimeSlots[tableCapacity]++;
    192208                                const timeSlotDateTime = new Date(timeSlot);
     
    259275                </div>
    260276
    261                 <div>
     277                <div className="border-0">
    262278                    {filteredRestaurants.map((restaurant) => (
    263279                        <div key={restaurant.id} className="card mb-3">
  • my-react-app/src/components/ReservationConfirmation.js

    r9293100 re35d0e9  
    114114                                <button type="submit" className="btn btn-primary">Submit</button>
    115115                            </div>
    116                             <div className="col-md-6">
    117                                 <a href="/restaurants" className="btn btn-primary">Back to Home</a>
     116                            <div className="card-footer">
     117                                <a href="/restaurants" className="btn btn-primary">Back to Restaurants</a>
     118                            </div>
     119                            <div className="card-footer">
     120                                <a href="/" className="btn btn-primary">Back to Home</a>
    118121                            </div>
    119122                        </form>
  • src/main/java/com/example/rezevirajmasa/demo/service/RestaurantService.java

    r9293100 re35d0e9  
    1616    Restaurant updateRestaurant(Long restaurantId, String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, BigDecimal rating, List<Long> tablesList);
    1717    Restaurant deleteRestaurant(Long restaurantId);
    18 
    1918    Restaurant findById(Long restaurantId);
    2019    List<Restaurant> listRestaurantBy(String search);
Note: See TracChangeset for help on using the changeset viewer.