Skip to content

Commit c542496

Browse files
committed
fix: compatible with latest lint rules
1 parent 2ad9c03 commit c542496

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

app/(admin)/(user-management)/users/_components/update-form.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { UpdateFormBody } from "@/components/update-modal/form-body";
66
import type { UpdateFormBaseProps } from "@/components/update-modal/types";
77
import { zodResolver } from "@hookform/resolvers/zod";
88
import React from "react";
9-
import { useForm } from "react-hook-form";
9+
import { useForm, useWatch } from "react-hook-form";
1010
import { z } from "zod";
1111

1212
export const formSchema = z.object({
@@ -39,6 +39,9 @@ export function UpdateUserForm({
3939
defaultValues,
4040
});
4141

42+
const avatar = useWatch({ control: form.control, name: "avatar" });
43+
const name = useWatch({ control: form.control, name: "name" });
44+
4245
const handleSubmit = (data: z.infer<typeof formSchema>) => {
4346
onSubmit({
4447
name: data.name,
@@ -85,8 +88,8 @@ export function UpdateUserForm({
8588
/>
8689

8790
<Avatar>
88-
<AvatarImage src={form.watch("avatar")} />
89-
<AvatarFallback>{form.watch("name")}</AvatarFallback>
91+
<AvatarImage src={avatar} />
92+
<AvatarFallback>{name}</AvatarFallback>
9093
</Avatar>
9194
</div>
9295

app/(admin)/me/_components/form.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useUser } from "@/providers/use-user";
99
import { useMutation } from "@apollo/client/react";
1010
import { zodResolver } from "@hookform/resolvers/zod";
1111
import { useEffect } from "react";
12-
import { useForm } from "react-hook-form";
12+
import { useForm, useWatch } from "react-hook-form";
1313
import { toast } from "sonner";
1414
import { z } from "zod";
1515
import { ME_UPDATE_MUTATION } from "./mutation";
@@ -30,6 +30,8 @@ export function MeForm() {
3030
},
3131
});
3232

33+
const avatar = useWatch({ control: form.control, name: "avatar" });
34+
3335
useEffect(() => {
3436
if (!form.formState.isDirty) return;
3537
const message = "您有尚未儲存的更動。確定要關閉而不儲存嗎?您的更動將會遺失。";
@@ -47,8 +49,6 @@ export function MeForm() {
4749
};
4850
}, [form.formState.isDirty]);
4951

50-
const avatar = form.watch("avatar");
51-
5252
const [updateMe] = useMutation(ME_UPDATE_MUTATION, {
5353
refetchQueries: [BASIC_USER_INFO_QUERY],
5454
onError: (error) => {

components/data-table/general.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export function GeneralDataTable<TData, TValue>({
1212
columns,
1313
data,
1414
}: GeneralDataTableProps<TData, TValue>) {
15+
"use no memo";
16+
1517
const table = useReactTable({
1618
data,
1719
columns,

components/ui/sidebar.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,6 @@ function SidebarMenuSkeleton({
723723
}: React.ComponentProps<"div"> & {
724724
showIcon?: boolean;
725725
}) {
726-
// Random width between 50 to 90%.
727-
const width = React.useMemo(() => {
728-
return `${Math.floor(Math.random() * 40) + 50}%`;
729-
}, []);
730-
731726
return (
732727
<div
733728
data-slot="sidebar-menu-skeleton"
@@ -745,7 +740,7 @@ function SidebarMenuSkeleton({
745740
className="h-4 max-w-(--skeleton-width) flex-1"
746741
data-sidebar="menu-skeleton-text"
747742
style={{
748-
"--skeleton-width": width,
743+
"--skeleton-width": "90%",
749744
} as React.CSSProperties}
750745
/>
751746
</div>

0 commit comments

Comments
 (0)