<template>
  <PageHeader />
  <main :class="[loggedInUserDarkModeBoolean ? 'main-darkmode' : 'main-lightmode']">
    <slot />
  </main>
</template>
  
  
<script setup>
import { ref, onMounted, watch } from 'vue';

import PageHeader from "../layouts/PageHeader.vue";
import { useStore } from 'vuex';
import { computed } from 'vue';

const store = useStore();
// const modeChanged = computed(() => store.state.updateDarkMode);

// watch(modeChanged, getSession)

const loggedInUserDarkModeBoolean = ref('');

const getSession = async () => {
    const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
    if (loggedInUserDarkModeBool == 1) {
        loggedInUserDarkModeBoolean.value = true;
    } else {
        loggedInUserDarkModeBoolean.value = false;
    }
}

function getItem(item) {
    if (process.client) {
        return localStorage.getItem(item)
    } else {
        return undefined
    }
}

onMounted(async () => {
    await getSession();
});
</script>

<script>
export default {
  name: "empty",
}
</script>    
    
    
<style scoped>
* {
  box-sizing: border-box;
}


main {
  display: flex;
  flex-direction: row;
  gap: 0.625rem;
  padding: 0.625rem 1.5625rem 0.625rem 0.625rem;
  height: 100vh;
  width: 100vw;
  height: 100%;
  width: 100%;
}

.main-darkmode {
  background-color: #212121;
}

.main-lightmode {
  background-color: #EBEBEB;
}
</style>