implemented mode change

This commit is contained in:
2024-03-25 23:23:37 +01:00
parent 45a4b58f26
commit 3f88f6b821
71 changed files with 3020 additions and 1006 deletions

View File

@ -32,10 +32,11 @@
<td
:class="['Name', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Name-darkmode' : 'Name-lightmode']">
<nuxt-link to="/maintenanceVisits" id="nuxt-link" class="button"
:class="[darkMode ? 'button-darkmode' : 'button-lightmode']"
:class="[darkMode ? 'button-darkmode' : 'button-lightmode', darkMode ? 'nuxt-link-darkmode' : 'nuxt-link-lightmode']"
@click="goToChosenMVT(template.checklistID)">
{{ template.name }}
</nuxt-link></td>
</nuxt-link>
</td>
<td
:class="['ID', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'ID-darkmode' : 'ID-lightmode']">
{{ template.checklistID }}</td>
@ -48,8 +49,8 @@
</table>
</div>
</template>
<script setup>
import { ref, onMounted, watch } from 'vue';
import Axios from '../axios.config.js';
@ -59,6 +60,8 @@ import { computed } from 'vue';
// get accesss to the store
const store = useStore()
const modeChanged = computed(() => store.state.updateDarkMode);
const goToChosenMVT = (id) => {
store.commit('setChosenMVT', id);
store.commit('changeToTemplate');
@ -68,7 +71,7 @@ const customerFilter = computed(() => store.state.filteredByCustomer);
const searchable = computed(() => store.state.searchable);
const mvtSearchFilter = ref('');
const darkMode = ref(true)
const darkMode = ref('');
const maintenanceVisitTemplates = ref([]);
//get all maintenance visit templates
@ -115,10 +118,29 @@ const getFilteredMVTByCustomer = async () => {
}
}
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
if (loggedInUserDarkModeBool == 1) {
darkMode.value = true;
} else {
darkMode.value = false;
}
}
function getItem(item) {
if (process.client) {
return localStorage.getItem(item)
} else {
return undefined
}
}
watch(searchable, updateSearchTerm);
watch(customerFilter, getMaintenanceVisitTemplates);
watch(modeChanged, getSession)
onMounted(async () => {
getSession();
await getMaintenanceVisitTemplates();
});
</script>
@ -127,10 +149,10 @@ onMounted(async () => {
export default {
name: "MaintenanceVisitsTemplateTable",
};
</script>
</script>
<style scoped>
.data {
display: flex;
@ -176,9 +198,16 @@ export default {
#nuxt-link {
text-decoration: none;
}
.nuxt-link-darkmode {
color: white;
}
.nuxt-link-lightmode {
color: #000;
}
.dataInput {
display: flex;
flex-direction: row;