lokeshloki143 commited on
Commit
e89d19d
·
verified ·
1 Parent(s): aa19fd3

Update templates/customer_details.html

Browse files
Files changed (1) hide show
  1. templates/customer_details.html +252 -247
templates/customer_details.html CHANGED
@@ -1,261 +1,266 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>User Profile</title>
7
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
- <style>
9
- body {
10
- background-color: #FDF4E3;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
-
13
- .back-to-menu {
14
- display: block;
15
- margin: 30px auto 10px auto;
16
- padding: 10px 20px;
17
- background-color: #ff5722;
18
- color: #ffffff;
19
- border: none;
20
- border-radius: 25px;
21
- font-size: 1rem;
22
- font-weight: bold;
23
- text-align: center;
24
- text-decoration: none;
25
- width: 100%;
26
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
27
- transition: background-color 0.3s ease;
28
- }
29
-
30
- .back-to-menu:hover {
31
- background-color: #e64a19;
32
- text-decoration: none;
33
- }
34
-
35
- .editable {
36
- background-color: #f0f8ff; /* Light blue when edited */
37
- }
38
-
39
- .input-group {
40
- position: relative;
41
- }
42
-
43
- .btn-change {
44
- position: absolute;
45
- right: 10px;
46
- top: 50%;
47
- transform: translateY(-50%);
48
- background-color: #ffffff;
49
- color: #0FAA39;
50
- border: none;
51
- border-radius: 5px;
52
- padding: 5px 10px;
53
- cursor: pointer;
54
- font-size: 0.9rem;
55
- }
56
-
57
- .btn-change:hover {
58
- background-color: #ffffff;
59
- color: #0FAA39;
60
- }
61
-
62
- .copy-btn {
63
- position: absolute;
64
- right: 10px;
65
- top: 50%;
66
- transform: translateY(-50%);
67
- background: none;
68
- border: none;
69
- color: #007bff;
70
- font-size: 1.2rem;
71
- cursor: pointer;
72
- }
73
-
74
- .update-btn {
75
- background-color: #0FAA39;
76
- color: white;
77
- border: none;
78
- border-radius: 5px;
79
- padding: 10px 20px;
80
- font-size: 1rem;
81
- cursor: pointer;
82
- width: 20%;
83
- font-weight: bold; /* Making the button text bold */
84
- }
85
-
86
- .update-btn:hover {
87
- background-color: #0f8e29;
88
- }
89
-
90
- .edit-btn {
91
- background-color: #0FAA39;
92
- color: white;
93
- border: none;
94
- border-radius: 5px;
95
- padding: 10px 20px;
96
- font-size: 1rem;
97
- cursor: pointer;
98
- width: 20%;
99
- font-weight: bold; /* Making the button text bold */
100
- }
101
-
102
- .edit-btn:hover {
103
- background-color: #0f8e29;
104
- }
105
-
106
-
107
-
108
- /* Button container adjustments */
109
- .button-container {
110
- display: flex;
111
- justify-content: space-between;
112
- gap: 10px; /* Add space between buttons */
113
- }
114
-
115
-
116
-
117
-
118
-
119
- /* Flexbox for equally spaced buttons */
120
- .button-container {
121
- display: flex;
122
- justify-content: space-between;
123
- margin-top: 20px;
124
- }
125
-
126
- /* Ensure both buttons have equal height and width */
127
- .edit-btn, .update-btn {
128
- flex: 1;
129
- margin: 0 5px;
130
- padding: 10px 20px;
131
- font-size: 1rem;
132
- cursor: pointer;
133
- border-radius: 5px;
134
- height: 50px; /* Equal height for both buttons */
135
- }
136
-
137
- /* Change text color inside input fields to gray */
138
- input[type="text"], input[type="email"], input[type="number"], .form-control {
139
- color: #808080; /* Change text color to gray */
140
- }
141
-
142
- /* Change color for the headings like Name, Email, Phone, Referral Code, Reward Points */
143
- .form-label {
144
- color: #1C1C1C; /* Change heading text color */
145
- }
146
-
147
- h1 {
148
- color: #1C1C1C; /* Change User Profile heading color */
149
- font-size: 24px; /* Change font size of 'User Profile' */
150
- }
151
- </style>
152
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
153
- <script>
154
- function enableEditField(fieldId) {
155
- var field = document.getElementById(fieldId);
156
- field.removeAttribute("readonly");
157
- field.classList.add("editable");
158
- field.focus();
159
- }
160
-
161
- function updateProfile(event) {
162
- event.preventDefault();
163
- var formData = $('#profileForm').serialize();
164
-
165
- $.ajax({
166
- type: "POST",
167
- url: "/user/update_profile",
168
- data: formData,
169
- success: function(response) {
170
- if (response.status === "success") {
171
- alert(response.message);
172
- location.reload();
173
- } else {
174
- alert(response.message);
175
- }
176
- },
177
- error: function() {
178
- alert("An error occurred while updating the profile.");
179
- }
180
- });
181
- }
182
-
183
- function editProfileFields() {
184
- document.getElementById('customerName').removeAttribute('readonly');
185
- document.getElementById('email').removeAttribute('readonly');
186
- document.getElementById('phone').removeAttribute('readonly');
187
- document.getElementById('customerName').classList.add('editable');
188
- document.getElementById('email').classList.add('editable');
189
- document.getElementById('phone').classList.add('editable');
190
- }
191
-
192
- function copyReferralCode() {
193
- var referralCode = document.getElementById('referralCode');
194
- referralCode.select();
195
- document.execCommand('copy');
196
- alert('Referral Code Copied!');
197
- }
198
- </script>
199
  </head>
200
- <body>
201
- <div class="container mt-4">
202
- <h1>User Profile</h1>
203
 
204
- {% with messages = get_flashed_messages(with_categories=true) %}
205
- {% if messages %}
206
- <div class="alert alert-{{ messages[0][0] }}">
207
- {{ messages[0][1] }}
208
- </div>
209
- {% endif %}
210
- {% endwith %}
211
-
212
- <div class="card">
213
- <div class="card-body">
214
- <form id="profileForm" method="POST" onsubmit="updateProfile(event)">
215
- <div class="mb-3">
216
- <label for="customerName" class="form-label"><strong>Name:</strong></label>
217
- <div class="input-group">
218
- <input type="text" id="customerName" name="customerName" class="form-control" value="{{ customer['name'] }}" readonly>
219
- </div>
220
- </div>
221
 
222
- <div class="mb-3">
223
- <label for="email" class="form-label"><strong>Email:</strong></label>
224
- <div class="input-group">
225
- <input type="email" id="email" name="email" class="form-control" value="{{ customer['email'] }}" readonly>
226
- </div>
227
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
- <div class="mb-3">
230
- <label for="phone" class="form-label"><strong>Phone:</strong></label>
231
- <div class="input-group">
232
- <input type="text" id="phone" name="phone" class="form-control" value="{{ customer['phone'] }}" readonly>
233
- </div>
234
- </div>
235
 
236
- <div class="mb-3">
237
- <label for="referralCode" class="form-label"><strong>Referral Code:</strong></label>
238
- <div class="input-group">
239
- <input type="text" id="referralCode" name="referralCode" class="form-control" value="{{ customer['referral_code'] }}" readonly>
240
- <button type="button" class="copy-btn" onclick="copyReferralCode()">📋</button>
241
- </div>
242
- </div>
243
 
244
- <div class="mb-3">
245
- <label for="rewardPoints" class="form-label"><strong>Reward Points:</strong></label>
246
- <input type="text" id="rewardPoints" name="rewardPoints" class="form-control" value="{{ customer['reward_points'] }}" readonly>
247
- </div>
248
 
249
- <!-- Flex container for Edit and Update buttons -->
250
- <div class="button-container">
251
- <button type="button" class="edit-btn" onclick="editProfileFields()">Edit Profile</button>
252
- <button type="submit" class="update-btn">Update Profile</button>
253
- </div>
254
- </form>
255
- </div>
256
- </div>
257
 
258
- <a href="/menu" class="back-to-menu">Back to Menu</a>
259
- </div>
260
  </body>
261
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6
+ <title>User Profile</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
8
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet"/>
9
+ <style>
10
+ body {
11
+ background-color: #FDF4E3;
12
+ margin: 0;
13
+ padding: 0;
14
+ position: relative;
15
+ min-height: 100vh;
16
+ }
17
+ /* Top orange bar */
18
+ .top-bar {
19
+ background-color: #FF6F3C;
20
+ width: 100%;
21
+ padding: 10px 15px;
22
+ display: flex;
23
+ align-items: center;
24
+ box-sizing: border-box;
25
+ }
26
+ .back-link {
27
+ display: flex;
28
+ align-items: center;
29
+ text-decoration: none;
30
+ }
31
+ .back-arrow {
32
+ font-size: 1.8rem;
33
+ color: #000; /* Dark black */
34
+ font-weight: bold;
35
+ }
36
+ .back-label {
37
+ margin-left: 10px;
38
+ color: white;
39
+ font-weight: bold;
40
+ font-size: 1rem;
41
+ }
42
+ h1 {
43
+ color: #1C1C1C;
44
+ font-size: 1.2rem;
45
+ margin: 30px 0 15px; /* Default margin for larger screens */
46
+ text-align: center;
47
+ }
48
+ /* For mobile view */
49
+ @media (max-width: 576px) {
50
+ h1 {
51
+ margin-top: 2px; /* Reduced top margin for mobile */
52
+ }
53
+ }
54
+ .form-control {
55
+ border: 1px solid #333;
56
+ color: #808080;
57
+ background-color: #F9F9F9;
58
+ }
59
+ #referralCode, #rewardPoints {
60
+ color: #000 !important;
61
+ }
62
+ .form-label {
63
+ color: #000 !important;
64
+ font-size: 0.8rem;
65
+ }
66
+ input.form-control[readonly], textarea.form-control[readonly] {
67
+ color: #808080;
68
+ background-color: #F9F9F9 !important;
69
+ }
70
+ input.form-control.editable, textarea.form-control.editable {
71
+ background-color: #FFF8E1 !important;
72
+ color: #000 !important;
73
+ }
74
+ .input-group {
75
+ position: relative;
76
+ }
77
+ .pen-icon {
78
+ position: absolute;
79
+ right: 5px;
80
+ top: 50%;
81
+ transform: translateY(-50%);
82
+ cursor: pointer;
83
+ font-size: 1.2rem;
84
+ color: black;
85
+ }
86
+ .pen-icon.editing {
87
+ color: #333;
88
+ }
89
+ .button-container {
90
+ display: flex;
91
+ flex-direction: column;
92
+ margin-top: 10px;
93
+ }
94
+ /* Updated label button style */
95
+ .orange-label {
96
+ background-color: #ffffff;
97
+ color: white;
98
+ padding: 8px 16px;
99
+ border-radius: 5px;
100
+ font-weight: bold;
101
+ text-align: center;
102
+ margin-top: 20px;
103
+ width: 100%; /* Ensure the label is full width */
104
+ position: absolute;
105
+ bottom: 0;
106
+ }
107
+ .update-btn {
108
+ background-color: #0FAA39; /* Green button */
109
+ color: white;
110
+ border: none;
111
+ border-radius: 5px;
112
+ padding: 5px 12px;
113
+ font-size: 0.8rem;
114
+ font-weight: bold;
115
+ width: 60%; /* Full width inside orange label */
116
+ }
117
+ .update-btn:hover {
118
+ background-color: #0f8e29;
119
+ }
120
+ @media (max-width: 576px) {
121
+ .container {
122
+ padding: 10px;
123
+ }
124
+ .update-btn {
125
+ width: 100%;
126
+ }
127
+ .form-label {
128
+ font-size: 0.75rem;
129
+ }
130
+ .form-control {
131
+ font-size: 0.8rem;
132
+ }
133
+ }
134
+ </style>
135
+
136
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
137
+ <script>
138
+ function toggleEditableField(fieldId, penIcon) {
139
+ var input = document.getElementById(fieldId);
140
+ var icon = document.getElementById(penIcon);
141
+ if (input.hasAttribute('readonly')) {
142
+ input.removeAttribute('readonly');
143
+ input.classList.add('editable');
144
+ icon.classList.add('editing');
145
+ } else {
146
+ input.setAttribute('readonly', true);
147
+ input.classList.remove('editable');
148
+ icon.classList.remove('editing');
149
+ }
150
+ }
151
+ function updateProfile(event) {
152
+ event.preventDefault();
153
+ var formData = $('#profileForm').serialize();
154
+ $.ajax({
155
+ type: "POST",
156
+ url: "/update_profile", // Update this URL with your back-end processing URL
157
+ data: formData,
158
+ success: function(response) {
159
+ if (response.status === "success") {
160
+ alert(response.message);
161
+ location.reload();
162
+ } else {
163
+ alert(response.message);
164
+ }
165
+ },
166
+ error: function() {
167
+ alert("An error occurred while updating the profile.");
168
  }
169
+ });
170
+ }
171
+ function copyReferralCode() {
172
+ var referralInput = document.getElementById("referralCode");
173
+ referralInput.select();
174
+ referralInput.setSelectionRange(0, 99999);
175
+ document.execCommand("copy");
176
+ alert("Referral code copied: " + referralInput.value);
177
+ }
178
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  </head>
 
 
 
180
 
181
+ <body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
+ <!-- Top Orange Label Bar -->
184
+ <div class="top-bar">
185
+ <a href="/menu" class="back-link">
186
+ <span class="back-arrow">&#10216;</span>
187
+ <span class="back-label">Back to Menu</span>
188
+ </a>
189
+ </div>
190
+
191
+ <!-- Main Container -->
192
+ <div class="container mt-4">
193
+ <h1>User Profile</h1>
194
+
195
+ {% with messages = get_flashed_messages(with_categories=true) %}
196
+ {% if messages %}
197
+ <div class="alert alert-{{ messages[0][0] }}">
198
+ {{ messages[0][1] }}
199
+ </div>
200
+ {% endif %}
201
+ {% endwith %}
202
+
203
+ <div class="card">
204
+ <div class="card-body">
205
+ <form id="profileForm" method="POST" onsubmit="updateProfile(event)">
206
+ <!-- Name -->
207
+ <div class="mb-3">
208
+ <label for="customerName" class="form-label"><strong>Name:</strong></label>
209
+ <div class="input-group">
210
+ <input type="text" id="customerName" name="customerName" class="form-control" value="{{ customer['name'] }}" readonly>
211
+ <span id="pen-icon-customerName" class="pen-icon" onclick="toggleEditableField('customerName', 'pen-icon-customerName')">
212
+ <i class="fas fa-pen"></i>
213
+ </span>
214
+ </div>
215
+ </div>
216
+
217
+ <!-- Email -->
218
+ <div class="mb-3">
219
+ <label for="email" class="form-label"><strong>Email:</strong></label>
220
+ <div class="input-group">
221
+ <input type="email" id="email" name="email" class="form-control" value="{{ customer['email'] }}" readonly>
222
+ <span id="pen-icon-email" class="pen-icon" onclick="toggleEditableField('email', 'pen-icon-email')">
223
+ <i class="fas fa-pen"></i>
224
+ </span>
225
+ </div>
226
+ </div>
227
+
228
+ <!-- Phone -->
229
+ <div class="mb-3">
230
+ <label for="phone" class="form-label"><strong>Phone:</strong></label>
231
+ <div class="input-group">
232
+ <input type="text" id="phone" name="phone" class="form-control" value="{{ customer['phone'] }}" readonly>
233
+ <span id="pen-icon-phone" class="pen-icon" onclick="toggleEditableField('phone', 'pen-icon-phone')">
234
+ <i class="fas fa-pen"></i>
235
+ </span>
236
+ </div>
237
+ </div>
238
+
239
+ <!-- Referral Code -->
240
+ <div class="mb-3">
241
+ <label for="referralCode" class="form-label"><strong>Referral Code:</strong></label>
242
+ <div class="input-group">
243
+ <input type="text" id="referralCode" name="referralCode" class="form-control" value="{{ customer['referral_code'] }}" readonly>
244
+ <button type="button" class="copy-btn" onclick="copyReferralCode()">📋</button>
245
+ </div>
246
+ </div>
247
 
248
+ <!-- Reward Points -->
249
+ <div class="mb-3">
250
+ <label for="rewardPoints" class="form-label"><strong>Reward Points:</strong></label>
251
+ <input type="text" id="rewardPoints" name="rewardPoints" class="form-control" value="{{ customer['reward_points'] }}" readonly>
252
+ </div>
 
253
 
254
+ </form>
255
+ </div>
256
+ </div>
 
 
 
 
257
 
258
+ </div>
 
 
 
259
 
260
+ <!-- Orange Label with Update Profile Button at the Bottom -->
261
+ <div class="orange-label">
262
+ <button type="submit" class="update-btn" form="profileForm">Update Profile</button>
263
+ </div>
 
 
 
 
264
 
 
 
265
  </body>
266
  </html>