Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/admin single user view #314

Merged
merged 14 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.5.1",
"axios": "^1.6.8",
"eslint": "^8.50.0",
"eslint-plugin-github-commit-hash": "^1.0.3",
"eslint-plugin-import": "^2.27.5",
Expand All @@ -58,7 +59,6 @@
"prettier": "^3.1.1",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vue-tsc": "^2.0.29",
"axios": "^1.6.8"
"vue-tsc": "^2.0.29"
}
}
92 changes: 0 additions & 92 deletions apps/dashboard/src/components/ChangeInfoComponent.vue

This file was deleted.

2 changes: 1 addition & 1 deletion apps/dashboard/src/components/FormCard.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<CardComponent :header="header">
<template #topAction>
<div v-if="showEdit">
<div v-if="showEdit" class="mx-2">
<div v-if="!edit">
<Button
severity="primary"
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/src/components/FormInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { ref, watch, onMounted, type PropType } from 'vue';
import InputText from 'primevue/inputtext';
import Textarea from 'primevue/textarea';
import Calendar from 'primevue/calendar';
import type { Ref } from "vue";
import ErrorSpan from "@/components/ErrorSpan.vue";

const props = defineProps({
Expand Down
15 changes: 11 additions & 4 deletions apps/dashboard/src/components/InputSpan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
:placeholder="placeholder"
v-model="internalValue as number"
:disabled="disabled"/>

<InputNumber v-if="type === 'percentage'"
mode="decimal"
:min="0.0"
Expand All @@ -37,11 +36,16 @@
v-model="internalValue as number"
:disabled="disabled"
suffix="%"/>

<InputSwitch v-if="type === 'boolean'"
v-model="internalValue as boolean"
:disabled="disabled"/>

<Dropdown v-if="type === 'usertype'"
:options="userTypes"
optionLabel="name"
optionValue="value"
v-model="internalValue as number"
:placeholder="placeholder"
:disabled="disabled"/>
</span>
<div class="flex justify-content-end">
<ErrorSpan :error="errors"/>
Expand All @@ -58,6 +62,8 @@ import ErrorSpan from "@/components/ErrorSpan.vue";
import CalendarString from "@/components/CalendarString.vue";

import type { HintedString } from "primevue/ts-helpers";
import InputNumber from "primevue/inputnumber";
import { userTypes } from "@/utils/validation-schema";

const props = defineProps({
label: {
Expand Down Expand Up @@ -100,7 +106,8 @@ const props = defineProps({
const emit = defineEmits(['update:value']);

const stringInputs = ['text', 'textarea'];
const numberInputs = ['currency', 'percentage', 'number'];

const numberInputs = ['currency', 'number', 'usertype', 'percentage'];
const booleanInputs = ['boolean'];

const initialValue = () => {
Expand Down
6 changes: 4 additions & 2 deletions apps/dashboard/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@
"pointOfSaleCreated": "Successfully created point of sale.",
"waiveFinesSuccess": "Successfully waived fines.",
"waiveFinesRejected": "Canceled waiving fines.",
"canceled": "Canceled"
"canceled": "Canceled",
"userUpdated": "Successfully updated user."
},
"termsOfService": {
"acceptFirst": "Accept the Terms of Service",
Expand Down Expand Up @@ -324,7 +325,8 @@
"Usertype": "Usertype",
"passwordUpdated": "Password successfully updated",
"updatedUserInfo": "Succesfully updated user info.",
"userInfoUpdated": "User information successfully updated"
"userInfoUpdated": "User information successfully updated",
"userInformation": "User information"
},
"contact": {
"Contact": "Contact",
Expand Down
6 changes: 4 additions & 2 deletions apps/dashboard/src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@
"pointOfSaleCreated": "Point of sale is successvol aangemaakt.",
"waiveFinesSuccess": "Boetes zijn succesvol kwijtgescholden.",
"waiveFinesRejected": "Boetes zijn succesvol afgewezen.",
"canceled": "Geannuleerd"
"canceled": "Geannuleerd",
"userUpdated": "Gebruiker is succesvol geüpdatet."
},
"termsOfService": {
"acceptFirst": "Accepteer de Voorwaarden",
Expand Down Expand Up @@ -325,7 +326,8 @@
"Usertype": "Gebruikerstype",
"passwordUpdated": "Wachtwoord is succesvol geüpdatet",
"updatedUserInfo": "Profiel is succesvol geüpdatet.",
"userInfoUpdated": "Profiel is succesvol aangepast"
"userInfoUpdated": "Profiel is succesvol aangepast",
"userInformation": "Gebruikersinformatie"
},
"validation": {
"number": {
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ app.component('ToggleButton', ToggleButton);
app.component('Steps', Steps);
app.component('Calendar', Calendar);
app.component('ConfirmDialog', ConfirmDialog);
app.component('InputSwitch', InputSwitch);

populateStoresFromToken(apiService).then(() => {
app.mount('#app');
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/mixins/pendingPayoutsMixin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// src/mixins/pendingPayoutsMixin.ts
import { computed, type ComputedRef, watch } from 'vue';
import { computed, watch } from 'vue';
import { usePayoutStore } from '@/stores/payout.store';
import { useUserStore } from '@sudosos/sudosos-frontend-common';
import { UserRole } from '@/utils/rbacUtils';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<FormCard :header="t('userDetails.userInformation')"
@update:modelValue="edit = $event"
@save="formSubmit"
:enableEdit="true"
>
<div class="flex flex-column justify-content-between gap-2">
<UserEditForm :user="props.user" :form="form" :edit="edit" @update:edit="edit = $event"/>
</div>
</FormCard>
</template>

<script setup lang="ts">
import FormCard from "@/components/FormCard.vue";
import { onMounted, type PropType, ref, watch } from "vue";
import type { UserResponse } from "@sudosos/sudosos-client";
import { schemaToForm } from "@/utils/formUtils";
import { updateUserDetailsObject, userTypes } from "@/utils/validation-schema";
import UserEditForm from "@/modules/admin/components/users/forms/UserEditForm.vue";
import { useI18n } from "vue-i18n";

const { t } = useI18n();

const props = defineProps({
user: {
type: Object as PropType<UserResponse>,
required: true
}
});

const edit = ref(false);

const form = schemaToForm(updateUserDetailsObject);

const formSubmit = () => {
form.submit();
};

const updateFieldValues = (p: UserResponse) => {
if (!p) return;
const values = {
...p,
userType: userTypes.value.find(ut => ut.name === p.type)?.value || undefined,
isActive: p.active,
};
form.context.resetForm({ values });
};

watch(() => props.user, (newValue: UserResponse) => {
updateFieldValues(newValue);
});

onMounted(() => {
if (props.user) {
updateFieldValues(props.user);
}
});
</script>

<style scoped lang="scss">

</style>
Loading
Loading