2023-10-11 13:23:08 -04:00
|
|
|
<script lang="ts" setup>
|
2023-12-20 17:23:31 -05:00
|
|
|
import { IBand } from "@models/band";
|
2023-10-11 13:23:08 -04:00
|
|
|
import icon from "~/components/icon.vue";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { subscriptions, bp } from "@client/listActions";
|
|
|
|
import { IUser } from "@models/user";
|
2023-10-11 13:23:08 -04:00
|
|
|
|
|
|
|
const { data: bands } = (await useApiFetch<NonNullable<IBand[]>>(
|
2023-12-09 17:22:08 -05:00
|
|
|
"/band/all",
|
2023-12-01 17:51:00 -05:00
|
|
|
)) as unknown as { data: Ref<IBand[]> };
|
2023-10-11 13:23:08 -04:00
|
|
|
|
|
|
|
const { data: rd }: { data: any } = useAuth();
|
|
|
|
const data = rd as { user: IUser };
|
|
|
|
|
|
|
|
const hider = subscriptions;
|
|
|
|
if (bands.value == null) bands.value = [];
|
2023-12-09 17:22:08 -05:00
|
|
|
useHead({
|
|
|
|
title: "Bands",
|
|
|
|
});
|
2023-10-11 13:23:08 -04:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<a-list v-model:data-source="bands" :grid="bp">
|
|
|
|
<template #renderItem="{ item }">
|
|
|
|
<a-list-item>
|
|
|
|
<a-row :gutter="[5, 5]">
|
|
|
|
<a-col>
|
|
|
|
<nuxt-link :to="`/band/${item._id}`">
|
|
|
|
{{ item.name }}
|
|
|
|
</nuxt-link>
|
|
|
|
</a-col>
|
|
|
|
<!-- subscribe... -->
|
|
|
|
<a-col v-if="data && data.user?._id" style="margin-left: auto">
|
|
|
|
<a
|
|
|
|
v-if="!data?.user.subscriptions.bands.includes(item._id)"
|
|
|
|
@click="(e) => hider(bands, item._id, 'subscribe', 'bands')"
|
|
|
|
>
|
|
|
|
<icon :istyle="'regular'" name="paper-plane" :size="12" />
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
v-else
|
|
|
|
@click="(e) => hider(bands, item._id, 'unsubscribe', 'bands')"
|
|
|
|
>
|
|
|
|
<icon :istyle="'regular'" name="x" :size="12" />
|
|
|
|
</a>
|
|
|
|
</a-col>
|
|
|
|
<a-col v-if="data?.user._id">
|
|
|
|
<a @click="(e) => hider(bands, item._id, 'hide', 'bands')">
|
|
|
|
<icon :istyle="'regular'" name="eye-slash" :size="12" />
|
|
|
|
</a>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</a-list-item>
|
|
|
|
</template>
|
|
|
|
</a-list>
|
|
|
|
</template>
|