Feature/profile picture update in settings - #95
Conversation
|
@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. |
|
create a folder called check the implementation of Auth related apis using tanstack. |
|
take latest pulls from dev and fix conflicts |
You mean the dev branch right? |
yes |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Yeah yeah on it, was down with fever |
…thub.com/dashabhijeet/next-payroll into feature/profile-picture-update-in-settings
1751376 to
d5dbd2d
Compare
|
@sristy17 @pooranjoyb please check |
|
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. |
|
update @dashabhijeet |
|
Will submit by tomorrow eod |
|
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. |


Pull Request
Description
This PR updates the
ProfilePhotoFormcomponent to improve avatar handling. It allows users to: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
Checklist
Related Issues
Closes #87