<template>
  <div class="app-container h-full">
    <FullscreenViewport v-if="platform === 'ios' || platform === 'android'"/>
    <router-view/>
    <CartButton/>
  </div>
</template>

<script setup>
import {onMounted, ref, watch} from "vue";
import {useWebAppViewport, useBackButton} from 'vue-tg';
import {useMiniApp, FullscreenViewport} from 'vue-tg';
import {useRoute, useRouter} from "vue-router";
import CartButton from "@/components/CartButton.vue";

const tg = useMiniApp();
const platform = ref();
platform.value = tg.platform;

const {disableVerticalSwipes} = useWebAppViewport();
disableVerticalSwipes();

const router = useRouter();
const route = useRoute();
const backButton = useBackButton();

watch(
    () => route,
    () => {
      if (route.name === 'home') {
        backButton.hide?.();
      } else {
        backButton.show?.();
        backButton.onClick?.(() => {
          window.Telegram.WebApp.HapticFeedback.impactOccurred('light');
          router.back();

        });
      }
    },
    {immediate: true, deep: true}
);
</script>
