import { defineStore } from 'pinia'

const savedUTCFlag = sessionStorage.getItem('UTCFlag')

export const useTimeZoneStore = defineStore('timeZone', () => {
  const UTCFlag = ref(Boolean(savedUTCFlag))

  const toggleUTCFlag = (flag: boolean) => {
    UTCFlag.value = flag
    if (flag) {
      sessionStorage.setItem('UTCFlag', 'true')
    } else {
      sessionStorage.removeItem('UTCFlag')
    }
  }

  return {
    UTCFlag,
    toggleUTCFlag,
  }
})
