diff --git a/assets/main.css b/assets/main.css
index 14ac617..021e600 100644
--- a/assets/main.css
+++ b/assets/main.css
@@ -385,6 +385,10 @@ section.mi .row input[type=checkbox] {
position: absolute;
}
+label.error {
+ color: var(--text-important);
+}
+
section.estimates .entry {
padding: 10px 3px;
border-bottom: 2px solid var(--outline);
diff --git a/components/app.vue b/components/app.vue
index 2a99736..9b8e70d 100644
--- a/components/app.vue
+++ b/components/app.vue
@@ -26,7 +26,11 @@ v-else-if="active == 3"
@removeFeeTemp="(fee) => fees = fees.filter(f => f.id != fee.id)"
/>
-
+
@@ -97,12 +101,36 @@ function getUser() {
this.user = result[0]
if (this.user.avatar) return
- fetch("/assets/image/empty-avatar.jpg").then(r => r.blob()).
- then(b => this.user.avatar = b)
+ return getAvatar(token)
+ }).then(b => {
+ const validTypes = ['image/jpeg', 'image/png']
+
+ if (!validTypes.includes(b.type) || b.size <= 1) {
+ fetch("/assets/image/empty-avatar.jpg").
+ then(r => r.blob()).then( a => this.user.avatar = a )
+ return
+ }
+
+ this.user.avatar = b
})
}
+function getAvatar(t) {
+ return fetch("/api/user/avatar",
+ {method: 'GET',
+ headers: {
+ "Accept": "application/json",
+ "Authorization": `Bearer ${t || this.token}`,
+ }
+ }).then(r => r.blob())
+}
+
+function updateAvatar() {
+ const token = getCookie("skouter")
+ getAvatar(token).then(b => this.user.avatar = b)
+}
+
function getFees() {
const token = getCookie("skouter")
@@ -181,6 +209,8 @@ export default {
getUser,
getFees,
refreshToken,
+ updateAvatar,
+ getAvatar,
},
data() {
return {
diff --git a/components/settings.vue b/components/settings.vue
index d9eba03..b296cdd 100644
--- a/components/settings.vue
+++ b/components/settings.vue
@@ -6,9 +6,10 @@
Avatar
changeAvatar(e.target.files[0])"
+@change="e => uploadAvatar(e.target.files[0])"
/>
+