1
0
Fork 0
activist/src/views/StickerView.vue

93 lines
2.2 KiB
Vue
Raw Normal View History

2024-11-16 23:04:02 -05:00
<script setup lang="ts">
2024-11-25 20:06:22 -05:00
import {computed, onBeforeMount, ref} from 'vue';
2024-12-02 19:35:53 -05:00
import { useRoute } from 'vue-router';
2024-11-16 23:04:02 -05:00
import Button from 'primevue/button';
2024-11-25 20:06:22 -05:00
import Panel from 'primevue/panel';
2024-12-02 19:35:53 -05:00
2024-11-25 20:06:22 -05:00
import Sticker from "@/components/Sticker.vue";
2024-12-02 19:35:53 -05:00
import { type User } from "@/stores/types";
import { useSessionStore } from "@/stores/sessionStore";
import {
type Sticker as StickerType,
useStickersStore
} from "@/stores/stickersStore";
2024-11-25 20:06:22 -05:00
2024-12-02 19:35:53 -05:00
const sessionStore = useSessionStore();
const stickersStore = useStickersStore();
2024-11-25 20:06:22 -05:00
const route = useRoute();
const uuid = ref<string>(route.params.uuid as string);
const { getSticker } = stickersStore;
let sticker = ref<StickerType>();
2024-11-25 20:06:22 -05:00
onBeforeMount(async () => {
await stickersStore.fetch(uuid.value);
sticker.value = getSticker(uuid.value);
2024-11-25 20:06:22 -05:00
});
const first = computed(() => {
const parts = uuid.value.split('-')
return [parts[0], parts[1], parts[2]].join('-');
})
const second = computed(() => {
const parts = uuid.value.split('-')
return [parts[3], parts[4]].join('-');
2024-11-17 15:01:11 -05:00
})
2024-11-16 23:04:02 -05:00
2024-11-26 11:30:20 -05:00
function claimSticker() {
stickersStore.setOwner(sticker.value, sessionStore.user as User);
2024-11-26 11:30:20 -05:00
}
2024-11-16 23:04:02 -05:00
</script>
<template>
2024-11-25 20:06:22 -05:00
<div class="profilePage">
<Panel>
<div class="flex flex-row content-end">
<div>
<div class="font-mono text-sn tracking-wider col">
{{ first }}
</div>
<div class="font-mono text-sn tracking-wider col">
{{ second }}
2024-11-16 23:04:02 -05:00
</div>
2024-11-25 20:06:22 -05:00
</div>
</div>
</Panel>
<Panel header="Sticker">
<div class="flex flex-col gap-5">
<div id="StickerWrapper">
<Sticker
class="sticker"
v-bind="sticker"
v-if="sticker"
2024-11-25 20:06:22 -05:00
/>
</div>
2024-11-26 11:30:20 -05:00
<Button
v-bind:disabled="sessionStore.isAnonymous"
v-if="sticker?.owner == null"
2024-11-26 11:30:20 -05:00
v-on:click="claimSticker">
2024-11-25 20:06:22 -05:00
This is my sticker!
</Button>
<span v-if="sessionStore.isAnonymous">
2024-12-04 09:10:13 -05:00
Log in to claim your sticker.
</span>
2024-11-25 20:06:22 -05:00
</div>
</Panel>
2024-11-16 23:04:02 -05:00
</div>
</template>
2024-11-26 08:51:46 -05:00
<style scoped>
#StickerWrapper {
background-color: #DDD;
padding: 12px;
@media (screen(sm)) {
.sticker {
zoom: 250%;
}
}
2024-11-26 08:51:46 -05:00
}
</style>