<template>
  <slot v-if="s.allowed"/>
  <v-card v-if="!s.allowed" rounded="0" title="Dexorder Closed Beta">
    <v-card-item><v-text-field v-model="password" label="Beta Password" class="maxw"/></v-card-item>
    <v-card-text>
      Follow our social media for public release updates!
    </v-card-text>
    <v-card-item><social/></v-card-item>
  </v-card>
</template>

<script setup>
import {useStore} from "@/store/store";
import Social from "@/components/Social.vue";
import {ref, watchEffect} from "vue";
import {hashMessage} from "ethers";

const s = useStore()

const password = ref(null)
const passHash = '0x3e6e96bd824dd0a5e5361853719ef051e939b91f3fc6fd0f685b4c414c7ba89e'

watchEffect(()=>{
  if (!password.value) return
  const canonical = password.value.replace(/[^a-zA-Z]/g, '').toLowerCase();
  const hash = hashMessage(canonical);
  if (hash===passHash)
    s.allowed = true
})

</script>

<style scoped lang="scss">

</style>
