<template>
  <v-row no-gutters class="fill-height" align="center" justify="center">
    <v-col cols="12" lg="6" md="6" sm="6" class="text-center text-subtitle-1">
      You must have a customer to view this page. Please join or contact your
      administrator for access.
      <v-row no-gutters justify="center" align="center" class="mt-2">
        <v-btn
          @click="goToAccount"
          rounded="xl"
          variant="tonal"
          class="text-none text-subtitle-2"
        >
          Go to Organization Page
        </v-btn>
        <span class="mx-2">or</span>
        <v-btn
          @click="createCustomer"
          rounded="xl"
          variant="tonal"
          class="text-none text-subtitle-2"
        >
          Create an Customer
        </v-btn>
      </v-row>
    </v-col>
  </v-row>
</template>

<script setup lang="ts">
definePageMeta({
  layout: "plain",
});

const { APP_NAME, APP_ORG } = useRuntimeConfig().public;

function goToAccount() {
  window.location.href = `${APP_ORG}`;
}

const { authenticate } = useLocalAuth();

authenticate();

const { currentUser } = useLocalAuth();

function createCustomer() {
  if (APP_NAME.toLowerCase() === "org") {
    navigateTo({
      name: "org-organizations-customers-add",
      params: { organization: currentUser.value?.defaultOrg },
    });
  } else {
    window.location.href = `${APP_ORG}/org/${currentUser.value?.defaultOrg}/customers/add`;
  }
}
</script>
