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

@ -29,7 +29,7 @@
<td
:class="['Name', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Name-darkmode' : 'Name-lightmode']">
<nuxt-link to="/productionOrders" 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="goToChosenPOT(template.templateID)">
{{ template.name }}
</nuxt-link>
@ -43,8 +43,8 @@
</table>
</div>
</template>
<script setup>
import { ref, onMounted, watch } from 'vue';
import Axios from '../axios.config.js';
@ -54,6 +54,8 @@ import { computed } from 'vue';
// get accesss to the store
const store = useStore()
const modeChanged = computed(() => store.state.updateDarkMode);
const goToChosenPOT = (id) => {
store.commit('setChosenPOT', id);
store.commit('changeToTemplate');
@ -63,7 +65,7 @@ const customerFilter = computed(() => store.state.filteredByCustomer);
const searchable = computed(() => store.state.searchable);
const potSearchFilter = ref('');
const darkMode = ref(true);
const darkMode = ref('');
const productionOrderTemplates = ref([]);
//get all productionOrder templates
@ -110,10 +112,29 @@ const getFilteredPOTByCustomer = 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(customerFilter, getProductionOrderTemplates);
watch(searchable, updateSearchTerm);
watch(modeChanged, getSession)
onMounted(async () => {
getSession();
await getProductionOrderTemplates();
});
</script>
@ -122,9 +143,9 @@ onMounted(async () => {
export default {
name: "ProductionOrdersTemplateTable",
};
</script>
</script>
<style scoped>
.section-darkmode {
background-color: #2c2c2c;
@ -179,9 +200,16 @@ export default {
#nuxt-link {
text-decoration: none;
}
.nuxt-link-darkmode {
color: white;
}
.nuxt-link-lightmode {
color: #000;
}
.table-row {
display: flex;
flex-direction: row;