-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Allow updating partner email #2602
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import { | |
| Button, | ||
| buttonVariants, | ||
| DotsPattern, | ||
| DynamicTooltipWrapper, | ||
| FileUpload, | ||
| LoadingSpinner, | ||
| ToggleGroup, | ||
|
|
@@ -89,6 +90,7 @@ function FormWrapper({ | |
|
|
||
| type ProfileFormData = { | ||
| name: string; | ||
| email: string; | ||
| image: string | null; | ||
| description: string | null; | ||
| country: string; | ||
|
|
@@ -103,6 +105,7 @@ function FormProvider({ | |
| const form = useForm<ProfileFormData>({ | ||
| defaultValues: { | ||
| name: partner.name, | ||
| email: partner.email ?? "", | ||
| image: partner.image, | ||
| description: partner.description ?? null, | ||
| country: partner.country ?? "", | ||
|
|
@@ -115,6 +118,8 @@ function FormProvider({ | |
| } | ||
|
|
||
| function Controls({ formRef }: { formRef: RefObject<HTMLFormElement> }) { | ||
| const { partner } = usePartnerProfile(); | ||
|
|
||
| const { MergePartnerAccountsModal, setShowMergePartnerAccountsModal } = | ||
| useMergePartnerAccountsModal(); | ||
|
|
||
|
|
@@ -135,7 +140,19 @@ function Controls({ formRef }: { formRef: RefObject<HTMLFormElement> }) { | |
| text="Save changes" | ||
| className="h-8 w-fit px-2.5" | ||
| loading={isSubmitting} | ||
| onClick={() => formRef.current?.requestSubmit()} | ||
| onClick={() => { | ||
| if (partner?.stripeConnectId) { | ||
| const confirmed = window.confirm( | ||
| "Updating your email, country, or profile type will reset your Stripe account, which will require you to restart the payouts connection process. Are you sure you want to continue?", | ||
| ); | ||
|
|
||
| if (!confirmed) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| formRef.current?.requestSubmit(); | ||
| }} | ||
| /> | ||
| </> | ||
| ); | ||
|
|
@@ -252,29 +269,57 @@ function ProfileForm({ | |
| /> | ||
| </div> | ||
| </label> | ||
| <label className="flex flex-col gap-1.5"> | ||
| <span className="text-sm font-medium text-neutral-800">Email</span> | ||
| <DynamicTooltipWrapper | ||
| tooltipProps={ | ||
| completedPayoutsCount > 0 | ||
| ? { | ||
| content: | ||
| "Since you've already received payouts on Dub, you cannot change your email. If you need to update your email, please contact support.", | ||
| } | ||
| : undefined | ||
| } | ||
| > | ||
| <input | ||
| type="email" | ||
| className={cn( | ||
| "block w-full rounded-md focus:outline-none sm:text-sm", | ||
| errors.email | ||
| ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500" | ||
| : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500", | ||
| completedPayoutsCount > 0 && | ||
| "cursor-not-allowed bg-neutral-100 text-neutral-400", | ||
| )} | ||
| placeholder="[email protected]" | ||
| disabled={completedPayoutsCount > 0} | ||
| {...register("email", { | ||
| required: true, | ||
| })} | ||
| /> | ||
| </DynamicTooltipWrapper> | ||
| </label> | ||
| <label className="flex flex-col"> | ||
| <span className="text-sm font-medium text-neutral-800"> | ||
| Country | ||
| </span> | ||
| <div> | ||
| <Controller | ||
| control={control} | ||
| name="country" | ||
| rules={{ required: true }} | ||
| render={({ field }) => ( | ||
| <CountryCombobox | ||
| value={field.value || ""} | ||
| onChange={field.onChange} | ||
| error={errors.country ? true : false} | ||
| disabledTooltip={ | ||
| completedPayoutsCount > 0 | ||
| ? "Since you've already received payouts on Dub, you cannot change your country. If you need to update your country, please contact support." | ||
| : undefined | ||
| } | ||
| /> | ||
| )} | ||
| /> | ||
| </div> | ||
| <Controller | ||
| control={control} | ||
| name="country" | ||
| rules={{ required: true }} | ||
| render={({ field }) => ( | ||
| <CountryCombobox | ||
| value={field.value || ""} | ||
| onChange={field.onChange} | ||
| error={errors.country ? true : false} | ||
| disabledTooltip={ | ||
| completedPayoutsCount > 0 | ||
| ? "Since you've already received payouts on Dub, you cannot change your country. If you need to update your country, please contact support." | ||
| : undefined | ||
| } | ||
| /> | ||
| )} | ||
| /> | ||
| </label> | ||
|
|
||
| <label className="flex flex-col gap-1.5"> | ||
|
|
@@ -302,7 +347,16 @@ function ProfileForm({ | |
| <span className="text-sm font-medium text-neutral-800"> | ||
| Profile type | ||
| </span> | ||
| <div className="w-full"> | ||
| <DynamicTooltipWrapper | ||
| tooltipProps={ | ||
| completedPayoutsCount > 0 | ||
| ? { | ||
| content: | ||
| "Since you've already received payouts on Dub, you cannot change your profile type. If you need to update your profile type, please contact support.", | ||
| } | ||
| : undefined | ||
| } | ||
| > | ||
| <LayoutGroup> | ||
| <div className="w-full"> | ||
| <ToggleGroup | ||
|
|
@@ -328,13 +382,14 @@ function ProfileForm({ | |
| )} | ||
| optionClassName={cn( | ||
| "h-9 flex items-center justify-center rounded-lg flex-1", | ||
| completedPayoutsCount > 0 && "pointer-events-none", | ||
| completedPayoutsCount > 0 && | ||
| "pointer-events-none text-neutral-400", | ||
| )} | ||
| indicatorClassName="bg-white" | ||
| /> | ||
| </div> | ||
| </LayoutGroup> | ||
| </div> | ||
| </DynamicTooltipWrapper> | ||
| </label> | ||
|
|
||
| <AnimatePresence mode="popLayout"> | ||
|
|
@@ -378,14 +433,6 @@ function ProfileForm({ | |
| </AnimatePresence> | ||
| </div> | ||
| </div> | ||
| {/* <div className="flex justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-100 px-5 py-3.5"> | ||
| <Button | ||
| type="submit" | ||
| text="Save changes" | ||
| className="h-8 w-fit px-2.5" | ||
| loading={isSubmitting || isPending} | ||
| /> | ||
| </div> */} | ||
| </form> | ||
| ); | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.