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
|
|
|
|
2023-12-29 20:53:29 -05:00
|
|
|
const { data: bands } = (await useApiFetch<NonNullable<IBand[]>>("/band/all")) as unknown as { data: Ref<IBand[]> };
|
2023-10-11 13:23:08 -04:00
|
|
|
|
2024-04-02 01:16:34 -04:00
|
|
|
const {
|
|
|
|
data: { value: rd },
|
|
|
|
getSession,
|
|
|
|
} = useAuth();
|
|
|
|
await getSession({ force: true });
|
|
|
|
let inc = ref<number>(1);
|
|
|
|
const data = ref(rd);
|
2023-12-30 16:04:49 -05:00
|
|
|
const refresh = async () => {
|
|
|
|
await useAuth().getSession({ force: true });
|
2024-04-02 01:16:34 -04:00
|
|
|
data.value = useAuth().data.value;
|
|
|
|
//inc.value += 1;
|
2023-12-30 16:04:49 -05:00
|
|
|
};
|
2023-10-11 13:23:08 -04:00
|
|
|
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 }">
|
2024-04-02 01:16:34 -04:00
|
|
|
<a-list-item :key="item._id + inc">
|
2023-10-11 13:23:08 -04:00
|
|
|
<a-row :gutter="[5, 5]">
|
|
|
|
<a-col>
|
|
|
|
<nuxt-link :to="`/band/${item._id}`">
|
|
|
|
{{ item.name }}
|
|
|
|
</nuxt-link>
|
|
|
|
</a-col>
|
|
|
|
<!-- subscribe... -->
|
2024-04-02 01:16:34 -04:00
|
|
|
<a-col v-if="data && data.user?._id" style="margin-left: auto">
|
2023-12-30 16:04:49 -05:00
|
|
|
<a
|
2024-04-02 01:16:34 -04:00
|
|
|
v-if="!data?.user.subscriptions.bands.includes(item._id)"
|
2023-12-30 16:04:49 -05:00
|
|
|
@click="
|
|
|
|
async (e) => {
|
2024-04-02 01:16:34 -04:00
|
|
|
await hider(bands, item._id, 'subscribe', 'bands');
|
2023-12-30 16:04:49 -05:00
|
|
|
await refresh();
|
|
|
|
}
|
|
|
|
"
|
|
|
|
>
|
2023-10-11 13:23:08 -04:00
|
|
|
<icon :istyle="'regular'" name="paper-plane" :size="12" />
|
|
|
|
</a>
|
2023-12-30 16:04:49 -05:00
|
|
|
<a
|
|
|
|
v-else
|
|
|
|
@click="
|
|
|
|
async (e) => {
|
2024-04-02 01:16:34 -04:00
|
|
|
await hider(bands, item._id, 'unsubscribe', 'bands');
|
2023-12-30 16:04:49 -05:00
|
|
|
await refresh();
|
|
|
|
}
|
|
|
|
"
|
|
|
|
>
|
2023-10-11 13:23:08 -04:00
|
|
|
<icon :istyle="'regular'" name="x" :size="12" />
|
|
|
|
</a>
|
|
|
|
</a-col>
|
2024-04-02 01:16:34 -04:00
|
|
|
<a-col v-if="data?.user._id">
|
2023-12-30 16:04:49 -05:00
|
|
|
<a
|
|
|
|
@click="
|
|
|
|
async (e) => {
|
2024-04-02 01:16:34 -04:00
|
|
|
await hider(bands, item._id, 'hide', 'bands');
|
2023-12-30 16:04:49 -05:00
|
|
|
await refresh();
|
|
|
|
}
|
|
|
|
"
|
|
|
|
>
|
2023-10-11 13:23:08 -04:00
|
|
|
<icon :istyle="'regular'" name="eye-slash" :size="12" />
|
|
|
|
</a>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</a-list-item>
|
|
|
|
</template>
|
|
|
|
</a-list>
|
|
|
|
</template>
|