This commit is contained in:
2021-07-21 13:16:22 +02:00
parent a574d1c9e5
commit 055a961fce
7 changed files with 334 additions and 316 deletions

View File

@@ -36,7 +36,7 @@ const ssr = true
const proxy = { const proxy = {
'/api': { '/api': {
target: "https://api.arthurdanjou.fr", target: 'https://api.arthurdanjou.fr',
pathRewrite: { "^/api": "" } pathRewrite: { "^/api": "" }
} }
} }

View File

@@ -1,5 +1,4 @@
const publicRuntimeConfig = { const publicRuntimeConfig = {
} }
const privateRuntimeConfig = { const privateRuntimeConfig = {

View File

@@ -2,7 +2,7 @@
<section class="p-6 border border-indigo-600 dark:border-indigo-700 rounded-lg text-justify"> <section class="p-6 border border-indigo-600 dark:border-indigo-700 rounded-lg text-justify">
<h1 class="text-black font-bold dark:text-white text-2xl">{{ $t('guestbook.signin') }}</h1> <h1 class="text-black font-bold dark:text-white text-2xl">{{ $t('guestbook.signin') }}</h1>
<h3 class="text-gray-500 dark:text-gray-400">{{ $t('guestbook.share') }}</h3> <h3 class="text-gray-500 dark:text-gray-400">{{ $t('guestbook.share') }}</h3>
<div v-if="!success && !error" class="flex space-x-4 my-3"> <div v-if="!loginRef" class="flex space-x-4 my-3">
<div @click="login('google')" class="icon-parent flex justify-center items-center p-2 border border-black dark:border-white duration-300 cursor-pointer"> <div @click="login('google')" class="icon-parent flex justify-center items-center p-2 border border-black dark:border-white duration-300 cursor-pointer">
<GoogleIcon /> <GoogleIcon />
</div> </div>
@@ -14,7 +14,7 @@
</div> </div>
</div> </div>
<div v-else class="my-3"> <div v-else class="my-3">
<form v-if="!success" class="relative"> <form class="relative">
<input <input
required required
type="text" type="text"
@@ -41,7 +41,7 @@
</div> </div>
</div> </div>
</div> </div>
<p class="text-sm text-gray-700 dark:text-gray-300">{{ $t('guestbook.infos') }}</p> <p class="text-sm text-gray-400 dark:text-gray-600">{{ $t('guestbook.infos') }}</p>
</section> </section>
</template> </template>
@@ -54,9 +54,18 @@ export default defineComponent({
setup() { setup() {
const { $axios, $sentry, app } = useContext() const { $axios, $sentry, app } = useContext()
const loginRef = ref(false)
const login = async (driver: 'github' | 'google' | 'twitter') => { const login = async (driver: 'github' | 'google' | 'twitter') => {
const response = await $axios.get(`/api/auth/${driver}`) const response = await $axios.get(`/api/auth/${driver}`, {
headers: {
'Access-Control-Allow-Origin': 'https://arthurdanjou.fr',
'Accept': '*/*',
'Origin': 'https://arthurdanjou.fr',
'host': 'https://arthurdanjou.fr'
}
})
if (response.status === 200) { if (response.status === 200) {
loginRef.value = true
await hasAlreadySignMessage(response.data.user.id) await hasAlreadySignMessage(response.data.user.id)
} else { } else {
$sentry.captureEvent(response.data) $sentry.captureEvent(response.data)
@@ -70,7 +79,8 @@ export default defineComponent({
const handleForm = async () => { const handleForm = async () => {
const response = await $axios.post('/api/guestbook', { const response = await $axios.post('/api/guestbook', {
message: form.value.message message: form.value.message,
email: 'contact@arthurdanjou.fr'
}, { }, {
headers: { headers: {
'Authorization': `Bearer ${process.env.API_TOKEN}` 'Authorization': `Bearer ${process.env.API_TOKEN}`
@@ -96,7 +106,7 @@ export default defineComponent({
} }
}) })
if (response.status === 200) { if (response.status === 200) {
switch (response.data.data) { switch (response.data.signed) {
case 0: case 0:
alreadySent.value = false alreadySent.value = false
break break
@@ -115,6 +125,7 @@ export default defineComponent({
success, success,
error, error,
alreadySent, alreadySent,
loginRef,
handleForm, handleForm,
hasAlreadySignMessage hasAlreadySignMessage
} }

View File

@@ -1,14 +1,14 @@
<template> <template>
<div class="my-6"> <div class="my-6">
<div class="text-justify leading-6"> <div class="text-justify leading-6 text-black dark:text-white">
{{ message }} {{ message }}
</div> </div>
<div class="flex mt-3"> <div class="flex mt-3">
<div class="text-gray-600"> <div class="text-gray-600 dark:text-gray-300">
{{ author }} {{ author }}
</div> </div>
<div class="text-gray-200 px-3">/</div> <div class="text-gray-200 px-3 dark:text-gray-700">/</div>
<div class="text-gray-400 lining-nums"> <div class="text-gray-400 dark:text-gray-500 lining-nums">
{{ formatDateAndTime }} {{ formatDateAndTime }}
</div> </div>
</div> </div>

View File

@@ -2,11 +2,11 @@
<main class="error w-full px-5 xl:px-64"> <main class="error w-full px-5 xl:px-64">
<div class="mt-24 w-full h-full flex items-center justify-center"> <div class="mt-24 w-full h-full flex items-center justify-center">
<div class="flex flex-col items-center md:mb-20"> <div class="flex flex-col items-center md:mb-20">
<div class="flex"> <div class="flex items-center">
<div class="h-16 w-16 mr-4"> <div class="h-16 w-16 mr-4">
<ErrorIcon class="w-full h-full"/> <ErrorIcon class="w-full h-full"/>
</div> </div>
<div class="mb-12 lining-nums"> <div class="lining-nums">
<div class="mb-2"> <div class="mb-2">
<p v-if="error.statusCode === 404" class="text-3xl md:text-6xl dark:text-white font-bold"> <p v-if="error.statusCode === 404" class="text-3xl md:text-6xl dark:text-white font-bold">
{{ $t('error.error').toUpperCase() }} 404 {{ $t('error.error').toUpperCase() }} 404
@@ -25,7 +25,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="mb-4 w-full text-center"> <div class="mt-12 mb-4 w-full text-center">
<div class="home-btn" @click="next"> <div class="home-btn" @click="next">
<div class="cursor-pointer w-full py-4 px-4 md:py-4 md:px-4 font-bold hover:(bg-indigo-600 text-white) duration-500 rounded"> <div class="cursor-pointer w-full py-4 px-4 md:py-4 md:px-4 font-bold hover:(bg-indigo-600 text-white) duration-500 rounded">
<BackSpaceIcon class="arrow-img text-xl"/> <BackSpaceIcon class="arrow-img text-xl"/>

View File

@@ -64,7 +64,7 @@ export default defineComponent({
const subscribersCount = ref(0) const subscribersCount = ref(0)
useAsync(() => { useAsync(() => {
$axios.get('/subscribers', { $axios.get('/api/subscribers', {
headers: { headers: {
'Authorization': `Bearer ${process.env.API_TOKEN}`, 'Authorization': `Bearer ${process.env.API_TOKEN}`,
} }
@@ -84,7 +84,7 @@ export default defineComponent({
const form = ref<NewsletterForm>({} as NewsletterForm) const form = ref<NewsletterForm>({} as NewsletterForm)
const handleForm = () => { const handleForm = () => {
$axios.post('/subscribers', { $axios.post('/api/subscribers', {
email: form.value.email email: form.value.email
}, { }, {
headers: { headers: {

606
yarn.lock

File diff suppressed because it is too large Load Diff