more linting

This commit is contained in:
taskylizard 2023-11-19 14:27:14 +05:30
parent 84337b7b1d
commit ae179550bf
No known key found for this signature in database
GPG Key ID: 5CABA3D642DDC497
7 changed files with 38 additions and 41 deletions

View File

@ -14,8 +14,8 @@ const feedbackOptions = [
},
];
function getFeedbackOption(value: string) {
return feedbackOptions.find((option) => option.value === value);
function getFeedbackOption(value: string): string {
return feedbackOptions.find((option) => option.value === value).label;
}
export default defineEventHandler(async (event) => {
@ -36,7 +36,7 @@ export default defineEventHandler(async (event) => {
embeds: [
{
color: 3447003,
title: getFeedbackOption(type).label,
title: getFeedbackOption(type),
description,
},
],

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { reactive, ref } from "vue";
import { useRoute } from "vitepress";
import type { FeedbackType } from "../../types/Feedback";
import { type FeedbackType, getFeedbackOption, feedbackOptions } from "../../types/Feedback";
const loading = ref<boolean>(false);
const error = ref<unknown>(null);
@ -10,23 +10,6 @@ const { path } = useRoute();
const feedback = reactive<FeedbackType>({ message: "", contact: "" });
const feedbackOptions = [
{ label: "🐞 Bug", value: "bug" },
{
label: "💡 Suggestion",
value: "suggestion",
},
{ label: "📂 Other", value: "other" },
{
label: "❤️ Appreciation",
value: "appreciate",
},
];
function getFeedbackOption(value: string) {
return feedbackOptions.find((option) => option.value === value);
}
async function handleSubmit(type?: FeedbackType["type"]) {
if (type) feedback.type = type;
loading.value = true;
@ -53,7 +36,7 @@ async function handleSubmit(type?: FeedbackType["type"]) {
error.value = data.error;
return;
}
if (data.status === "success") {
if (data.status === "ok") {
success.value = true;
}
} catch (error_) {
@ -99,7 +82,7 @@ async function handleSubmit(type?: FeedbackType["type"]) {
<button
type="submit"
class="btn btn-primary"
:disabled="feedback.message.length > 1000"
:disabled="feedback.message.length > 1000 || feedback.contact.length > 100"
@click="handleSubmit()">
Submit
</button>

View File

@ -10,11 +10,10 @@ import {
} from "@headlessui/vue";
const isOpen = ref(true);
interface ILogger {}
const feedbackOptions = [
{
label: "♻️ Suggestion",
label: "💡 Suggestion",
value: "suggestion",
},
{
@ -37,8 +36,7 @@ function openModal() {
<button
type="button"
class="p-[4px 8px] text-xl i-carbon:user-favorite-alt-filled"
@click="openModal"
/>
@click="openModal" />
<TransitionRoot appear :show="isOpen" as="template">
<Dialog as="div" class="relative z-10" @close="closeModal">
@ -62,8 +60,7 @@ function openModal() {
enter-to="opacity-100 scale-100"
leave="duration-200 ease-in"
leave-from="opacity-100 scale-100"
leave-to="opacity-0 scale-95"
>
leave-to="opacity-0 scale-95">
<DialogPanel
class="w-full max-w-md transform overflow-hidden rounded-2xl bg-bg p-6 text-left align-middle shadow-xl transition-all">
<DialogTitle as="h3" class="text-lg font-medium leading-6 text-text">
@ -75,8 +72,7 @@ function openModal() {
<button
v-for="item in feedbackOptions"
:key="item.value"
class="inline-flex justify-center rounded-md border border-transparent bg-bg-alt px-4 py-2 text-sm font-medium text-text hover:border-primary focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2"
>
class="inline-flex justify-center rounded-md border border-transparent bg-bg-alt px-4 py-2 text-sm font-medium text-text hover:border-primary focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2">
<span>{{ item.label }}</span>
</button>
</div>
@ -84,9 +80,9 @@ function openModal() {
<div class="mt-2">
<div>
<label for="feedback-input-text" class="field-label">Feedback*</label>
<label class="field-label">Feedback*</label>
<textarea id="feedback-input-text" placeholder="meow" rows="5" />
<textarea placeholder="meow" rows="5" />
</div>
</div>
@ -94,8 +90,7 @@ function openModal() {
<button
type="button"
class="inline-flex justify-center rounded-md border border-transparent bg-blue-100 px-4 py-2 text-sm font-medium text-blue-900 hover:bg-blue-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"
@click="closeModal"
>
@click="closeModal">
Close
</button>
</div>

View File

@ -7,4 +7,21 @@ export const FeedbackSchema = z.object({
page: z.string().min(3).max(10),
});
export const feedbackOptions = [
{ label: "🐞 Bug", value: "bug" },
{
label: "💡 Suggestion",
value: "suggestion",
},
{ label: "📂 Other", value: "other" },
{
label: "❤️ Appreciation",
value: "appreciate",
},
];
export function getFeedbackOption(value: string): { label: string; value: string } {
return feedbackOptions.find((option) => option.value === value);
}
export type FeedbackType = z.infer<typeof FeedbackSchema>;

View File

@ -1,4 +1,6 @@
import { type Component } from "vue";
declare module "*.vue" {
const component: import("vue").Component;
const component: Component;
export default component;
}

View File

@ -32,7 +32,7 @@
"devDependencies": {
"@iconify-json/carbon": "^1.1.21",
"@iconify-json/twemoji": "^1.1.12",
"@taskylizard/eslint-config": "^1.0.3",
"@taskylizard/eslint-config": "^1.0.5",
"@types/node": "^20.8.9",
"@types/nprogress": "^0.2.3",
"eslint": "^8.53.0",

8
pnpm-lock.yaml generated
View File

@ -55,8 +55,8 @@ devDependencies:
specifier: ^1.1.12
version: 1.1.12
'@taskylizard/eslint-config':
specifier: ^1.0.3
version: 1.0.3(eslint-plugin-import@2.29.0)(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2)
specifier: ^1.0.5
version: 1.0.5(eslint-plugin-import@2.29.0)(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2)
'@types/node':
specifier: ^20.8.9
version: 20.8.9
@ -1543,8 +1543,8 @@ packages:
string.prototype.codepointat: 0.2.1
dev: false
/@taskylizard/eslint-config@1.0.3(eslint-plugin-import@2.29.0)(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2):
resolution: {integrity: sha512-++eQftOq60qClRh/O8Pqrj/c0TOJkBUc62iiB5aDrsxjKu7EdndZCBJpr1C+RlLGQuosyE96G4Tag3uAZEJ8ZA==}
/@taskylizard/eslint-config@1.0.5(eslint-plugin-import@2.29.0)(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2):
resolution: {integrity: sha512-kz3zxNPMnm7S/j7SzHbyJmZXVj1fa6STzuigQjNl1njcpuA+1ygsa1Zvn711y0wkIGik/yLiP+BTG+likBRAZA==}
peerDependencies:
eslint: '>=8.0.0'
prettier: '>=3.0.0 <4'