Skip to content

Commit

Permalink
feat: state of adoption button
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Dec 21, 2024
1 parent bf989b1 commit ee8537e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion components/AddCredits.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
outlined
label="Adopt probe"
class="text-primary !opacity-100"
@click="$emit('adopt-a-probe')"
/>
<Button v-else size="small" label="Adopt probe" @click="$emit('adopt-a-probe')"/>
</div>
Expand Down Expand Up @@ -143,17 +144,28 @@
</template>

<script setup lang="ts">
import { readItems } from '@directus/sdk';
import { useAuth } from '~/store/auth';
const { $directus } = useNuxtApp();
const config = useRuntimeConfig();
const auth = useAuth();
const user = auth.getUser as User;
defineEmits([ 'cancel', 'adopt-a-probe' ]);
const { data: adoptionsExists } = await useAsyncData('gp_adopted_probes_exist', async () => {
const adoptions = await $directus.request(readItems('gp_adopted_probes', {
filter: { userId: { _eq: user.id } },
limit: 1,
}));
return !!adoptions.length;
}, { default: () => false });
const creditsPerAdoptedProbePerDay = config.public.creditsPerAdoptedProbePerDay;
const creditsPerDollar = config.public.creditsPerDollar;
const step1Completed = auth.isLoggedIn;
const step2Completed = true;
const step2Completed = adoptionsExists.value;
const step3Completed = user.user_type === 'sponsor' || user.user_type === 'special';
</script>

0 comments on commit ee8537e

Please sign in to comment.