-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update profile #150
feat: update profile #150
Conversation
Thank you for following the naming conventions for pull request titles! 🙏 |
where: { | ||
status: "ACTIVE", | ||
id: user.memberId, | ||
companyId: user.companyId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filtering by companyId
is not necessary here.
FormLabel, | ||
FormMessage, | ||
} from "@/components/ui/form"; | ||
const profileSettingsSchema = z.object({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this schema to a dedicated file so that it can be used on the backend as well.
const [file, setFile] = useState<File | null>(null); | ||
const fileInputRef = useRef<HTMLInputElement>(null); | ||
|
||
// @ts-expect-error: xxxx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment
resolver: zodResolver(profileSettingsSchema), | ||
}); | ||
|
||
// @ts-expect-error: xxxx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
}, | ||
}); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to fetch data initially from the server component and pass the profile
as prop. useEffect
is redundant here.
} | ||
}, [memberProfile?.data, form]); | ||
|
||
const handleImageUpload = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this unused function.
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const files = event.target.files; | ||
|
||
if (files?.[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract the file validation logic to a utils
.
const handleRemoveAvatar = () => { | ||
setFile(null); | ||
}; | ||
async function onSubmit(values: z.infer<typeof profileSettingsSchema>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing a profile picture and saving profile information are two different actions like I said the day before. Clicking on save button should only save the profile information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have requested for some changes. Awesome work BTW
@chetannn I think I fixed the requested changes ?? |
PR for issue #139