Fixes: 1) Correct file path imports by removing `.js` extensions in GraphQL fragments; 2) Resolve typo in `usePromocodeStore` composables to ensure consistent store usage; 3) Add missing `:type="submit"` to login form button for proper form submission handling; Extra: 1) Remove unused `.idea` and `README.md` files for repository cleanup; 2) Delete extraneous dependencies from `package-lock.json` for streamlined package management; 3) Refactor category slug handling with improved composable logic for cleaner route parameters and SEO alignment.
141 lines
No EOL
3.2 KiB
Vue
141 lines
No EOL
3.2 KiB
Vue
<template>
|
|
<div class="promocodes">
|
|
<h2>{{ t('profile.promocodes.title') }}</h2>
|
|
<div class="promocodes__list" v-if="promocodes?.length">
|
|
<div
|
|
class="promocodes__item"
|
|
v-for="promocode in promocodes"
|
|
:key="promocode.node.uuid"
|
|
>
|
|
<div class="promocodes__item-left">
|
|
<icon
|
|
name="material-symbols:content-copy"
|
|
size="20"
|
|
class="promocodes__item-button"
|
|
@click="copyCode(promocode.node.code)"
|
|
/>
|
|
<p>{{ promocode.node.code }}</p>
|
|
</div>
|
|
<div class="promocodes__item-right">
|
|
<p class="promocodes__item-text">{{ promocode.node.discount }} {{ promocode.node.discountType === 'percent' ? '%' : CURRENCY }}</p>
|
|
<div class="promocodes__item-expire">
|
|
{{ t('profile.promocodes.until') }}
|
|
{{
|
|
useDate(promocode.node.endTime, locale, {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit'
|
|
})
|
|
}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<p class="promocodes__empty" v-else>{{ t('profile.promocodes.empty') }}</p>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {usePageTitle} from "~/composables/utils";
|
|
import {useNotification} from "~/composables/notification/index.js";
|
|
import {CURRENCY} from "~/config/constants";
|
|
import {useDate} from "~/composables/date";
|
|
|
|
const {t, locale} = useI18n();
|
|
const promocodeStore = usePromocodeStore();
|
|
|
|
const promocodes = computed(() => promocodeStore.promocodes);
|
|
|
|
const copyCode = (code: string) => {
|
|
navigator.clipboard.writeText(code)
|
|
.then(() => {
|
|
useNotification({
|
|
message: t('popup.success.promocodeCopy'),
|
|
type: 'success'
|
|
});
|
|
})
|
|
.catch(err => {
|
|
console.error(err);
|
|
});
|
|
};
|
|
|
|
const { setPageTitle } = usePageTitle();
|
|
|
|
setPageTitle(t('breadcrumbs.promocodes'));
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.promocodes {
|
|
background-color: $white;
|
|
width: 100%;
|
|
box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.2);
|
|
padding: 20px;
|
|
border-radius: $default_border_radius;
|
|
height: fit-content;
|
|
|
|
&__list {
|
|
margin-top: 50px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
}
|
|
|
|
&__item {
|
|
border-radius: $default_border_radius;
|
|
border: 2px solid $accent;
|
|
display: flex;
|
|
align-items: stretch;
|
|
justify-content: space-between;
|
|
|
|
&-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20px;
|
|
padding: 7px 15px;
|
|
|
|
& p {
|
|
font-weight: 600;
|
|
}
|
|
}
|
|
|
|
&-button {
|
|
cursor: pointer;
|
|
transition: 0.2s;
|
|
color: $accentDark;
|
|
|
|
@include hover {
|
|
color: $accent;
|
|
}
|
|
}
|
|
|
|
&-right {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20px;
|
|
}
|
|
|
|
&-text {
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
}
|
|
|
|
&-expire {
|
|
height: 100%;
|
|
background-color: $accent;
|
|
padding-inline: 15px;
|
|
display: grid;
|
|
place-items: center;
|
|
|
|
color: $white;
|
|
}
|
|
}
|
|
|
|
&__empty {
|
|
margin-top: 50px;
|
|
font-weight: 600;
|
|
}
|
|
}
|
|
</style> |