Update templates/customer_details.html
#6
by
geethareddy
- opened
- templates/customer_details.html +152 -22
templates/customer_details.html
CHANGED
@@ -3,14 +3,17 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
|
8 |
<style>
|
|
|
|
|
|
|
9 |
.back-to-menu {
|
10 |
display: block;
|
11 |
margin: 30px auto 10px auto;
|
12 |
padding: 10px 20px;
|
13 |
-
background-color: #ff5722;
|
14 |
color: #ffffff;
|
15 |
border: none;
|
16 |
border-radius: 25px;
|
@@ -26,47 +29,174 @@
|
|
26 |
background-color: #e64a19;
|
27 |
text-decoration: none;
|
28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
.copy-btn {
|
|
|
|
|
|
|
|
|
30 |
background: none;
|
31 |
border: none;
|
32 |
-
cursor: pointer;
|
33 |
color: #007bff;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
font-size: 1rem;
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
</style>
|
|
|
38 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
function copyReferralCode() {
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
}
|
45 |
</script>
|
46 |
</head>
|
47 |
<body>
|
48 |
<div class="container mt-4">
|
49 |
-
<h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
<div class="card">
|
52 |
<div class="card-body">
|
53 |
-
<
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
</div>
|
64 |
</div>
|
65 |
-
|
66 |
-
<!-- Back to Menu Button -->
|
67 |
<a href="/menu" class="back-to-menu">Back to Menu</a>
|
68 |
</div>
|
69 |
-
|
70 |
-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
|
71 |
</body>
|
72 |
</html>
|
|
|
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/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
|
8 |
<style>
|
9 |
+
body {
|
10 |
+
background-color: #FDF4E3;
|
11 |
+
}
|
12 |
.back-to-menu {
|
13 |
display: block;
|
14 |
margin: 30px auto 10px auto;
|
15 |
padding: 10px 20px;
|
16 |
+
background-color: #ff5722;
|
17 |
color: #ffffff;
|
18 |
border: none;
|
19 |
border-radius: 25px;
|
|
|
29 |
background-color: #e64a19;
|
30 |
text-decoration: none;
|
31 |
}
|
32 |
+
.editable {
|
33 |
+
background-color: #f0f8ff; /* Light blue when edited */
|
34 |
+
}
|
35 |
+
.input-group {
|
36 |
+
position: relative;
|
37 |
+
}
|
38 |
+
.btn-change {
|
39 |
+
position: absolute;
|
40 |
+
right: 10px;
|
41 |
+
top: 50%;
|
42 |
+
transform: translateY(-50%);
|
43 |
+
background-color: #ffffff;
|
44 |
+
color: #0FAA39; /* Green text color */
|
45 |
+
border: none; /* No border */
|
46 |
+
border-radius: 5px;
|
47 |
+
padding: 5px 10px;
|
48 |
+
cursor: pointer;
|
49 |
+
font-size: 0.9rem;
|
50 |
+
}
|
51 |
+
.btn-change:hover {
|
52 |
+
background-color: #ffffff;
|
53 |
+
color: #0FAA39;
|
54 |
+
}
|
55 |
.copy-btn {
|
56 |
+
position: absolute;
|
57 |
+
right: 10px;
|
58 |
+
top: 50%;
|
59 |
+
transform: translateY(-50%);
|
60 |
background: none;
|
61 |
border: none;
|
|
|
62 |
color: #007bff;
|
63 |
+
font-size: 1.2rem;
|
64 |
+
cursor: pointer;
|
65 |
+
}
|
66 |
+
.update-btn {
|
67 |
+
background-color: #0FAA39;
|
68 |
+
color: white;
|
69 |
+
border: none;
|
70 |
+
border-radius: 5px;
|
71 |
+
padding: 10px 20px;
|
72 |
+
font-size: 1rem;
|
73 |
+
cursor: pointer;
|
74 |
+
}
|
75 |
+
.update-btn:hover {
|
76 |
+
background-color: #0f8e29;
|
77 |
+
}
|
78 |
+
.edit-btn {
|
79 |
+
background-color: #0FAA39;
|
80 |
+
color: white;
|
81 |
+
border: none;
|
82 |
+
border-radius: 5px;
|
83 |
+
padding: 10px 20px;
|
84 |
font-size: 1rem;
|
85 |
+
cursor: pointer;
|
86 |
+
}
|
87 |
+
.edit-btn:hover {
|
88 |
+
background-color: #0f8e29;
|
89 |
+
}
|
90 |
+
/* Change text color to #ff5722 */
|
91 |
+
h1, .form-label {
|
92 |
+
color: #ff5722;
|
93 |
}
|
94 |
</style>
|
95 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
96 |
<script>
|
97 |
+
function enableEditField(fieldId) {
|
98 |
+
var field = document.getElementById(fieldId);
|
99 |
+
field.removeAttribute("readonly");
|
100 |
+
field.classList.add("editable");
|
101 |
+
field.focus();
|
102 |
+
}
|
103 |
+
|
104 |
+
function updateProfile(event) {
|
105 |
+
event.preventDefault();
|
106 |
+
var formData = $('#profileForm').serialize();
|
107 |
+
|
108 |
+
$.ajax({
|
109 |
+
type: "POST",
|
110 |
+
url: "/update_profile",
|
111 |
+
data: formData,
|
112 |
+
success: function(response) {
|
113 |
+
if (response.status === "success") {
|
114 |
+
alert(response.message);
|
115 |
+
location.reload();
|
116 |
+
} else {
|
117 |
+
alert(response.message);
|
118 |
+
}
|
119 |
+
},
|
120 |
+
error: function() {
|
121 |
+
alert("An error occurred while updating the profile.");
|
122 |
+
}
|
123 |
+
});
|
124 |
+
}
|
125 |
+
|
126 |
+
function editProfileFields() {
|
127 |
+
// Making only editable fields editable (Excluding referralCode and rewardPoints)
|
128 |
+
document.getElementById('customerName').removeAttribute('readonly');
|
129 |
+
document.getElementById('email').removeAttribute('readonly');
|
130 |
+
document.getElementById('phone').removeAttribute('readonly');
|
131 |
+
document.getElementById('customerName').classList.add('editable');
|
132 |
+
document.getElementById('email').classList.add('editable');
|
133 |
+
document.getElementById('phone').classList.add('editable');
|
134 |
+
}
|
135 |
+
|
136 |
function copyReferralCode() {
|
137 |
+
var referralCode = document.getElementById('referralCode');
|
138 |
+
referralCode.select();
|
139 |
+
document.execCommand('copy');
|
140 |
+
alert('Referral Code Copied!');
|
141 |
}
|
142 |
</script>
|
143 |
</head>
|
144 |
<body>
|
145 |
<div class="container mt-4">
|
146 |
+
<h1>User Profile</h1>
|
147 |
+
|
148 |
+
{% with messages = get_flashed_messages(with_categories=true) %}
|
149 |
+
{% if messages %}
|
150 |
+
<div class="alert alert-{{ messages[0][0] }}">
|
151 |
+
{{ messages[0][1] }}
|
152 |
+
</div>
|
153 |
+
{% endif %}
|
154 |
+
{% endwith %}
|
155 |
|
156 |
<div class="card">
|
157 |
<div class="card-body">
|
158 |
+
<form id="profileForm" method="POST" onsubmit="updateProfile(event)">
|
159 |
+
<div class="mb-3">
|
160 |
+
<label for="customerName" class="form-label"><strong>Name:</strong></label>
|
161 |
+
<div class="input-group">
|
162 |
+
<input type="text" id="customerName" name="customerName" class="form-control" value="{{ customer['name'] }}" readonly>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
|
166 |
+
<div class="mb-3">
|
167 |
+
<label for="email" class="form-label"><strong>Email:</strong></label>
|
168 |
+
<div class="input-group">
|
169 |
+
<input type="email" id="email" name="email" class="form-control" value="{{ customer['email'] }}" readonly>
|
170 |
+
</div>
|
171 |
+
</div>
|
172 |
+
|
173 |
+
<div class="mb-3">
|
174 |
+
<label for="phone" class="form-label"><strong>Phone:</strong></label>
|
175 |
+
<div class="input-group">
|
176 |
+
<input type="text" id="phone" name="phone" class="form-control" value="{{ customer['phone'] }}" readonly>
|
177 |
+
</div>
|
178 |
+
</div>
|
179 |
|
180 |
+
<div class="mb-3">
|
181 |
+
<label for="referralCode" class="form-label"><strong>Referral Code:</strong></label>
|
182 |
+
<div class="input-group">
|
183 |
+
<input type="text" id="referralCode" name="referralCode" class="form-control" value="{{ customer['referral_code'] }}" readonly>
|
184 |
+
<button type="button" class="copy-btn" onclick="copyReferralCode()">📋</button>
|
185 |
+
</div>
|
186 |
+
</div>
|
187 |
+
|
188 |
+
<div class="mb-3">
|
189 |
+
<label for="rewardPoints" class="form-label"><strong>Reward Points:</strong></label>
|
190 |
+
<input type="text" id="rewardPoints" name="rewardPoints" class="form-control" value="{{ customer['reward_points'] }}" readonly>
|
191 |
+
</div>
|
192 |
+
|
193 |
+
<button type="button" class="edit-btn" onclick="editProfileFields()">Edit Profile</button>
|
194 |
+
<button type="submit" class="update-btn">Update Profile</button>
|
195 |
+
</form>
|
196 |
</div>
|
197 |
</div>
|
198 |
+
|
|
|
199 |
<a href="/menu" class="back-to-menu">Back to Menu</a>
|
200 |
</div>
|
|
|
|
|
201 |
</body>
|
202 |
</html>
|