Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff8c124

Browse filesBrowse files
committed
fix(types) fixing types
1 parent eca12c4 commit ff8c124
Copy full SHA for ff8c124

File tree

Expand file treeCollapse file tree

6 files changed

+40
-49
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+40
-49
lines changed

‎components/content/ProseCode.vue

Copy file name to clipboardExpand all lines: components/content/ProseCode.vue
+10-20Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,42 @@
44
<span v-if="filename" class="filename-text mt-2">
55
{{ filename }}
66
</span>
7-
87
<div class="flex justify-end mr-5">
9-
<button @click="copy(code) && copyFeedback()" class="w-6 h-6 text-white mb-2">
8+
<button @click="copy(code).then(() => copyFeedback())" class="w-6 h-6 text-white mb-2">
109
<svg v-if="!hasCopied" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
1110
stroke="currentColor" class="">
1211
<path stroke-linecap="round" stroke-linejoin="round"
1312
d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75" />
1413
</svg>
1514
</button>
1615
<div class="text-white flex justify-end" v-if="hasCopied">
17-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
18-
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z" />
16+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
17+
stroke="currentColor" class="w-6 h-6">
18+
<path stroke-linecap="round" stroke-linejoin="round"
19+
d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z" />
1920
</svg>
20-
21-
2221
</div>
2322
</div>
24-
2523
<slot />
26-
2724
<div class="mt-10"></div>
2825
</div>
29-
3026
</div>
3127
</template>
3228

3329
<script setup lang="ts">
34-
import { useClipboard, usePermission } from '@vueuse/core';
30+
import { useClipboard } from '@vueuse/core';
3531
import { ref } from 'vue'
3632
37-
const input = ref('')
38-
const { text, isSupported, copy } = useClipboard()
39-
const permissionRead = usePermission('clipboard-read')
40-
const permissionWrite = usePermission('clipboard-write')
41-
33+
const {copy} = useClipboard()
4234
4335
const props = withDefaults(
4436
defineProps<{
4537
code?: string;
4638
language?: string | null;
4739
filename?: string | null;
48-
highlights?: Array<number>;
40+
highlights: Array<number> | never[];
4941
}>(),
50-
{ code: '', language: null, filename: null, highlights: [] }
42+
{ code: '', language: null, filename: null, highlights: undefined }
5143
);
5244
5345
const languageMap: Record<
@@ -97,9 +89,7 @@ function copyFeedback() {
9789
border-radius: 0.5rem;
9890
}
9991
100-
@media (max-width: 640px) {
101-
102-
}
92+
@media (max-width: 640px) {}
10393
10494
.filename-text {
10595
position: absolute;

‎components/elements/AnswerForm.vue

Copy file name to clipboardExpand all lines: components/elements/AnswerForm.vue
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script setup lang="ts">
22
33
const props = defineProps(['questionId'])
4-
const emit = defineEmits<{(e: 'addAnswer', answer: IAnswer)}>()
4+
5+
const addAnswer = 'addAnswer';
6+
const emit = defineEmits<{(e: typeof addAnswer, answer: IAnswer): void}>()
57
68
const questionId = props.questionId
79
@@ -10,7 +12,6 @@ const data: IAnswerPost = reactive({
1012
questionId: parseInt(questionId)
1113
})
1214
13-
1415
const showAnswerForm = useState('showAnswerForm' + questionId)
1516
1617
async function postAnswer() {

‎components/elements/TopicCard.vue

Copy file name to clipboardExpand all lines: components/elements/TopicCard.vue
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ defineProps({
99
</script>
1010

1111
<template>
12-
<nuxt-link :to="topic.url">
12+
<nuxt-link v-if="topic" :to="topic.url">
1313
<div class="flex justify-center pb-12 mb-10 min-h-content mr-5" :class="{
1414
'hover:border-green-700 hover:dark:border-green-700': topic.accentColor == 'green',
1515
'hover:border-red-700 hover:dark:border-red-700': topic.accentColor == 'red',
1616
'hover:border-indigo-700 hover:dark:border-indigo-700': topic.accentColor == 'indigo'
1717
}">
18-
<img class="h-16 md:h-96" :src="topic.image" v-if="topic.image !== '/img/nuxt3.svg'" alt="nuxt 3 logo">
18+
<img class="h-16 md:h-96" :src="topic.image ?? ''" v-if="topic.image !== '/img/nuxt3.svg'" alt="nuxt 3 logo">
1919
<svg v-if="topic.image == '/img/nuxt3.svg'" viewBox="0 0 221 65" fill="none" xmlns="http://www.w3.org/2000/svg"
2020
class="h-26 md:h-96 mr-5">
2121
<g clip-path="url(#a)">

‎composables/useAuth.ts

Copy file name to clipboardExpand all lines: composables/useAuth.ts
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { useRouter, useState } from "#app";
22
import { ISession } from "~~/types/ISession";
33
import { IUser } from "~/types/IUser";
4-
import consolaGlobalInstance from "consola";
54

65
export const useAuthCookie = () => useCookie('auth_token')
76

8-
export async function useUser(): Promise<IUser|null> {
7+
export async function useUser(): Promise<IUser | null> {
98
const authCookie = useAuthCookie().value
10-
const user = useState<IUser|null>('user')
9+
const user = useState<IUser | null>('user')
1110

1211
if (authCookie && !user.value) {
1312

@@ -48,7 +47,7 @@ export async function registerWithEmail(
4847
name: string,
4948
email: string,
5049
password: string
51-
): Promise<FormValidation|undefined> {
50+
): Promise<FormValidation | undefined> {
5251

5352
try {
5453
const { data, error } = await useFetch<ISession>('/api/auth/register', {
@@ -82,14 +81,14 @@ export async function registerWithEmail(
8281

8382
export async function loginWithEmail(usernameOrEmail: string, password: string): Promise<boolean> {
8483

85-
try{
84+
try {
8685
const user = await $fetch<IUser>('/api/auth/login', { method: 'POST', body: { usernameOrEmail: usernameOrEmail, password: password } })
8786
console.log(user)
8887
useState('user').value = user
8988
await useRouter().push('/topics')
9089
return true
91-
} catch(e) {
92-
return false
90+
} catch (e) {
91+
return false
9392
}
94-
93+
9594
}

‎pages/login.vue

Copy file name to clipboardExpand all lines: pages/login.vue
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
22
import { ref } from "@vue/reactivity";
33
import { loginWithEmail } from "~/composables/useAuth";
4+
import type {Ref} from "vue"
45
5-
const usernameOrEmail = ref(null)
6-
const password = ref(null)
7-
const hasError = ref(null)
8-
const errorMessage = ref(null)
9-
6+
const usernameOrEmail = ref('')
7+
const password = ref('')
8+
const hasError: Ref<boolean|null> = ref(null)
9+
const errorMessage: Ref<string|null> = ref(null)
1010
1111
definePageMeta({
1212
middleware: 'guest'

‎pages/register.vue

Copy file name to clipboardExpand all lines: pages/register.vue
+13-12Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<script setup lang="ts">
22
import { ref } from "@vue/reactivity";
33
import { registerWithEmail } from "~/composables/useAuth";
4+
import type {Ref} from "vue"
45
5-
const email = ref(null);
6-
const password = ref(null);
7-
const username = ref(null);
8-
const name = ref(null);
9-
const errors = ref(new Map())
10-
let response = ref<FormValidation>({ hasErrors: false })
6+
const email: Ref<string> = ref('');
7+
const password: Ref<string> = ref('');
8+
const username: Ref<string> = ref('');
9+
const name: Ref<string> = ref('');
10+
const errors: Ref<Map<string, { check: InputValidation; }> | undefined> = ref(new Map<string, { check: InputValidation }>())
11+
let response: Ref<FormValidation|undefined> = ref({ hasErrors: false })
1112
1213
async function postRegisterForm() {
1314
response.value = await registerWithEmail(username.value, name.value, email.value, password.value);
14-
errors.value = response.value.errors
15+
errors.value = response?.value?.errors
1516
};
1617
1718
</script>
@@ -31,7 +32,7 @@ async function postRegisterForm() {
3132
Sign Up
3233
</h2>
3334
</div>
34-
<div v-if="response.hasErrors && errors"
35+
<div v-if="response?.hasErrors && errors"
3536
class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mt-3" role="alert">
3637
<strong class="font-bold">Oops, try again! </strong>
3738

@@ -50,15 +51,15 @@ async function postRegisterForm() {
5051
<label for="name" class="sr-only">Name</label>
5152
<input v-model="name" id="name" name="name" required
5253
class="appearance-none dark:bg-slate-500 dark:text-white dark:placeholder-white rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
53-
:class="errors.has('name') ? ' border-red-500' : ''" placeholder="Name" />
54+
:class="errors?.has('name') ? ' border-red-500' : ''" placeholder="Name" />
5455
</div>
5556
</div>
5657
<div class="rounded-md shadow-sm -space-y-px mb-1">
5758
<div>
5859
<label for="email-address" class="sr-only">Username</label>
5960
<input type="email" v-model="username" id="username" name="username" required
6061
class="dark:bg-slate-500 dark:text-white dark:placeholder-white appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
61-
:class="errors.has('username') ? ' border-red-500' : ''" placeholder="username" />
62+
:class="errors?.has('username') ? ' border-red-500' : ''" placeholder="username" />
6263
</div>
6364
</div>
6465

@@ -67,15 +68,15 @@ async function postRegisterForm() {
6768
<label for="email-address" class="sr-only">Email address</label>
6869
<input v-model="email" id="email-address" name="email" type="email" autocomplete="email" required
6970
class="dark:bg-slate-500 dark:text-white dark:placeholder-white appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
70-
:class="errors.has('email') ? ' border-red-500' : ''" placeholder="Email address" />
71+
:class="errors?.has('email') ? ' border-red-500' : ''" placeholder="Email address" />
7172
</div>
7273
</div>
7374
<div>
7475
<label for="password" class="sr-only">Password</label>
7576
<input v-model="password" id="password" name="password" type="password" autocomplete="current-password"
7677
required
7778
class="dark:bg-slate-500 dark:text-white dark:placeholder-white appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
78-
:class="errors.has('password') ? ' border-red-500' : ''" placeholder="Password" />
79+
:class="errors?.has('password') ? ' border-red-500' : ''" placeholder="Password" />
7980
</div>
8081

8182
<div class="flex items-center justify-between">

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.