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

Update templates/customer_details.html

Browse files
Files changed (1) hide show
  1. templates/customer_details.html +105 -85
templates/customer_details.html CHANGED
@@ -2,19 +2,19 @@
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%;
@@ -30,27 +30,21 @@
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;
@@ -60,7 +54,7 @@
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] {
@@ -76,53 +70,63 @@
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;
@@ -130,14 +134,22 @@
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');
@@ -148,61 +160,70 @@
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>
@@ -251,16 +272,15 @@
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>
 
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
  min-height: 100vh;
15
+ display: flex;
16
+ flex-direction: column;
17
  }
 
18
  .top-bar {
19
  background-color: #FF6F3C;
20
  width: 100%;
 
30
  }
31
  .back-arrow {
32
  font-size: 1.8rem;
33
+ color: #000;
34
  font-weight: bold;
35
  }
36
  .back-label {
37
  margin-left: 10px;
38
  color: white;
39
  font-weight: bold;
40
+ ruminant-size: 1rem;
41
  }
42
  h1 {
43
  color: #1C1C1C;
44
  font-size: 1.2rem;
45
+ margin: 15px 0;
46
  text-align: center;
47
  }
 
 
 
 
 
 
48
  .form-control {
49
  border: 1px solid #333;
50
  color: #808080;
 
54
  color: #000 !important;
55
  }
56
  .form-label {
57
+ color: #000;
58
  font-size: 0.8rem;
59
  }
60
  input.form-control[readonly], textarea.form-control[readonly] {
 
70
  }
71
  .pen-icon {
72
  position: absolute;
73
+ right: 10px;
74
  top: 50%;
75
  transform: translateY(-50%);
76
  cursor: pointer;
77
+ font-size: 1rem;
78
  color: black;
79
  }
80
  .pen-icon.editing {
81
  color: #333;
82
  }
83
+ .update-btn {
84
+ background-color: #0FAA39;
 
 
 
 
 
 
85
  color: white;
86
+ border: none;
87
  border-radius: 5px;
88
+ padding: 10px;
89
+ font-size: 0.9rem;
90
  font-weight: bold;
91
+ width: 100%;
92
  margin-top: 20px;
 
 
 
93
  }
94
+ .update-btn:hover {
95
+ background-color: #0f8e29;
96
+ }
97
+ .copy-btn {
98
+ background-color: #FF6F3C;
99
  color: white;
100
  border: none;
101
+ padding: 5px 10px;
102
+ cursor: pointer;
103
+ }
104
+ .copy-btn:hover {
105
+ background-color: #e65b2e;
106
+ }
107
+ .error-message {
108
+ color: red;
109
  font-size: 0.8rem;
110
+ margin-top: 10px;
111
+ display: none;
112
  }
113
+ .success-message {
114
+ color: green;
115
+ font-size: 0.8rem;
116
+ margin-top: 10px;
117
+ display: none;
118
  }
119
  @media (max-width: 576px) {
120
+ body {
121
+ padding-top: 0;
122
+ }
123
  .container {
124
  padding: 10px;
125
+ margin-top: 0;
126
  }
127
+ h1 {
128
+ margin: 10px 0;
129
+ font-size: 1.1rem;
130
  }
131
  .form-label {
132
  font-size: 0.75rem;
 
134
  .form-control {
135
  font-size: 0.8rem;
136
  }
137
+ .top-bar {
138
+ padding: 8px 10px;
139
+ }
140
+ .back-arrow {
141
+ font-size: 1.5rem;
142
+ }
143
+ .back-label {
144
+ font-size: 0.9rem;
145
+ }
146
  }
147
  </style>
 
148
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
149
  <script>
150
  function toggleEditableField(fieldId, penIcon) {
151
+ const input = document.getElementById(fieldId);
152
+ const icon = document.getElementById(penIcon);
153
  if (input.hasAttribute('readonly')) {
154
  input.removeAttribute('readonly');
155
  input.classList.add('editable');
 
160
  icon.classList.remove('editing');
161
  }
162
  }
163
+
164
+ function copyReferralCode() {
165
+ const referralInput = document.getElementById('referralCode');
166
+ referralInput.select();
167
+ document.execCommand('copy');
168
+ showMessage('success', 'Referral code copied!');
169
+ }
170
+
171
+ function showMessage(type, message) {
172
+ const msgElement = document.getElementById(`${type}-message`);
173
+ msgElement.textContent = message;
174
+ msgElement.style.display = 'block';
175
+ setTimeout(() => {
176
+ msgElement.style.display = 'none';
177
+ }, 3000);
178
+ }
179
+
180
  function updateProfile(event) {
181
  event.preventDefault();
182
+ const formData = {
183
+ Id: '{{ customer["salesforce_id"] }}', // Salesforce record ID
184
+ Name: document.getElementById('customerName').value,
185
+ Email: document.getElementById('email').value,
186
+ Phone: document.getElementById('phone').value
187
+ };
188
+
189
+ // Salesforce REST API call
190
  $.ajax({
191
+ type: 'PATCH',
192
+ url: 'https://your-instance.salesforce.com/services/data/v52.0/sobjects/Contact/{{ customer["salesforce_id"] }}',
193
+ headers: {
194
+ 'Authorization': 'Bearer YOUR_ACCESS_TOKEN', // Replace with your access token
195
+ 'Content-Type': 'application/json'
196
+ },
197
+ data: JSON.stringify(formData),
198
  success: function(response) {
199
+ showMessage('success', 'Profile updated successfully!');
200
+ setTimeout(() => location.reload(), 1000);
 
 
 
 
201
  },
202
+ error: function(xhr) {
203
+ const errorMsg = xhr.responseJSON && xhr.responseJSON[0] && xhr.responseJSON[0].message
204
+ ? xhr.responseJSON[0].message
205
+ : 'Failed to update profile.';
206
+ showMessage('error', errorMsg);
207
  }
208
  });
209
  }
 
 
 
 
 
 
 
210
  </script>
211
  </head>
 
212
  <body>
213
+ <!-- Top Orange Bar -->
 
214
  <div class="top-bar">
215
  <a href="/menu" class="back-link">
216
+ <span class="back-arrow">⟨</span>
217
  <span class="back-label">Back to Menu</span>
218
  </a>
219
  </div>
220
 
221
  <!-- Main Container -->
222
+ <div class="container mt-2">
223
  <h1>User Profile</h1>
 
 
 
 
 
 
 
 
 
224
  <div class="card">
225
  <div class="card-body">
226
+ <form id="profileForm" onsubmit="updateProfile(event)">
227
  <!-- Name -->
228
  <div class="mb-3">
229
  <label for="customerName" class="form-label"><strong>Name:</strong></label>
 
272
  <input type="text" id="rewardPoints" name="rewardPoints" class="form-control" value="{{ customer['reward_points'] }}" readonly>
273
  </div>
274
 
275
+ <!-- Messages -->
276
+ <div id="success-message" class="success-message"></div>
277
+ <div id="error-message" class="error-message"></div>
278
+
279
+ <!-- Update Button -->
280
+ <button type="submit" class="update-btn">Update Profile</button>
281
  </form>
282
  </div>
283
  </div>
 
284
  </div>
 
 
 
 
 
 
285
  </body>
286
+ </html>