apps/web/src/views/TicketsView.vue (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
<script lang="ts" setup>
import type { SanitisedTicket as Ticket } from "@stealth-developers/api";
import { computed, onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import TimeAgo from "@/components/TimeAgo.vue";
import UserChip from "@/components/UserChip.vue";
import { client } from "@/stores/api";
const route = useRoute();
const guildId = computed(() => route.params.guildId as string);
const tickets = ref<Ticket[]>([]);
const cursor = computed(() => tickets.value.length);
const hasMore = ref(false);
onMounted(async () => {
const res = await client.api
.guilds({ guildId: guildId.value })
.tickets.get({ query: { limit: 50, offset: cursor.value } });
tickets.value = res.data?.tickets ?? [];
hasMore.value = res.data?.tickets?.length === 50;
});
</script>
<template>
<div>
<h1>Tickets</h1>
<div class="ticket-container">
<div v-for="ticket in tickets" :key="ticket.id" class="ticket">
<div class="ticket-header">
<span class="ticket-header__id">#{{ ticket.localId }}</span>
<span class="ticket-header__status">{{ ticket.status }}</span>
<span class="ticket-header__time"><TimeAgo :time="ticket.openedAt"></TimeAgo></span>
</div>
<div class="ticket-body details">
<div class="keypair">
<span class="key">Opened by</span>
<span class="value">
<UserChip :user="ticket.subjects.subject" />
</span>
</div>
<div class="keypair">
<span class="key">Closed by</span>
<span class="value">
<UserChip v-if="ticket.subjects.closedBy" :user="ticket.subjects.closedBy" />
<span v-else>/</span>
</span>
</div>
</div>
<div class="ticket-footer">
<RouterLink class="link" :to="`./tickets/${ticket.localId}`">View Ticket</RouterLink>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.ticket-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
gap: 0.5rem;
}
.ticket {
display: flex;
flex-direction: column;
background-color: hsla(var(--crust) / 1);
border-radius: 0.5rem;
overflow: hidden;
.ticket-header,
.ticket-body,
.ticket-footer {
padding: 0.5rem 0.5rem;
}
.ticket-header {
display: flex;
align-items: center;
gap: 1ch;
line-height: 1;
background-color: hsla(var(--base) / 1);
.ticket-header__id {
font-weight: bold;
}
.ticket-header__status {
font-weight: bold;
color: hsl(var(--subtext0));
}
.ticket-header__time {
color: hsl(var(--subtext0));
}
}
}
.details {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
align-items: center;
row-gap: 0.5ch;
column-gap: 1ch;
padding: 0.5rem;
.keypair {
display: contents;
.key {
font-weight: bolder;
color: hsl(var(--subtext0));
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.value {
color: hsl(var(--subtext1));
font-weight: bold;
overflow: hidden;
}
}
}
.ticket-footer {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 1ch;
line-height: 1;
.link {
color: hsl(var(--subtext1));
font-weight: bold;
background-color: hsla(var(--surface0) / 0.75);
padding: 0.5rem;
border-radius: 0.5rem;
text-decoration: none;
&:hover {
background-color: hsla(var(--surface1) / 0.6);
}
&:active {
background-color: hsla(var(--surface0) / 1);
}
}
}
</style>
|