Skip to content

Commit

Permalink
#48 add message when series is created. Change color of message's type
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcellino-Palerme committed Jul 8, 2024
1 parent 57ec5bc commit 4185895
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 18 deletions.
24 changes: 11 additions & 13 deletions components/ManageSerie.async.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const { t } = useI18n();
const dialog = ref<boolean>(false);
const validateForm = ref(false);
const rUpload = ref(false);
const stateMessage = useState<{actif:boolean,
message:string,
type:string}>("stateMessage")

const nameRules = ref([
(value: string) =>
Expand Down Expand Up @@ -86,14 +89,7 @@ async function sendFile() {

async function submit (event:SubmitEvent) {

// check if we have daughter solution
// if (rDaughterTable.value.length === 0) {
// // TODO: show error message
// return;
// }
// Group value by file (daughter solution)
console.log("plouf");

// Group value by file (daughter solution)
const daughterGroup = rDaughterTable.value.reduce(
(acc: {[key:string]:{}[]}, cur:{
idFile: string;
Expand All @@ -110,9 +106,7 @@ async function submit (event:SubmitEvent) {
expectedArea:cur.expectedArea
});
return acc;
}, {});
console.log("0");

}, {});
// send serie name and all associated daughter solution
$fetch('/api/AddSerie', {
method: 'POST',
Expand All @@ -123,11 +117,15 @@ async function submit (event:SubmitEvent) {
})
.then(() => {
rUpload.value = !rUpload.value;
console.log(1);
stateMessage.value.type="success"
stateMessage.value.message=t("message.success.createSerie")
stateMessage.value.actif=true

})
.catch(() => {
console.log("error");
stateMessage.value.type="error"
stateMessage.value.message=t("message.error.createSerie")
stateMessage.value.actif=true
// TODO: show error message
});
}
Expand Down
24 changes: 24 additions & 0 deletions components/StateMessage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


<script setup lang="ts">
const stateMessage = useState("stateMessage", () => {return {
actif:false,
type : undefined,
message: ""}
})
const timeout = -1
</script>

<template>
<v-snackbar
v-model="stateMessage.actif"
:timeout="timeout"
>
<v-alert
v-model="stateMessage.actif"
:type="stateMessage.type"
closable
:text="stateMessage.message"
/>
</v-snackbar>
</template>
6 changes: 6 additions & 0 deletions lang/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ export default {
confQuestion: "Are you sure to continue?",
created: "created",
createdFail: "Project's creation failed",
error:{
createSerie: "Failed to create serie"
},
fitting: "The fitting ",
koDelProject: "We didn't delete, the named project",
loading: "Loading",
noEmpty: "Can't be empty",
okDelProject: "We deleted, the named project",
success:{
createSerie: "La gamme a été créée"
},
updateFail: "Update fail",
updateInProgress: "Update of project in progress",
updateProject:"updated",
Expand Down
6 changes: 6 additions & 0 deletions lang/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,18 @@ export default {
confQuestion: "Êtes-vous sûr de vouloir continuer ?",
created: "a été créé",
createdFail: "La création du projet a échoué",
error:{
createSerie: "Echech de la création de la gamme"
},
fitting: "L'ajustement ",
koDelProject: "Nous n'avons pas supprimé le projet",
loading: "chargement",
noEmpty:"ne peut pas être vide",
okDelProject: "Nous avons supprimé le projet",
required: "Champ obligatoire",
success:{
createSerie: "La gamme a été créée"
},
updateFail: "Échec de la mise à jour",
updateInProgress: "Le project est en cours de mise à jour",
updateProject:"est mise à jour",
Expand Down
1 change: 1 addition & 0 deletions pages/serie.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ const ListComp : {[key:string]: string | ConcreteComponent} = {
</v-window>
</v-col>
</v-row>
<state-message />
</NuxtLayout>
</template>
10 changes: 5 additions & 5 deletions plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const myCustomLightTheme: ThemeDefinition = {
dark: false,
colors: {
primary: '#8bc34a',
secondary: '#cddc39',
accent: '#f44336',
error: '#ff9800',
warning: '#607d8b',
secondary: '#607d8b',
accent: '#cddc39',
error: '#f44336',
warning: '#ff9800',
info: '#00bcd4',
success: '#2196f3'
success: '#8bc34a'
}
};
export default defineNuxtPlugin((app) => {
Expand Down

0 comments on commit 4185895

Please sign in to comment.