<script setup lang="ts">
import type { RefresherCustomEvent } from "@ionic/vue";
import { notificationsOutline, scanOutline, settingsOutline } from "ionicons/icons";
import Asset from "./components/asset.vue";
import IssuingAsset from "./components/issuing-asset.vue";
import MyRevenue from "./components/my-revenue.vue";
import TradeSettings from "./components/trade-settings.vue";
import UserInfo from "./components/user-info.vue";
import WalletCard from "./components/wallet-card.vue";

const { vibrate } = useHaptics();
const walletStore = useWalletStore();

async function handleRefresh(event: RefresherCustomEvent) {
  vibrate();
  await walletStore.initializeWallet();
  setTimeout(() => {
    event.target.complete();
  }, 500);
}
</script>

<template>
  <IonPage>
    <ion-header class="ion-no-border">
      <ion-toolbar class="ui-toolbar">
        <div slot="end">
          <ion-button fill="clear">
            <ion-icon slot="icon-only" :icon="scanOutline" />
          </ion-button>
          <ion-button fill="clear">
            <ion-icon slot="icon-only" :icon="notificationsOutline" />
          </ion-button>
          <ion-button fill="clear" router-link="/system-settings">
            <ion-icon slot="icon-only" :icon="settingsOutline" />
          </ion-button>
        </div>
      </ion-toolbar>
    </ion-header>
    <IonContent :fullscreen="true" class="ion-padding">
      <ion-refresher slot="fixed" @ion-refresh="handleRefresh($event)">
        <ion-refresher-content />
      </ion-refresher>

      <div class="flex flex-col space-y-5">
        <UserInfo />
        <WalletCard />
        <Asset />
        <IssuingAsset />
        <MyRevenue />
        <TradeSettings />
      </div>
    </IonContent>
  </IonPage>
</template>

<style scoped></style>
