-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
146 lines (141 loc) · 6.14 KB
/
index.html
File metadata and controls
146 lines (141 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="./assets/imgs/cart.svg">
<link rel="stylesheet" href="./assets/css/styles.css" />
<script src="https://unpkg.com/vue@2.7.8/dist/vue.js"></script>
<script src="./scripts/main.js" type="module"></script>
<title>After School Online Lessons Booking System</title>
</head>
<body>
<div id="app">
<!-- Loading Before Lessons are done fetching -->
<div id="loading" v-if="!fetchedLessons.length && !apiError">
<div id="wrapper">
<div id="mouse"></div>
<div class="loader">
</div>
<div class="loading-bar">
<div class="progress-bar"></div>
</div>
<div class="status">
<div class="state"></div>
<div class="percentage"></div>
</div>
</div>
</div>
<div class="container">
<header>
<div class="flex">
<h1 v-text="webappName"></h1>
<!-- Toggle Cart (Show Cart of hide it's view) -->
<input class="search" type="search" placeholder="Search for Lessons to book" v-model="searchQuery"
v-if="!showCart" />
</div>
<div class="header__buttons">
<!-- Cart button -->
<div class="header__buttons--cart">
<button @click="toggleShowCart" :disabled="totalItemsInTheCart === 0">
<img src="./assets/imgs/cart.svg" alt="Cart Icon">
{{ `${ totalItemsInTheCart > 1 ? totalItemsInTheCart + ' Items' :
totalItemsInTheCart + ' Item'} in cart` }}
</button>
<button @click="resetCart" :disabled="totalItemsInTheCart === 0">
<img src="./assets/imgs/trash.svg" alt="Trash Icon">
Reset Cart
</button>
</div>
<!-- Sorting buttons [subject - location - price - spaces] -->
<div class="header__buttons--sorting" v-if="!showCart">
<button @click="sortBySubject">Sort by Subject</button>
<button @click="sortByLocation">Sort by Location</button>
<button @click="sortByPrice">Sort by Price</button>
<button @click="sortBySpaces">Sort by Spaces</button>
</div>
</div>
<button class="backBtn" @click="toggleShowCart" v-if="showCart">⇦ Back to Lessons</button>
</header>
<main>
<!-- Chechout view -->
<div v-if="showCart" class="cart-container">
<h2>Shopping Cart</h2>
<div v-if="totalItemsInTheCart > 0">
<ul class="cart-added-items">
<li v-for="(item, index) in cart" :key="item._id + '-' + index">
<img :src="`${ELASTIC_BEANSTALK_API_URL}/images/` + item.image" :alt="item.subject" width="50"
height="50" />
<p>
[ {{ item.bookedClasses }} classes booked ] - {{ item.subject }}
<span>- Total Price: <strong>£{{ Math.round(item.totalPrice) }}</strong> </span>
</p>
</span>
<button @click="removeFromCart(item)">Remove</button>
</li>
</ul>
<p>Your total price for all classes booked = £{{ Math.round(totalCartPrice) }}</p>
<form name="checkout">
<div class="input-group">
<label for="#name">Please Enter Your Name</label>
<input type="text" id="name" :disabled="cart.length === 0" v-model="checkoutForm.name" />
</div>
<div class="input-group">
<label for="#phone">Please Enter Your Phone Number</label>
<input type="number" id="phone" :disabled="cart.length === 0" v-model="checkoutForm.phone" />
</div>
</form>
<button @click="checkout" :disabled="cart.length === 0 || !isInputValid">
Checkout
</button>
</div>
<p class="errorMsg" v-else>
Your Cart is empty, click <u>Back to Lessons</u> button to view the lessons
</p>
</div>
<div class="main bd-grid grid-wrapper" v-else>
<!-- Show Error when lessons not found! -->
<p class="errorMsg" v-if="apiError">{{ apiError }}</p>
<!-- Lessons view -->
<article class="lesson card" v-for="lesson in filteredLessons" :key="lesson._id" v-if="fetchedLessons.length">
<div class="card__img">
<img :src="`${ELASTIC_BEANSTALK_API_URL}/images/` + lesson.image" :alt="lesson.subject" width="150"
height="150">
<small>{{ lesson.subject }}</small>
</div>
<div class="card__name">
<small>{{ lesson.subject }}</small>
<span class="card__info--location">Location: {{ lesson.location }}</span>
</div>
<div class="card__info">
<div>
<small class="card__info--spaces">
{{
lesson.spaces === 0 ? 'Fully Booked'
: lesson.spaces === 1 ? '1 Last Seat'
: `Spaces: ${lesson.spaces}`
}}
</small>
<span class="card__info--location">Location: {{ lesson.location }}</span>
</div>
<div>
<span class="card__info--price">£{{ lesson.price }}</span>
</div>
<button class="card__icon" @click="addToCart(lesson)" :title="'Add ' + lesson.subject + ' to the Cart'"
:disabled="lesson.spaces === 0">
<img src="./assets/imgs/cart.svg" alt="Cart Icon" :title="'Add ' + lesson.subject + ' to the Cart'">
</button>
</div>
</article>
<!-- Search for lessons NOT found! -->
<div class="errorMsg" v-if="fetchedLessons.length && fetchedLessons.length === 0">
<p>Sorry, the lessons you are looking for cannot be found.</p>
<p>Please try a different search or reset your filters.</p>
</div>
</div>
</main>
</div>
</div>
</body>
</html>