This commit is contained in:
taskylizard 2023-11-06 11:15:08 +05:30
parent 3a71e8f164
commit 7213a1f4af
No known key found for this signature in database
GPG Key ID: 5CABA3D642DDC497
5 changed files with 26 additions and 5 deletions

View File

@ -0,0 +1,6 @@
import { corsEventHandler } from "nitro-cors";
export default corsEventHandler((_event) => { }, {
origin: "*",
methods: "*",
});

View File

@ -47,5 +47,5 @@ export default defineEventHandler(async (event) => {
throw new Error(error);
});
return "success";
return { status: "success" };
});

View File

@ -42,12 +42,11 @@ async function handleSubmit(type?: string) {
contactEmail: feedback.contactEmail,
};
// TODO: fix this horror?
try {
const response = await fetch("https://feedback.tasky.workers.dev", {
method: "POST",
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST",
"Content-Type": "application/json",
},
body: JSON.stringify(body),
@ -59,7 +58,9 @@ async function handleSubmit(type?: string) {
error.value = data.error;
return;
}
success.value = true;
if (data.status === "success") {
success.value = true;
}
} catch (err) {
error.value = err;
} finally {
@ -103,7 +104,10 @@ async function handleSubmit(type?: string) {
<textarea v-model="feedback.message" autofocus class="input" />
<p class="desc">Contacts, so we can get back to you. (Optional)</p>
<textarea v-model="feedback.contactEmail" class="contact-input" />
<button class="btn btn-primary" :disabled="!feedback.message" @click="handleSubmit()">
<button
class="btn btn-primary"
:disabled="feedback.message.length > 10"
@click="handleSubmit()">
Submit
</button>
</div>

View File

@ -16,6 +16,7 @@
"dependencies": {
"fast-glob": "^3.3.1",
"itty-fetcher": "^0.9.4",
"nitro-cors": "^0.7.0",
"nitropack": "latest",
"pathe": "^1.1.1",
"unocss": "^0.57.1",

View File

@ -16,6 +16,9 @@ dependencies:
itty-fetcher:
specifier: ^0.9.4
version: 0.9.4
nitro-cors:
specifier: ^0.7.0
version: 0.7.0
nitropack:
specifier: latest
version: 2.7.2
@ -4468,6 +4471,13 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
/nitro-cors@0.7.0:
resolution: {integrity: sha512-Mbb26M7TCKZxt8mOw5V9mVj4gCCv+/+LOy1QUUlk+HcMFn5CD4/irwg8IsoDg7NA+c441A0joC4n+mVFCNhu5g==}
dependencies:
h3: 1.8.2
ufo: 1.3.1
dev: false
/nitropack@2.7.2:
resolution: {integrity: sha512-6vQbGdBNR20N8wTChzIQUZQmNVhWVDrjUdpOYD68u2hlyUiJembth2fQuoWw3KlsoNYWFvcyqL9X3DPjjnoEUQ==}
engines: {node: ^16.11.0 || >=17.0.0}