Skip to content

Commit 90acfbd

Browse files
committed
fixes: pages with additional TS changes
1 parent 81a0f75 commit 90acfbd

File tree

7 files changed

+42
-25
lines changed

7 files changed

+42
-25
lines changed

src/components/DeleteUserModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup lang="ts">
22
import { useTemplateRef } from 'vue';
33
import { useRouter } from 'vue-router';
4-
import Password from 'primevue/password';
54
import { useAuthStore } from '@/stores/auth';
65
import { useAxiosForm } from '@/composables/useAxiosForm';
76
import { useFlashMessage } from '@/composables/useFlashMessage.js';
7+
import Password from 'primevue/password';
88
import InputErrors from '@/components/InputErrors.vue';
99
1010
const modalOpen = defineModel<boolean>({ default: false });
@@ -13,7 +13,7 @@ const authStore = useAuthStore();
1313
const router = useRouter();
1414
const { setFlashMessage } = useFlashMessage();
1515
16-
type PasswordInputType = InstanceType<typeof Password>;
16+
type PasswordInputType = InstanceType<typeof Password> & { $el: HTMLElement };
1717
const passwordInput = useTemplateRef<PasswordInputType>('password-input');
1818
1919
const {
@@ -38,7 +38,7 @@ const deleteAccount = () => {
3838
console.error('error');
3939
if (passwordInput.value && passwordInput.value?.$el) {
4040
const passwordInputElement = passwordInput.value.$el.querySelector('input');
41-
passwordInputElement.focus();
41+
passwordInputElement?.focus();
4242
}
4343
},
4444
onFinish: () => resetFormFields(),

src/views/auth/ForgotPassword.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { useTemplateRef, computed, onMounted } from 'vue';
33
import { useAxiosForm } from '@/composables/useAxiosForm';
44
import { useAuthStore } from '@/stores/auth';
55
import { useFlashMessage } from '@/composables/useFlashMessage.js';
6+
import InputText from 'primevue/inputtext';
67
import GuestAuthLayout from '@/layouts/GuestAuthLayout.vue';
78
import InputErrors from '@/components/InputErrors.vue';
89
910
const authStore = useAuthStore();
1011
const { flashMessages, setFlashMessage } = useFlashMessage();
1112
12-
const emailInput = useTemplateRef('email-input');
13+
type InputTextType = InstanceType<typeof InputText> & { $el: HTMLElement };
14+
const emailInput = useTemplateRef<InputTextType>('email-input');
1315
1416
const {
1517
data: formData,
@@ -34,7 +36,9 @@ const loading = computed(() => {
3436
});
3537
3638
onMounted(() => {
37-
emailInput.value.$el.focus();
39+
if (emailInput.value) {
40+
emailInput.value.$el.focus();
41+
}
3842
});
3943
</script>
4044

src/views/auth/Login.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import { useRouter } from 'vue-router';
44
import { useAxiosForm } from '@/composables/useAxiosForm';
55
import { useAuthStore } from '@/stores/auth';
66
import { useFlashMessage } from '@/composables/useFlashMessage.js';
7+
import InputText from 'primevue/inputtext';
78
import GuestAuthLayout from '@/layouts/GuestAuthLayout.vue';
89
import InputErrors from '@/components/InputErrors.vue';
910
1011
const router = useRouter();
1112
const authStore = useAuthStore();
1213
const { flashMessages } = useFlashMessage();
1314
14-
const emailInput = useTemplateRef('email-input');
15+
type InputTextType = InstanceType<typeof InputText> & { $el: HTMLElement };
16+
const emailInput = useTemplateRef<InputTextType>('email-input');
1517
1618
const {
1719
data: formData,
@@ -28,7 +30,7 @@ const submit = () => {
2830
authStore.fetchCsrfCookie().then(() => {
2931
submitForm('/login', {
3032
onSuccess: () => {
31-
const redirectPath = router.currentRoute.value.query?.redirect;
33+
const redirectPath = router.currentRoute.value.query?.redirect as string;
3234
if (redirectPath) {
3335
router.push({ path: redirectPath });
3436
} else {
@@ -47,7 +49,9 @@ const loading = computed(() => {
4749
});
4850
4951
onMounted(() => {
50-
emailInput.value.$el.focus();
52+
if (emailInput.value) {
53+
emailInput.value.$el.focus();
54+
}
5155
});
5256
</script>
5357

src/views/auth/Register.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { useTemplateRef, computed, onMounted } from 'vue';
33
import { useRouter } from 'vue-router';
44
import { useAxiosForm } from '@/composables/useAxiosForm';
55
import { useAuthStore } from '@/stores/auth';
6+
import InputText from 'primevue/inputtext';
67
import GuestAuthLayout from '@/layouts/GuestAuthLayout.vue';
78
import InputErrors from '@/components/InputErrors.vue';
89
910
const router = useRouter();
1011
const authStore = useAuthStore();
1112
12-
const nameInput = useTemplateRef('name-input');
13+
type InputTextType = InstanceType<typeof InputText> & { $el: HTMLElement };
14+
const nameInput = useTemplateRef<InputTextType>('name-input');
1315
1416
const {
1517
data: formData,
@@ -37,7 +39,9 @@ const loading = computed(() => {
3739
});
3840
3941
onMounted(() => {
40-
nameInput.value.$el.focus();
42+
if (nameInput.value) {
43+
nameInput.value.$el.focus();
44+
}
4145
});
4246
</script>
4347

src/views/auth/ResetPassword.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useAxiosForm } from '@/composables/useAxiosForm';
44
import { useAuthStore } from '@/stores/auth';
55
import { useRoute, useRouter } from 'vue-router';
66
import { useFlashMessage } from '@/composables/useFlashMessage.js';
7+
import InputText from 'primevue/inputtext';
78
import GuestAuthLayout from '@/layouts/GuestAuthLayout.vue';
89
import InputErrors from '@/components/InputErrors.vue';
910
@@ -19,7 +20,8 @@ const route = useRoute();
1920
const authStore = useAuthStore();
2021
const { setFlashMessage } = useFlashMessage();
2122
22-
const emailInput = useTemplateRef('email-input');
23+
type InputTextType = InstanceType<typeof InputText> & { $el: HTMLElement };
24+
const emailInput = useTemplateRef<InputTextType>('email-input');
2325
2426
const {
2527
data: formData,
@@ -28,7 +30,7 @@ const {
2830
post: submitForm,
2931
} = useAxiosForm({
3032
token: props.token,
31-
email: route.query?.email ?? '',
33+
email: route.query?.email as string ?? '',
3234
password: '',
3335
password_confirmation: '',
3436
});
@@ -49,7 +51,9 @@ const loading = computed(() => {
4951
});
5052
5153
onMounted(() => {
52-
emailInput.value.$el.focus();
54+
if (emailInput.value) {
55+
emailInput.value.$el.focus();
56+
}
5357
});
5458
</script>
5559

src/views/settings/Password.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import AppLayout from '@/layouts/AppLayout.vue';
88
import SettingsLayout from '@/layouts/UserSettingsLayout.vue';
99
import InputErrors from '@/components/InputErrors.vue';
1010
11+
1112
const breadcrumbs = [
1213
{ label: 'Dashboard', route: { name: 'dashboard' } },
1314
{ label: 'Password settings' },
@@ -16,8 +17,9 @@ const breadcrumbs = [
1617
const toast = useToast();
1718
const authStore = useAuthStore();
1819
19-
const currentPasswordInput = useTemplateRef('current-password-input');
20-
const newPasswordInput = useTemplateRef('new-password-input');
20+
type PasswordInputType = InstanceType<typeof Password> & { $el: HTMLElement };
21+
const currentPasswordInput = useTemplateRef<PasswordInputType>('current-password-input');
22+
const newPasswordInput = useTemplateRef<PasswordInputType>('new-password-input');
2123
2224
const {
2325
data: formData,
@@ -47,17 +49,16 @@ const submit = () => {
4749
await nextTick();
4850
if (validationErrors.value?.password) {
4951
resetFormFields('password', 'password_confirmation');
50-
const newPasswordInputElement = newPasswordInput.value.$el.querySelector('input');
51-
if (newPasswordInputElement) {
52-
newPasswordInputElement.focus();
52+
if (newPasswordInput.value && newPasswordInput.value?.$el) {
53+
const newPasswordInputElement = newPasswordInput.value.$el.querySelector('input');
54+
newPasswordInputElement?.focus();
5355
}
5456
}
5557
if (validationErrors.value?.current_password) {
5658
resetFormFields('current_password');
57-
const currentPasswordInputElement = currentPasswordInput.value.$el.querySelector('input');
58-
console.log(currentPasswordInput.value.$el);
59-
if (currentPasswordInputElement) {
60-
currentPasswordInputElement.focus();
59+
if (currentPasswordInput.value && currentPasswordInput.value?.$el) {
60+
const currentPasswordInputElement = currentPasswordInput.value.$el.querySelector('input');
61+
currentPasswordInputElement?.focus();
6162
}
6263
}
6364
},

src/views/settings/Profile.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const {
2727
processing: updating,
2828
patch: submitForm,
2929
} = useAxiosForm({
30-
name: authStore.user.name || '',
31-
email: authStore.user.email || '',
30+
name: authStore.user?.name || '',
31+
email: authStore.user?.email || '',
3232
});
3333
const submit = () => {
3434
submitForm('/profile', {
@@ -95,7 +95,7 @@ const resendVerifyEmail = () => {
9595
<InputErrors :errors="validationErrors?.email" />
9696
</div>
9797

98-
<div v-if="authStore.mustVerifyEmail && authStore.user.email_verified_at === null">
98+
<div v-if="authStore.mustVerifyEmail && authStore.user?.email_verified_at === null">
9999
<p class="text-sm mt-2">
100100
Your email address is unverified.
101101
<a

0 commit comments

Comments
 (0)