Skip to content

Commit e2412eb

Browse files
committed
MP-43 add reset selection button
1 parent ba29416 commit e2412eb

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

src/apps/accounts/src/settings/tabs/payments/PaymentsTab.module.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@
4040
border-radius: 4px;
4141
margin-top: $sp-8;
4242

43+
.confirmSelectionReset {
44+
display: flex;
45+
justify-content: space-between;
46+
align-items: center;
47+
margin-top: $sp-8;
48+
49+
@include ltelg {
50+
flex-direction: column;
51+
align-items: flex-start;
52+
53+
button {
54+
margin-top: $sp-4;
55+
}
56+
}
57+
}
58+
4359
.providers {
4460
display: grid;
4561
gap: $sp-8;

src/apps/accounts/src/settings/tabs/payments/PaymentsTab.tsx

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const PaymentsTab: FC<PaymentsTabProps> = (props: PaymentsTabProps) => {
3535
const [hasEmailedSupport, setHasEmailedSupport]: [boolean, Dispatch<SetStateAction<boolean>>]
3636
= useState<boolean>(false)
3737

38+
const [wantsToChangePreviousSelection, setWantsToChangePreviousSelection]: [boolean, Dispatch<SetStateAction<boolean>>]
39+
= useState<boolean>(false)
40+
3841
const [paymentService, setPaymentService]: [string | undefined, Dispatch<SetStateAction<string | undefined>>] = useState(
3942
localStorage.getItem(`${props.profile.handle}_${PAYMENT_PROVIDER_KEY}`) || undefined,
4043
)
@@ -68,7 +71,12 @@ const PaymentsTab: FC<PaymentsTabProps> = (props: PaymentsTabProps) => {
6871
}
6972
}
7073

71-
function handleSelectedProviderReset(): void {
74+
function handleSelectedProviderChange(): void {
75+
setWantsToChangePreviousSelection(true)
76+
}
77+
78+
function handleSelectionReset(): void {
79+
setWantsToChangePreviousSelection(false)
7280
localStorage.removeItem(`${props.profile.handle}_${PAYMENT_PROVIDER_KEY}`)
7381
setPaymentService(undefined)
7482
}
@@ -108,7 +116,7 @@ const PaymentsTab: FC<PaymentsTabProps> = (props: PaymentsTabProps) => {
108116
</p>
109117

110118
{
111-
paymentService ? (
119+
paymentService && !wantsToChangePreviousSelection ? (
112120
<SettingSection
113121
leftElement={(
114122
<div className={styles.providerSubmittedIcon}>
@@ -123,11 +131,37 @@ const PaymentsTab: FC<PaymentsTabProps> = (props: PaymentsTabProps) => {
123131
secondary
124132
size='lg'
125133
label='Change Provider'
126-
onClick={handleSelectedProviderReset}
134+
onClick={handleSelectedProviderChange}
127135
/>
128136
)}
129137
/>
130-
) : (
138+
) : undefined
139+
}
140+
141+
{
142+
paymentService && wantsToChangePreviousSelection ? (
143+
<div className={styles.confirmSelectionReset}>
144+
<p>
145+
<strong className='body-main-bold'>
146+
Your currently selected payment provider is:
147+
{' '}
148+
{paymentService}
149+
</strong>
150+
<br />
151+
<strong className='body-main-bold'>Note: </strong>
152+
You have chosen to change your selected payment provider. This change may take up to 48 hours to be reflected in your account.
153+
</p>
154+
<Button
155+
secondary
156+
label='Cancel Change'
157+
onClick={handleSelectionReset}
158+
/>
159+
</div>
160+
) : undefined
161+
}
162+
163+
{
164+
!paymentService || wantsToChangePreviousSelection ? (
131165
<>
132166
<div className={styles.providers}>
133167
<div className={styles.providerCard}>
@@ -214,7 +248,7 @@ const PaymentsTab: FC<PaymentsTabProps> = (props: PaymentsTabProps) => {
214248
prior to making a payment provider decision.
215249
</p>
216250
</>
217-
)
251+
) : undefined
218252
}
219253
</Collapsible>
220254
</div>

0 commit comments

Comments
 (0)