Skip to content

Commit e50a76b

Browse files
committed
feat: add momemnt js, format html entities
1 parent adedbe4 commit e50a76b

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"axios": "^0.21.0",
1414
"core-js": "^3.6.5",
1515
"dayjs": "^1.9.6",
16+
"moment": "^2.29.1",
1617
"normalize.css": "^8.0.1",
1718
"nprogress": "^0.2.0",
1819
"swrv": "^1.0.0-beta.5",

src/components/modals/profile/UpdateProfile.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<div class="input-section">
5252
<label for="dob">Date of Birth
5353
</label>
54-
<input type="date" id="dob" placeholder="YYYY-MM-DD" v-model="userCopy.dob">
54+
<input type="date" id="dob" placeholder="YYYY-MM-DD" v-model="userCopy.dob_formatted" >
5555
</div>
5656

5757
<div class="input-section">
@@ -84,7 +84,8 @@
8484
import Modal from '@/components/layout/Modal.vue'
8585
import { reactive, toRefs, inject } from 'vue'
8686
import { usersApi } from '@/api'
87-
// import { debounce } from 'lodash'
87+
import { cloneDeep } from 'lodash'
88+
import moment from 'moment'
8889
8990
export default {
9091
name: 'update-profile-modal',
@@ -94,6 +95,12 @@ export default {
9495
setup(props, { emit }) {
9596
/* Internal Methods */
9697
// const checkFormValid = () => v.form.valid = v.form.email.valid && v.form.email.unique && v.form.emailPassword.valid
98+
const decodeHtml = html => {
99+
let text = document.createElement('textarea')
100+
text.innerHTML = html
101+
return text.value
102+
}
103+
97104
98105
/* Template Methods */
99106
const updateProfile = () => {
@@ -121,7 +128,7 @@ export default {
121128
122129
/* Template Data */
123130
const v = reactive({
124-
userCopy: props.user,
131+
userCopy: cloneDeep(props.user), // don't want reactiveness
125132
formValid: false,
126133
usernameUnique: true,
127134
usernameValid: true,
@@ -130,6 +137,12 @@ export default {
130137
errorMessage: ''
131138
})
132139
140+
v.userCopy.dob_formatted = moment(v.userCopy.dob).format('YYYY-MM-DD')
141+
v.userCopy.name = decodeHtml(v.userCopy.name)
142+
v.userCopy.gender = decodeHtml(v.userCopy.gender)
143+
v.userCopy.website = decodeHtml(v.userCopy.website)
144+
v.userCopy.location = decodeHtml(v.userCopy.location)
145+
v.userCopy.language = decodeHtml(v.userCopy.language)
133146
/* Watch Data */
134147
// watch(() => v.form.emailPassword.val, val => {
135148
// v.form.emailPassword.valid = val && val.length >= 1 && val.length <= 72

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5815,6 +5815,11 @@ mkdirp@^1.0.3:
58155815
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
58165816
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
58175817

5818+
moment@^2.29.1:
5819+
version "2.29.1"
5820+
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
5821+
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
5822+
58185823
move-concurrently@^1.0.1:
58195824
version "1.0.1"
58205825
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"

0 commit comments

Comments
 (0)