Skip to content
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

Merged
merged 27 commits into from
Mar 1, 2024

Conversation

Raju-kadel-27
Copy link
Member

PR for issue #139

Copy link

github-actions bot commented Feb 24, 2024

Thank you for following the naming conventions for pull request titles! 🙏

@Raju-kadel-27 Raju-kadel-27 changed the title feat:update-profile-procedure feat: update profile procedure Feb 24, 2024
@Raju-kadel-27 Raju-kadel-27 changed the title feat: update profile procedure feat: update profile Feb 24, 2024
@Raju-kadel-27 Raju-kadel-27 marked this pull request as ready for review February 28, 2024 14:11
@Raju-kadel-27
Copy link
Member Author

@dahal @chetannn I think it's ready for review.

where: {
status: "ACTIVE",
id: user.memberId,
companyId: user.companyId,
Copy link
Collaborator

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({
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

},
});

useEffect(() => {
Copy link
Collaborator

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 (
Copy link
Collaborator

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]) {
Copy link
Collaborator

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>) {
Copy link
Collaborator

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.

Copy link
Collaborator

@chetannn chetannn left a 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

@Raju-kadel-27
Copy link
Member Author

@chetannn I think I fixed the requested changes ??

@dahal dahal merged commit 879ea5d into captableinc:main Mar 1, 2024
2 checks passed
@Raju-kadel-27 Raju-kadel-27 deleted the feat/complete-profile-setup branch March 1, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants