File tree Expand file tree Collapse file tree
(user-management)/users/_components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { UpdateFormBody } from "@/components/update-modal/form-body";
66import type { UpdateFormBaseProps } from "@/components/update-modal/types" ;
77import { zodResolver } from "@hookform/resolvers/zod" ;
88import React from "react" ;
9- import { useForm } from "react-hook-form" ;
9+ import { useForm , useWatch } from "react-hook-form" ;
1010import { z } from "zod" ;
1111
1212export 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
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { useUser } from "@/providers/use-user";
99import { useMutation } from "@apollo/client/react" ;
1010import { zodResolver } from "@hookform/resolvers/zod" ;
1111import { useEffect } from "react" ;
12- import { useForm } from "react-hook-form" ;
12+ import { useForm , useWatch } from "react-hook-form" ;
1313import { toast } from "sonner" ;
1414import { z } from "zod" ;
1515import { 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 ) => {
Original file line number Diff line number Diff 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,
Original file line number Diff line number Diff 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 >
You can’t perform that action at this time.
0 commit comments