Feat: pouoir mettre password user nullable et aussi notification global
This commit is contained in:
parent
5c8779cb6a
commit
ae7574045e
@ -66,7 +66,7 @@
|
|||||||
<strong>1.</strong> Définir nom et email.
|
<strong>1.</strong> Définir nom et email.
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm mb-2">
|
<p class="text-sm mb-2">
|
||||||
<strong>2.</strong> Saisir un mot de passe initial.
|
<strong>2.</strong> Le mot de passe initial est optionnel.
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm mb-0">
|
<p class="text-sm mb-0">
|
||||||
<strong>3.</strong> Assigner le rôle adapté au périmètre
|
<strong>3.</strong> Assigner le rôle adapté au périmètre
|
||||||
|
|||||||
@ -15,14 +15,15 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, reactive } from "vue";
|
import { computed, onMounted, reactive } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import Swal from "sweetalert2";
|
|
||||||
import UserCreatePresentation from "@/components/Organism/Parametrage/Users/UserCreatePresentation.vue";
|
import UserCreatePresentation from "@/components/Organism/Parametrage/Users/UserCreatePresentation.vue";
|
||||||
import { useAccessControlStore } from "@/stores/accessControlStore";
|
import { useAccessControlStore } from "@/stores/accessControlStore";
|
||||||
|
import { useNotificationStore } from "@/stores/notification";
|
||||||
import { useUserStore } from "@/stores/userStore";
|
import { useUserStore } from "@/stores/userStore";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const accessControlStore = useAccessControlStore();
|
const accessControlStore = useAccessControlStore();
|
||||||
|
const notificationStore = useNotificationStore();
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id: null,
|
id: null,
|
||||||
@ -39,8 +40,7 @@ const submitDisabled = computed(
|
|||||||
userStore.isLoading ||
|
userStore.isLoading ||
|
||||||
accessControlStore.isLoading ||
|
accessControlStore.isLoading ||
|
||||||
!form.name.trim() ||
|
!form.name.trim() ||
|
||||||
!form.email.trim() ||
|
!form.email.trim()
|
||||||
!form.password.trim()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@ -80,26 +80,19 @@ const submitUser = async () => {
|
|||||||
const user = await userStore.createUser({
|
const user = await userStore.createUser({
|
||||||
name: form.name.trim(),
|
name: form.name.trim(),
|
||||||
email: form.email.trim(),
|
email: form.email.trim(),
|
||||||
password: form.password.trim(),
|
password: form.password.trim() || null,
|
||||||
roles: form.roles,
|
roles: form.roles,
|
||||||
permissions: form.permissions,
|
permissions: form.permissions,
|
||||||
});
|
});
|
||||||
|
|
||||||
await Swal.fire({
|
notificationStore.created("L'utilisateur");
|
||||||
icon: "success",
|
|
||||||
title: "Succès",
|
|
||||||
text: "L'utilisateur a été créé avec succès.",
|
|
||||||
confirmButtonText: "Voir le détail",
|
|
||||||
});
|
|
||||||
|
|
||||||
router.push(`/parametrage/utilisateurs/${user.id}`);
|
router.push(`/parametrage/utilisateurs/${user.id}`);
|
||||||
} catch {
|
} catch {
|
||||||
await Swal.fire({
|
notificationStore.error(
|
||||||
icon: "error",
|
"Erreur de création",
|
||||||
title: "Erreur",
|
userStore.error || "Impossible de créer l'utilisateur."
|
||||||
text: userStore.error || "Impossible de créer l'utilisateur.",
|
);
|
||||||
confirmButtonText: "Fermer",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user