-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/stripe-integration
- Loading branch information
Showing
13 changed files
with
404 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<template> | ||
<CardComponent :header="t('profile.keyGet')"> | ||
<div> | ||
<p>{{ $t('profile.keyOldRemoved') }}</p> | ||
<p>{{apiKeyMessage || ' '}}</p> | ||
</div> | ||
<div style="margin-top: 1rem"> | ||
<Button severity="danger" :label="t('profile.keyGetNew')" @click="updateApiKey" /> | ||
</div> | ||
</CardComponent> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import CardComponent from "@/components/CardComponent.vue"; | ||
import { ref } from "vue"; | ||
import { useAuthStore } from "@sudosos/sudosos-frontend-common"; | ||
import apiService from "@/services/ApiService"; | ||
import { useToast } from "primevue/usetoast"; | ||
import { useI18n } from "vue-i18n"; | ||
import { handleError } from "@/utils/errorUtils"; | ||
const authStore = useAuthStore(); | ||
const apiKeyMessage = ref(); | ||
const toast = useToast(); | ||
const { t } = useI18n(); | ||
function updateApiKey() { | ||
authStore.updateUserKey(apiService).then((res) => { | ||
//Succes | ||
if(res) { | ||
toast.add({ | ||
severity: "success", | ||
summary: "Success", | ||
detail: `${t('profile.newKey')} \n ${res.key} \n ${t('profile.keyNotSaved')}` | ||
}); | ||
} | ||
}).catch((err) => { | ||
handleError(err, toast); | ||
}); | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<template> | ||
<CardComponent :header="$t('profile.changeUserInfo')" :class="{ 'opacity-30': !isLocal}"> | ||
<form @submit="changeUserInfo"> | ||
<small v-if="!isLocal">{{ $t('profile.notManagedThroughSudoSOS') }}</small> | ||
<div class="field"> | ||
<p>{{ $t('profile.firstName')}}</p> | ||
<InputText :disabled="!isLocal" v-bind="firstName"/> | ||
<small class="warning">{{errors.firstName || ' '}}</small> | ||
</div> | ||
<div class="field"> | ||
<p>{{ $t('profile.lastName')}}</p> | ||
<InputText :disabled="!isLocal" v-bind="lastName"/> | ||
<small class="warning">{{errors.lastName || ' '}}</small> | ||
</div> | ||
<div class="field"> | ||
<p>{{ $t('profile.emailAddress')}}</p> | ||
<InputText :disabled="!isLocal" v-bind="email"/> | ||
<small class="warning">{{errors.email || ' '}}</small> | ||
</div> | ||
<div style="margin-top: 1rem"> | ||
<Button | ||
severity="danger" | ||
:disabled="!isLocal" | ||
:label="$t('profile.updateInfo')" | ||
type="submit" | ||
/> | ||
</div> | ||
</form> | ||
</CardComponent> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import CardComponent from "@/components/CardComponent.vue"; | ||
import { useForm } from "vee-validate"; | ||
import { useUserStore } from "@sudosos/sudosos-frontend-common"; | ||
import { useToast } from "primevue/usetoast"; | ||
import { useI18n } from "vue-i18n"; | ||
import { simpleUserDetailsSchema } from "@/utils/validation-schema"; | ||
import { onBeforeMount } from "vue"; | ||
import apiService from "@/services/ApiService"; | ||
import { handleError } from "@/utils/errorUtils"; | ||
const toast = useToast(); | ||
const userStore = useUserStore(); | ||
const { t } = useI18n(); | ||
let isLocal = false; | ||
if(userStore.getCurrentUser.user) { | ||
isLocal = (userStore.getCurrentUser.user.type == "LOCAL_USER"); | ||
} | ||
const { defineComponentBinds, handleSubmit, errors, setValues } = useForm({ | ||
validationSchema: simpleUserDetailsSchema, | ||
}); | ||
const firstName = defineComponentBinds('firstName', {}); | ||
const lastName = defineComponentBinds('lastName', {}); | ||
const email = defineComponentBinds('email', {}); | ||
onBeforeMount(() => { | ||
setValues({ | ||
firstName: userStore.getCurrentUser.user?.firstName, | ||
lastName: userStore.getCurrentUser.user?.lastName, | ||
email: userStore.getCurrentUser.user?.email, | ||
} | ||
); | ||
}); | ||
const changeUserInfo = handleSubmit(async (values) => { | ||
if (userStore.getCurrentUser.user) { | ||
apiService.user.updateUser(userStore.getCurrentUser.user.id, { | ||
firstName: values.firstName, | ||
lastName: values.lastName, | ||
email: values.email, | ||
}).then(() => { | ||
toast.add({ | ||
severity: "success", | ||
summary: "Success", | ||
detail: `${t('userInfoUpdated')}`, | ||
life: 3000, | ||
}); | ||
}).catch((err) => { | ||
handleError(err, toast); | ||
}); | ||
} | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.warning { | ||
color: red; /* Set the error text color to red */ | ||
margin-top: 4px; /* Add some space between the input and the error text */ | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<template> | ||
<CardComponent :header="t('profile.changePassword')" :class="{ 'opacity-30': !isLocal}"> | ||
<form @submit="changeUserPassword"> | ||
<div class="field"> | ||
<p>{{ $t('profile.password') }}</p> | ||
<InputText type="password" id="password" :disabled="!isLocal" v-bind="password"/> | ||
<small class="warning">{{errors.password || ' '}}</small> | ||
</div> | ||
<div class="field"> | ||
<p>{{ $t('profile.passwordConfirm') }}</p> | ||
<InputText type="password" id="passwordConfirm" :disabled="!isLocal" v-bind="passwordConfirm"/> | ||
<small class="warning">{{errors.passwordConfirm || ' '}}</small> | ||
</div> | ||
<div style="margin-top: 1rem"> | ||
<Button | ||
severity="danger" | ||
:disabled="!isLocal" | ||
:label="t('profile.passwordUpdate')" | ||
type="submit" | ||
/> | ||
</div> | ||
</form> | ||
</CardComponent> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import CardComponent from "@/components/CardComponent.vue"; | ||
import { useForm } from "vee-validate"; | ||
import apiService from "@/services/ApiService"; | ||
import { useUserStore } from "@sudosos/sudosos-frontend-common"; | ||
import { useToast } from "primevue/usetoast"; | ||
import { useI18n } from "vue-i18n"; | ||
import { editPasswordSchema } from "@/utils/validation-schema"; | ||
import { handleError } from "@/utils/errorUtils"; | ||
const toast = useToast(); | ||
const userStore = useUserStore(); | ||
const { t } = useI18n(); | ||
const { defineComponentBinds, handleSubmit, errors } = useForm({ | ||
validationSchema: editPasswordSchema, | ||
}); | ||
const password = defineComponentBinds('password', {}); | ||
const passwordConfirm = defineComponentBinds('passwordConfirm', {}); | ||
let isLocal = false; | ||
if(userStore.getCurrentUser.user) { | ||
isLocal = (userStore.getCurrentUser.user.type == "LOCAL_USER"); | ||
} | ||
const changeUserPassword = handleSubmit(async (values) => { | ||
if (userStore.getCurrentUser.user) { | ||
apiService.user.updateUserLocalPassword( | ||
userStore.getCurrentUser.user?.id, { password: values.password }).then(() => { | ||
toast.add({ | ||
severity: "success", | ||
summary: "Success", | ||
detail: `${t('passwordUpdated')}`, | ||
life: 3000, | ||
});}).catch((err) => handleError(err, toast));}}); | ||
</script> | ||
|
||
|
||
|
||
<style scoped> | ||
.warning { | ||
color: red; /* Set the error text color to red */ | ||
margin-top: 4px; /* Add some space between the input and the error text */ | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<CardComponent :header="$t('profile.pinChange')"> | ||
<form id="update-pin-form" @submit="changeUserPin"> | ||
<div class="field"> | ||
<p>{{ $t('profile.pinNew')}}</p> | ||
<InputText v-bind="pin" /> | ||
<small class="warning">{{errors.pin || ' '}}</small> | ||
</div> | ||
<div class="field"> | ||
<p>{{ $t('profile.pinConfirm')}}</p> | ||
<InputText v-bind="pinConfirm" /> | ||
<small class="warning">{{errors.pinConfirm || ' '}}</small> | ||
</div> | ||
<div style="margin-top: 1rem"> | ||
<Button severity="danger" type="submit" :label="t('profile.pinChange')" /> | ||
</div> | ||
</form> | ||
</CardComponent> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import CardComponent from "@/components/CardComponent.vue"; | ||
import { useForm } from "vee-validate"; | ||
import apiService from "@/services/ApiService"; | ||
import { useUserStore } from "@sudosos/sudosos-frontend-common"; | ||
import { useToast } from "primevue/usetoast"; | ||
import { useI18n } from "vue-i18n"; | ||
import { editPinSchema } from "@/utils/validation-schema"; | ||
import { handleError } from "@/utils/errorUtils"; | ||
const userStore = useUserStore(); | ||
const toast = useToast(); | ||
const { t } = useI18n(); | ||
const { defineComponentBinds, handleSubmit, errors } = useForm({ | ||
validationSchema: editPinSchema, | ||
}); | ||
const pin = defineComponentBinds('pin', {}); | ||
const pinConfirm = defineComponentBinds('pinConfirm', {}); | ||
const changeUserPin = handleSubmit(async (values) => { | ||
if (userStore.getCurrentUser.user) { | ||
apiService.user.updateUserPin( | ||
userStore.getCurrentUser.user.id, | ||
{ pin: values.pinConfirm }) | ||
.then(() => { | ||
toast.add({ | ||
severity: "success", | ||
summary: "Success", | ||
detail: `${t('passwordUpdated')}`, | ||
life: 3000, | ||
}); | ||
}) | ||
.catch((err) => { | ||
handleError(err, toast); | ||
}); | ||
} | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.warning { | ||
color: red; /* Set the error text color to red */ | ||
margin-top: 4px; /* Add some space between the input and the error text */ | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.