remove contacts field

This commit is contained in:
taskylizard 2023-11-19 21:35:33 +00:00
parent bf3dae2258
commit a14f3966c7
3 changed files with 12 additions and 25 deletions

View File

@ -2,14 +2,10 @@ import { fetcher } from "itty-fetcher";
import { FeedbackSchema, getFeedbackOption } from "../types/Feedback"; import { FeedbackSchema, getFeedbackOption } from "../types/Feedback";
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {
const { message, page, contact, type } = await readValidatedBody( const { message, page, type } = await readValidatedBody(event, FeedbackSchema.parseAsync);
event,
FeedbackSchema.parseAsync,
);
const env = useRuntimeConfig(event); const env = useRuntimeConfig(event);
let description = `${message}\n\n`; let description = `${message}\n\n`;
if (contact) description += `**Contact:** ${contact}`;
if (page) description += `**Page:** \`${page}\``; if (page) description += `**Page:** \`${page}\``;
await fetcher() await fetcher()

View File

@ -9,7 +9,7 @@ const success = ref<boolean>(false);
const router = useRouter(); const router = useRouter();
const feedback = reactive<FeedbackType>({ message: "", contact: "" }); const feedback = reactive<FeedbackType>({ message: "" });
async function handleSubmit(type?: FeedbackType["type"]) { async function handleSubmit(type?: FeedbackType["type"]) {
if (type) feedback.type = type; if (type) feedback.type = type;
@ -18,7 +18,6 @@ async function handleSubmit(type?: FeedbackType["type"]) {
const body: FeedbackType = { const body: FeedbackType = {
message: feedback.message, message: feedback.message,
type: feedback.type, type: feedback.type,
contact: feedback.contact,
page: router.route.path, page: router.route.path,
}; };
@ -58,10 +57,7 @@ async function handleSubmit(type?: FeedbackType["type"]) {
</div> </div>
</div> </div>
<div class="button-container"> <div class="button-container">
<button <button v-for="item in feedbackOptions" :key="item.value" class="btn"
v-for="item in feedbackOptions"
:key="item.value"
class="btn"
@click="handleSubmit(item.value as FeedbackType['type'])"> @click="handleSubmit(item.value as FeedbackType['type'])">
<span>{{ item.label }}</span> <span>{{ item.label }}</span>
</button> </button>
@ -77,18 +73,14 @@ async function handleSubmit(type?: FeedbackType["type"]) {
</button> </button>
</div> </div>
</div> </div>
<textarea v-model="feedback.message" autofocus class="input" /> <textarea v-model="feedback.message" autofocus class="input" placeholder="What a lovely wiki!" />
<p class="desc">Contacts, so we can get back to you. (Optional)</p> <p class="desc mb-2">
<textarea v-model="feedback.contact" class="contact-input" /> Join our
<button <a class="text-primary font-semibold text-underline" href="https://discord.gg/Stz6y6NgNg">Discord</a>
type="submit" if you'd like a response to your feedback.
class="btn btn-primary" </p>
:disabled=" <button type="submit" class="btn btn-primary"
feedback.message.length < 5 || :disabled="feedback.message.length < 5 || feedback.message.length > 1000" @click="handleSubmit()">
feedback.message.length > 1000 ||
feedback.contact.length > 100
"
@click="handleSubmit()">
Submit Submit
</button> </button>
</div> </div>

View File

@ -3,7 +3,6 @@ import z from "zod";
export const FeedbackSchema = z.object({ export const FeedbackSchema = z.object({
message: z.string().min(5).max(1000), message: z.string().min(5).max(1000),
type: z.enum(["bug", "suggestion", "appreciate", "other"]), type: z.enum(["bug", "suggestion", "appreciate", "other"]),
contact: z.string().optional(),
page: z.string().optional(), page: z.string().optional(),
}); });