Enhance type safety in Appearance and Profile components by updating function signatures to use specific types. In Appearance.vue, change the parameter type of onAppearanceChange to AcceptableValue, ensuring only valid values are processed. In Profile.vue, add preserveScroll option to the form submission for improved user experience during profile updates.

This commit is contained in:
Yoga Pangestu 2026-06-12 16:02:48 +07:00
parent 09f35db9d8
commit 5124317a38
2 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<script setup lang="ts">
import { Head, useForm } from '@inertiajs/vue3';
import { Monitor, Moon, Save, Sun } from '@lucide/vue';
import type { AcceptableValue } from 'reka-ui';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
@ -51,7 +52,11 @@ const options: Array<{
},
];
function onAppearanceChange(value: string) {
function onAppearanceChange(value: AcceptableValue) {
if (typeof value !== 'string') {
return;
}
form.appearance = value as AppearanceMode;
applyAppearance(form.appearance);
}

View File

@ -18,7 +18,11 @@ import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { Textarea } from '@/components/ui/textarea';
import AccountLayout from '@/layouts/AccountLayout.vue';
import { formErrors } from '@/lib/form';
import type { EnumOption, ProfileFormData, ProfileUser } from '@/types/account';
import type {
EnumOption,
ProfileFormData,
ProfileUser,
} from '@/types/account';
const props = defineProps<{
user: ProfileUser;
@ -37,6 +41,7 @@ const form = useForm<ProfileFormData>({
function submit() {
form.put('/admin/account/profile', {
preserveScroll: true,
onError: () => {
toast.error('Gagal menyimpan profil. Periksa kembali formulir.');
},