Skip to content

Feature/profile picture update in settings - #95

Open
dashabhijeet wants to merge 8 commits into
sristy17:devfrom
dashabhijeet:feature/profile-picture-update-in-settings
Open

Feature/profile picture update in settings#95
dashabhijeet wants to merge 8 commits into
sristy17:devfrom
dashabhijeet:feature/profile-picture-update-in-settings

Conversation

@dashabhijeet

@dashabhijeet dashabhijeet commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

Pull Request

Description
This PR updates the ProfilePhotoForm component to improve avatar handling. It allows users to:

  • Upload a new profile photo.
  • Edit the uploaded image using cropping before confirming.
  • Remove the profile photo.
  • Preview the avatar in a larger circular view by clicking on it, with the rest of the profile photo card dimmed for focus.

The edit functionality remains intact when uploading a new photo, and the preview feature lets users clearly see their avatar.

Video Confirming the same

20250830-1904-15.7312230.mp4

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have performed a self-review of my own code
  • I have commented my code where necessary
  • I have added tests where necessary
  • My changes generate no new warnings

Related Issues
Closes #87

@vercel

vercel Bot commented Aug 30, 2025

Copy link
Copy Markdown

@dashabhijeet is attempting to deploy a commit to the sristy17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@dashabhijeet

Copy link
Copy Markdown
Contributor Author

@sristy17 @pooranjoyb

@pooranjoyb

Copy link
Copy Markdown
Collaborator

create a folder called storage in apis and create 3 files provider, query and types.

check the implementation of Auth related apis using tanstack.

@pooranjoyb

pooranjoyb commented Aug 31, 2025

Copy link
Copy Markdown
Collaborator

take latest pulls from dev and fix conflicts

@pooranjoyb pooranjoyb added help wanted Extra attention is needed gssoc25 level 3 enhancement New feature or request labels Aug 31, 2025
@dashabhijeet

Copy link
Copy Markdown
Contributor Author

take latest pulls from master and fix conflicts

You mean the dev branch right?

@pooranjoyb

Copy link
Copy Markdown
Collaborator

take latest pulls from dev and fix conflicts

You mean the dev branch right?

yes

@vercel

vercel Bot commented Sep 2, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
next-payroll Error Error Sep 3, 2025 5:31pm

@sristy17 sristy17 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Resolve Conflicts

@sristy17 sristy17 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Screenshot from 2025-09-02 20-24-38

@dashabhijeet

Copy link
Copy Markdown
Contributor Author

Resolve Conflicts

Yeah yeah on it, was down with fever

@dashabhijeet
dashabhijeet force-pushed the feature/profile-picture-update-in-settings branch from 1751376 to d5dbd2d Compare September 3, 2025 10:21
@dashabhijeet

Copy link
Copy Markdown
Contributor Author

@sristy17 @pooranjoyb please check

@pooranjoyb

Copy link
Copy Markdown
Collaborator

Why are you using so many states and hitting api in the component itself.

Rather, use a tanstack query and render it.

Write provider and query with tanstack

@dashabhijeet

Copy link
Copy Markdown
Contributor Author

Why are you using so many states and hitting api in the component itself.

Rather, use a tanstack query and render it.

Write provider and query with tanstack

I initially used all that to make it work but forgot to change it, i will change it.

@sristy17 sristy17 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Screenshot from 2025-09-03 23-01-51

@pooranjoyb

Copy link
Copy Markdown
Collaborator

update @dashabhijeet

@dashabhijeet

Copy link
Copy Markdown
Contributor Author

Will submit by tomorrow eod

@dashabhijeet

dashabhijeet commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

So now the states i have are important:

These are purely UI-side. They control how the user adjusts the crop box and zoom before uploading. No TanStack Query here because this never touches the server — it’s temporary interaction state.

const [crop, setCrop] = useState({ x: 0, y: 0 });
const [zoom, setZoom] = useState(1);
const [croppedAreaPixels, setCroppedAreaPixels] = useState<Area | null>(null);

These also stay local only. They let us manage the workflow: when a file is picked, when the crop modal is open, and when the preview is shown. Again, TanStack Query isn’t needed because none of this lives on the server — it’s just client-side UX.

const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [imageUrl, setImageUrl] = useState<string | null>(null);
const [showCropModal, setShowCropModal] = useState(false);
const [showPreviewModal, setShowPreviewModal] = useState(false);

These link the local UI to the server state. We use TanStack Query mutations to upload/remove photos and refetch the user profile, but we still need local state here to immediately display the avatar (signed URL + path) while waiting for the query to sync. If we removed them, we’d lose flexibility to optimistically show the latest avatar.

const [avatarUrl, setAvatarUrl] = useState<string | null>(null);
const [avatarPath, setAvatarPath] = useState<string | null>(null);

Finally, the two TanStack Query hooks (upload + remove) exist because server state should be handled through React Query — it automatically caches, invalidates, and refetches, keeping the backend in sync. Local state only covers UI interactions; React Query ensures the database and UI stay consistent.

@dashabhijeet

Copy link
Copy Markdown
Contributor Author

@pooranjoyb @sristy17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gssoc25 help wanted Extra attention is needed level 3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Profile Picture Upload in User Settings

3 participants