Skip to content

Commit 661eee2

Browse files
dem4roniHiD
authored andcommitted
First working iteration
Adjust tests, update TS, add return links, refactor, etc Sort out setup_future_usage issue Remove unused bits, tailor other bits Add appearance obj Add different theme objects DRY Use card element for subscriptions, refactor things Fix a wrong type Update import Adjust tests Fix things, and paths Fix footer form anomaly Improve TS on application.tsx Add stripe version to footer cache key Fix test Force dark colors on premium and insiders Refactor things, make card element options adaptive Format utils better Pass amount from backend Delete unused component Lazy load stripe.js (#5843) Add styling for load error and loading Tweak margins Fix the world (#5861) * Fix the world * Tidy up, optimise ExercismStripeElements * Tidy up StripeForm * add off_session on Stripe::Subscription.create * Refactor Form, useStripeForm * Leave things at a simple, working state * Fix tests * One more fix --------- Co-authored-by: dem4ron <demaaron88@gmail.com>
1 parent fb560dd commit 661eee2

34 files changed

+734
-470
lines changed

app/commands/payments/stripe/payment_intent/create_for_payment.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ class Payments::Stripe::PaymentIntent::CreateForPayment
44
initialize_with :customer_id, :amount_in_cents
55

66
def call
7-
Stripe::PaymentIntent.create(
7+
options = {
88
customer: customer_id,
99
amount: amount_in_cents,
1010
currency: 'usd',
11-
setup_future_usage: 'off_session'
12-
)
11+
automatic_payment_methods: {
12+
enabled: true
13+
}
14+
}
15+
16+
Stripe::PaymentIntent.create(**options)
1317
end
1418
end

app/css/application.postcss.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@import "./components/social-icon";
3636
@import "./components/blog-post";
3737
@import "./components/donations-form";
38+
@import "./components/donation-card-error";
3839
@import "./components/toast";
3940
@import "./components/contributions-summary";
4041
@import "./components/progress";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.c-donation-card-error {
2+
@apply mt-16 text-center;
3+
@apply text-15 text-darkRed font-semibold leading-150;
4+
@apply border-2 border-darkRed rounded-8;
5+
@apply bg-lightRed;
6+
@apply py-12 px-24;
7+
}

app/css/components/donations-form.css

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,7 @@
151151
}
152152
}
153153
}
154-
& .card-error {
155-
@apply mt-16 text-center;
156-
@apply text-15 text-darkRed font-semibold leading-150;
157-
@apply border-2 border-darkRed rounded-8;
158-
@apply bg-lightRed;
159-
@apply py-12 px-24;
160-
}
154+
161155
& .extra-info {
162156
@apply mt-16;
163157
@apply text-13 leading-160 text-textColor6 text-center;

app/helpers/react_components/donations/footer_form.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module ReactComponents
22
module Donations
33
class FooterForm < ReactComponent
4+
# this is cached in view_components/site_footer.rb
45
def to_s
56
super(
67
"donations-footer-form",
@@ -15,7 +16,8 @@ def to_s
1516
captcha_required: !current_user || current_user.captcha_required?,
1617
recaptcha_site_key: ENV.fetch('RECAPTCHA_SITE_KEY', Exercism.secrets.recaptcha_site_key),
1718
links: {
18-
settings: Exercism::Routes.donations_settings_url
19+
settings: Exercism::Routes.donations_settings_url,
20+
donate: Exercism::Routes.donate_url
1921
}
2022
}
2123
)

app/helpers/react_components/donations/premium_subscription_form.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ def to_s
44
"premium-subscription-form",
55
{
66
links: { cancel:, update_to_monthly: update_to_plan(:month), update_to_annual: update_to_plan(:year),
7-
insiders_path: Exercism::Routes.insiders_path, premium_redirect_link: Exercism::Routes.premium_path },
7+
insiders_path: Exercism::Routes.insiders_path, premium_redirect_link: Exercism::Routes.premium_path,
8+
premium_redirect_url: Exercism::Routes.premium_url },
89
user_signed_in: user_signed_in?,
910
captcha_required: !current_user || current_user.captcha_required?,
1011
recaptcha_site_key: ENV.fetch('RECAPTCHA_SITE_KEY', Exercism.secrets.recaptcha_site_key)

app/helpers/react_components/insiders/insiders_status.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def to_s
77
{
88
status: current_user.insiders_status,
99
insiders_status_request: Exercism::Routes.api_user_url(current_user),
10+
amount: 499,
1011
activate_insider_link: Exercism::Routes.activate_insiders_api_user_path,
1112
user_signed_in: user_signed_in?,
1213
captcha_required: !current_user || current_user.captcha_required?,

app/helpers/react_components/premium/price_option.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def to_s
1010
captcha_required: !current_user || current_user.captcha_required?,
1111
recaptcha_site_key: ENV.fetch('RECAPTCHA_SITE_KEY', Exercism.secrets.recaptcha_site_key),
1212
premium_redirect_link: Exercism::Routes.premium_path,
13+
premium_redirect_url: Exercism::Routes.premium_url,
1314
insiders_redirect_link: Exercism::Routes.insiders_path
1415
}.merge(send("data_for_#{type}"))
1516
)

app/helpers/view_components/site_footer.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def cache_key
1818
parts = digests
1919
parts << ::Track.active.count
2020
parts << user_part
21+
parts << stripe_version
2122

2223
parts.join(':')
2324
end
@@ -28,6 +29,8 @@ def user_part
2829
current_user.captcha_required? ? 2 : 1
2930
end
3031

32+
def stripe_version = 2
33+
3134
def digests
3235
%w[external shared].map do |file|
3336
Digest::SHA1.hexdigest(File.read(Rails.root.join('app', 'views', 'components', 'footer', "#{file}.html.haml")))

app/javascript/components/community/video-grid/index.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import type { Request } from '@/hooks'
1414
import type { VideoTrack } from '@/components/types'
1515
import type { CommunityVideoType } from '@/components/types'
1616

17-
type VideoGridProps = {
18-
data: {
19-
tracks: VideoTrack[]
20-
itemsPerRow: number
21-
request: Request
22-
}
17+
export type VideoGridProps = {
18+
tracks: VideoTrack[]
19+
itemsPerRow: number
20+
request: Request
2321
}
2422

25-
export function VideoGrid({ data }: VideoGridProps): JSX.Element {
23+
export function VideoGrid({
24+
tracks,
25+
itemsPerRow,
26+
request,
27+
}: VideoGridProps): JSX.Element {
2628
const {
2729
resolvedData,
2830
page,
@@ -32,7 +34,7 @@ export function VideoGrid({ data }: VideoGridProps): JSX.Element {
3234
selectedTrack,
3335
criteria,
3436
setCriteria,
35-
} = useVideoGrid(data.request, data.tracks)
37+
} = useVideoGrid(request, tracks)
3638

3739
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3840
const timer = useRef<any>()
@@ -52,7 +54,7 @@ export function VideoGrid({ data }: VideoGridProps): JSX.Element {
5254
return (
5355
<>
5456
<VideoGridHeader
55-
tracks={data.tracks}
57+
tracks={tracks}
5658
handleTrackChange={handleTrackChange}
5759
selectedTrack={selectedTrack}
5860
/>
@@ -71,7 +73,7 @@ export function VideoGrid({ data }: VideoGridProps): JSX.Element {
7173

7274
<ResultsZone isFetching={isFetching}>
7375
<div
74-
className={`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-${data.itemsPerRow} gap-16`}
76+
className={`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-${itemsPerRow} gap-16`}
7577
>
7678
{resolvedData && resolvedData.results.length > 0 ? (
7779
resolvedData.results.map((video) => (

0 commit comments

Comments
 (0)