Files
social-media/src/views/PayementCompleted.vue
2024-05-12 16:38:39 -04:00

112 lines
3.7 KiB
Vue

<template>
<body style="background-color: #f4f4f4;">
<DefaultLayout></DefaultLayout>
<v-container>
<div class="margin-top-mobile">
<v-row style="margin-top: 8%; margin-bottom: 2%" class="d-flex justify-center align-center">
<v-col cols="12" xxl="3" xl="4" lg="6" md="7" sm="9"> <v-card class="custom-dialog"
style="background-color: white;">
<v-container>
<!-- Title Card -->
<v-card-text style="font-weight: 600; margin-top: 25px; margin-bottom: 25px; font-size: 2.5rem;"
class="text-center">
Paiement complété
</v-card-text>
<v-text-field v-model="email" label="Email"></v-text-field>
<v-btn @click="getReceipt">Reçu</v-btn>
<v-row justify="center">
<!-- Icon Check -->
<v-col cols="12" class="text-center">
<v-icon color=#a30e79 size="250">mdi-check-circle</v-icon>
</v-col>
</v-row>
<!-- Informations -->
<v-row justify="center">
<v-col cols="12">
<v-card-text style="font-size: 1.2rem; text-align: center;">
Merci de supporter
</v-card-text>
<v-card-text style="font-weight: 600; font-size: 1.6rem; text-align: center;">
{{ creatorName }}
</v-card-text>
</v-col>
</v-row>
<!-- Ok btn -->
<v-row>
<v-col cols="12">
<v-card-actions class="justify-center">
<v-btn color="white" outlined elevation="2"
style="font-size: 2rem; width: 250px; height: 50px; margin-bottom: 25px; background-color: #a30e79;"
@click="router.push({ path: `/${creatorUserName}` })">Ok</v-btn>
</v-card-actions>
</v-col>
</v-row>
</v-container>
</v-card>
</v-col>
</v-row>
</div>
<v-snackbar v-model="errorSnackBar">
Aucun reçu trouvé pour ce email.
<template v-slot:actions>
<v-btn color="red" variant="text" @click="errorSnackBar = false">Fermer</v-btn>
</template>
</v-snackbar>
</v-container>
<FooterLayout></FooterLayout>
</body>
</template>
<script async setup>
import DefaultLayout from '@/layouts/DefaultLayout.vue';
import FooterLayout from '@/layouts/FooterLayout.vue';
import { useRouter } from 'vue-router';
import { useClient } from '@/plugins/api.js';
import {onBeforeMount, ref} from 'vue';
const router = useRouter()
const client = useClient();
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const creatorId = urlParams.get('creatorId')
const creatorName = ref("");
const creatorUserName = ref("");
const email = ref("");
const errorSnackBar = ref(false);
onBeforeMount(async () => {
const creatorResponse = await client.get(`/api/Users?UserId=${creatorId}`);
creatorName.value = creatorResponse.data.firstName + " " + creatorResponse.data.lastName;
creatorUserName.value = creatorResponse.data.userName;
})
async function getReceipt() {
const receiptResponse = await client.get(`/api/Stripe/GetMyLastReceipt?CreatorId=${creatorId}&Email=${email.value}`);
const receiptUrl = receiptResponse.data.receiptUrl;
if (receiptUrl === "") {
errorSnackBar.value = true;
return;
}
window.open(receiptUrl);
}
</script>
<style scoped>
@media (min-width: 200px) and (max-width: 960px) {
.margin-top-mobile {
margin-top: 60px;
}
}
</style>