-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_profile.html
211 lines (189 loc) · 9.93 KB
/
edit_profile.html
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!doctype html>
<html lang="en">
<head>
<title>Mosya - Edit Profil</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="robots" content="noindex,nofollow" />
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="assets/css/bootstrap.css">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/home.css">
<link rel="stylesheet" href="assets/css/navigation.css">
<link rel="stylesheet" href="assets/css/typography.css">
<link rel='stylesheet' href='https://cdn-uicons.flaticon.com/uicons-regular-rounded/css/uicons-regular-rounded.css'>
<link rel='stylesheet' href='https://cdn-uicons.flaticon.com/uicons-solid-rounded/css/uicons-solid-rounded.css'>
<link rel='stylesheet' href='https://cdn-uicons.flaticon.com/uicons-bold-rounded/css/uicons-bold-rounded.css'>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body class="align-items-start pt-0 flex-column pb-0">
<!-- start navigation bar -->
<nav class="navbar fixed-top bg-white border-bottom shadow-sm px-0">
<div class="col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 m-auto d-flex justify-content-start align-items-center flex-row py-0 px-xl-3 px-lg-3 px-md-3 px-sm-3 px-3">
<a class="navbar-brand" title="back" onclick="history.back()">
<i class="fi fi-sr-angle-left color-black400 headline6"></i>
</a>
<p class="mb-0 bodytext1 semibold color-black500 px-2 py-2">Edit Profil</p>
</div>
</nav>
<!-- end navigation bar -->
<!-- start body content -->
<main role="main" class="container-fluid col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 pt-0 pl-0 pr-0 mt-5">
<!-- start content welcome user -->
<form enctype="multipart/form-data" class="container-user d-flex justify-content-center flex-column w-100 px-3 py-4 mb-4">
<label class="container-image-profile mx-auto" for="choose-image">
<img src="https://defuj.github.io/mosya.bootstrap/assets/images/user-default.png" alt="profile" class="image-profile" id="image-profile">
<input type="file" name="picture" id="choose-image" accept="image/png, image/gif, image/jpeg" hidden>
<i class="fi fi-rr-camera change-picture"></i>
</label>
<div class="input-group-custom bg-white mt-3">
<i class="fi fi-rr-user color-black400"></i>
<input type="text" name="name" id="dataName" class="form-input bodytext2" placeholder="Nama Lengkap" required>
</div>
<div class="input-group-custom bg-white mt-3">
<i class="fi fi-rr-hastag color-black400"></i>
<input type="number" name="phone" id="dataPhone" maxlength="15" class="form-input bodytext2" placeholder="Nomor Telpon" required>
</div>
<div class="input-group-custom bg-light mt-3">
<i class="fi fi-rr-at color-black300"></i>
<input type="email" name="email" id="dataEmail" class="form-input bodytext2 color-black300" placeholder="Alamat Email" disabled required>
</div>
<button type="button" id="buttonSave" class="button-action-save text-white background-green500 bodytext1 text-center mt-5">
Simpan Perubahan
</button>
</form>
<!-- end content welcome user -->
</main>
<!-- end body content -->
<!-- start content footer -->
<footer style="max-height: 280px !important;min-height: 280px !important;" class="container-footer w-100 bg-white p-3 flex-row justify-content-center col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 ml-auto mr-auto mb-0">
<p class="headline6 color-black700 semibold text-center">Download Aplikasi Mosya!</p>
<p class="bodytext1 color-black400 text-center">Lebih mudah mencari mobil impian kamu hanya tinggal scroll dak klik klik aja.</p>
<div class="container-footer-button d-flex justify-content-center">
<a class="button-footer px-2" href="#">
<img src="assets/images/btn-google-play.png" alt="">
</a>
<a class="button-footer px-2" href="#">
<img src="assets/images/btn-app-store.png" alt="">
</a>
</div>
<div class="container-footer-action d-flex justify-content-center flex-wrap mt-3">
<a class="action-footer px-1 color-black300 bodytext2" href="#">
Tentang Mosya |
</a>
<a class="action-footer px-1 color-black300 bodytext2" href="#">
Syarat dan Ketentuan |
</a>
<a class="action-footer px-1 color-black300 bodytext2" href="#">
Pusat Bantuan
</a>
</div>
<div class="container-line background-black100 w-100 my-3" style="height: 1px;"></div>
<div class="container-footer-copyright d-flex justify-content-center flex-wrap">
<p class="copyright color-black300 bodytext2">Copyright © 2022 Mosya. All rights reserved.</p>
</div>
</footer>
<!-- end content footer -->
<!-- start navigation bottom -->
<nav class="d-none navbar bottom-nav-buy fixed-bottom navbar-expand bg-white px-3 py-3 shadow-sm col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 text-center m-auto">
<!-- <p class="mb-0 color-black500 semibold headline6 semibold color-black500 flex-fill text-left" id="data-price">Rp 0,0</p> -->
<button class="button-message flex-fill bodytext2 semibold text-white d-flex flex-row justify-content-center align-items-center background-green500" type="button">
<p class="mb-0 py-1">Cari Mobil</p>
<!-- <i class="fi fi-rr-comment bodytext1 ml-2"></i> -->
</button>
</nav>
<!-- end navigation bottom -->
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js"></script>
<script src="assets/js/session.js"></script>
<script src="assets/js/navigation.js"></script>
<script>
if(checkAccount()){
const user = getAccount();
$('#dataName').val(safeString(user.name));
$('#dataPhone').val(safeString(user.phone.replace('+', '')));
$('#dataEmail').val(safeString(user.email));
user.image != null && user.image != '' ? $('#image-profile').attr('src', user.image) : '';
}else{
setLastPage(document.URL);
window.location.href = 'login';
}
document.getElementById('choose-image').onchange = function (evt) {
var tgt = evt.target || window.event.srcElement,
files = tgt.files;
// FileReader support
if (FileReader && files && files.length) {
var fr = new FileReader();
fr.onload = function () {
document.getElementById('image-profile').src = fr.result;
}
fr.readAsDataURL(files[0]);
}else{
document.getElementById('image-profile').src = 'https://defuj.github.io/mosya.bootstrap/assets/images/user-default.png';
}
}
$('#buttonSave').click(function(e){
const name = safeString($('#dataName').val());
const phone = safeString( $('#dataPhone').val());
const account = getAccount()
if(name != '' && phone != ''){
$('#buttonSave').attr('disabled', true);
$('#buttonSave').html(spinnerWhite);
const postForm = {
id: account.id,
name: name,
phone: phone,
image: document.querySelector('#choose-image').files.length > 0 ? document.querySelector('#choose-image').files[0] : null
}
axios.postForm('auth/update_profile', postForm).then(response=>{
$('#buttonSave').attr('disabled', false);
$('#buttonSave').html('Simpan Perubahan');
let result = response.data;
// console.log(result.data);
if(result.status){
Swal.fire({
icon: 'success',
title: 'Berhasil',
text: 'Data berhasil disimpan',
}).then(res => {
if(res.value){
setAccount(result.data);
window.location.href = 'profile';
}
})
}else{
Swal.fire({
icon: 'error',
title: 'Gagal',
text: 'Data gagal disimpan',
})
}
})
.catch(error=>{
$('#buttonSave').attr('disabled', false);
$('#buttonSave').html('Simpan Perubahan');
// console.log(error);
})
}else{
Swal.fire({
icon: 'error',
title: 'Perhatian',
text: 'Data tidak boleh kosong',
})
}
});
</script>
</body>
</html>