-
Notifications
You must be signed in to change notification settings - Fork 4
Add profile picture upload for users and organizations #704
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
de56456
Add profile picture editor
BoraIneviNMI 972e3ec
Add user profile info management
BoraIneviNMI 43ddeb3
Add organization logo management
BoraIneviNMI 7b44f18
Move image cropping to client-side
BoraIneviNMI fd77766
Add pixel size checks
BoraIneviNMI f4aa43a
Add welcome page profile picture input
BoraIneviNMI 90f05ff
fix: update principal_id resolution in the profile picture route
BoraIneviNMI eea55ef
Resolve nitpicks
BoraIneviNMI 05e5bbe
Add read-only version of the organization profile picture setting
BoraIneviNMI 83bbd53
Add changeset
BoraIneviNMI ee27339
Merge branch 'development' into FDM664
BoraIneviNMI 7b64f7b
Allow cropping organization logos beyond the bounds of the image
BoraIneviNMI 9dd00e1
Add organization logo to the organization cards and the organization …
BoraIneviNMI 23554bb
Merge branch 'development' into FDM664
BoraIneviNMI 4c4958d
Fix organization card organization name type
BoraIneviNMI b2b9e4a
Improve organization settings page
BoraIneviNMI 112ecc1
Fix potential bugs
BoraIneviNMI 11ef86e
fix: reset profile picture manager after it is submitted
BoraIneviNMI 9f48cb0
Merge branch 'development' into FDM664
SvenVw 3a07ee5
fix: uploading profile picture
SvenVw 4d482a8
refactor: show only single back button on page
SvenVw 9162538
refactor: use rectangle and outer for user profile
SvenVw b7e8cd0
Merge branch 'development' into FDM664
SvenVw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@nmi-agro/fdm-app": minor | ||
| --- | ||
|
|
||
| Users can now upload their profile picture and organizations can now upload their logo, which will be stored in the GCS and displayed using the existing user.image and organization.logo database record fields. The profile pictures and logos, including those retrieved previously from social login, can also be deleted. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
fdm-app/app/components/blocks/organization/organization-avatar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { Building } from "lucide-react" | ||
| import { cn } from "@/app/lib/utils" | ||
| import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar" | ||
|
|
||
| export function OrganizationAvatar({ | ||
| src, | ||
| alt, | ||
| className, | ||
| }: { | ||
| src: string | null | undefined | ||
| alt: string | ||
| className?: string | ||
| }) { | ||
| return ( | ||
| <Avatar className={cn("rounded-lg", className)}> | ||
| {typeof src === "string" ? <AvatarImage src={src} alt={alt} /> : undefined} | ||
| <AvatarFallback className="rounded-lg"> | ||
| <Building className="text-muted-foreground size-3/4" /> | ||
| </AvatarFallback> | ||
| </Avatar> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
fdm-app/app/components/blocks/profile/detect-existing.server.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** | ||
| * Detect if the user might have an existing profile picture in GCS based on the image URL. | ||
| * If so, returns the object key for it. | ||
| * | ||
| * @param imageUrl URL to check | ||
| * @returns the object key if the url matches the pattern for a profile picture that is stored in GCS, null otherwise. | ||
| */ | ||
| export function detectExistingProfilePictureObjectKey(imageUrl: string | null | undefined) { | ||
| if (typeof imageUrl !== "string") { | ||
| return null | ||
| } | ||
|
|
||
| const types = ["user", "organization"] as const | ||
|
|
||
| for (const type of types) { | ||
| const prefix = `/api/profile-picture/${type}/` | ||
| if (imageUrl.startsWith(prefix)) { | ||
| const fileName = imageUrl.substring(prefix.length).split("?")[0] | ||
| return `profile_picture_${type}/${fileName}` | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return null | ||
| } | ||
77 changes: 77 additions & 0 deletions
77
fdm-app/app/components/blocks/profile/profile-info-form.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { zodResolver } from "@hookform/resolvers/zod" | ||
| import { useEffect } from "react" | ||
| import { Controller } from "react-hook-form" | ||
| import { Form, useFetcher } from "react-router" | ||
| import { RemixFormProvider, useRemixForm } from "remix-hook-form" | ||
| import z from "zod" | ||
| import { Button } from "~/components/ui/button" | ||
| import { Field, FieldError, FieldLabel } from "~/components/ui/field" | ||
| import { Input } from "~/components/ui/input" | ||
| import { Spinner } from "~/components/ui/spinner" | ||
| import { ProfileInfoSchema } from "./profile-info-schema" | ||
|
|
||
| const InfoFormSchema = ProfileInfoSchema.extend({ intent: z.literal("update_profile_info") }) | ||
| export function ProfileInfoForm({ | ||
| user, | ||
| }: { | ||
| user: { firstname?: string | null | undefined; surname?: string | null | undefined } | ||
| }) { | ||
| const fetcher = useFetcher() | ||
|
|
||
| const isSubmitting = fetcher.state !== "idle" | ||
|
|
||
| const form = useRemixForm({ | ||
| mode: "onTouched", | ||
| resolver: zodResolver(InfoFormSchema), | ||
| fetcher: fetcher, | ||
| stringifyAllValues: false, | ||
| defaultValues: { | ||
| intent: "update_profile_info" as const, | ||
| firstname: user.firstname ?? "", | ||
| surname: user.surname ?? "", | ||
| }, | ||
| }) | ||
|
|
||
| useEffect(() => { | ||
| form.reset({ | ||
| intent: "update_profile_info" as const, | ||
| firstname: user.firstname ?? "", | ||
| surname: user.surname ?? "", | ||
| }) | ||
| }, [user, form.reset]) | ||
|
|
||
| return ( | ||
| <RemixFormProvider {...form}> | ||
| <Form method="post" onSubmit={form.handleSubmit} className="space-y-6"> | ||
| <fieldset disabled={isSubmitting} className="space-y-4"> | ||
| <input type="hidden" name="intent" value="update_profile_info" /> | ||
| <Controller | ||
| name="firstname" | ||
| render={({ field, fieldState }) => ( | ||
| <Field> | ||
| <FieldLabel>Voornaam</FieldLabel> | ||
| <Input {...field} type="text" /> | ||
| {fieldState.error && <FieldError errors={[fieldState.error]} />} | ||
| </Field> | ||
| )} | ||
| /> | ||
| <Controller | ||
| name="surname" | ||
| render={({ field, fieldState }) => ( | ||
| <Field> | ||
| <FieldLabel>Achternaam</FieldLabel> | ||
| <Input {...field} type="text" /> | ||
| {fieldState.error && <FieldError errors={[fieldState.error]} />} | ||
| </Field> | ||
| )} | ||
| /> | ||
| </fieldset> | ||
| <div className="flex flex-row items-center justify-end gap-2"> | ||
| <Button type="submit" disabled={isSubmitting}> | ||
| Opslaan{isSubmitting && <Spinner />} | ||
| </Button> | ||
| </div> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| </Form> | ||
| </RemixFormProvider> | ||
| ) | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
fdm-app/app/components/blocks/profile/profile-info-schema.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import z from "zod" | ||
|
|
||
| export const ProfileInfoSchema = z.object({ | ||
| firstname: z | ||
| .string({ | ||
| error: (issue) => (issue.input === undefined ? "Vul je voornaam in" : undefined), | ||
| }) | ||
| .trim() | ||
| .min(1, { | ||
| error: "Vul je voornaam in", | ||
| }), | ||
| surname: z | ||
| .string({ | ||
| error: (issue) => (issue.input === undefined ? "Vul je achternaam in" : undefined), | ||
| }) | ||
| .trim() | ||
| .min(1, { | ||
| error: "Vul je achternaam in", | ||
| }), | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Scope the social-login deletion claim to user profile pictures.
The supplied flow demonstrates removal of a user’s imported social image, but not social-login-derived organization logos. Reword this sentence to avoid implying that organization logos can originate from social login.
🤖 Prompt for AI Agents