-
-
Notifications
You must be signed in to change notification settings - Fork 303
feat: plans migration #3216
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
base: main
Are you sure you want to change the base?
feat: plans migration #3216
Changes from all commits
fd89748
ea1ccfe
71a5d84
91250bc
23561c5
44299a8
506a022
b255f09
d61a02f
1ed447b
0228ce6
a395bb3
c9092c8
db9ccdc
49e9285
e079a93
848db96
ac4e28c
bf9215a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,3 +113,16 @@ notifications.email.security-settings-link=Check your security settings <a href= | |
notifications.email.mfa.MFA_ENABLED=Multi-factor authentication has been enabled for your account. | ||
notifications.email.mfa.MFA_DISABLED=Multi-factor authentication has been disabled for your account. | ||
notifications.email.password-changed=Password has been changed for your account. | ||
|
||
notifications.email.plan-migration-subject=Your 🐁 plan will be updated on {0} | ||
notifications.email.plan-migration-body=Hello! 👋<br/><br/>\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, the encoding is somehow broken. I believe utf-8 is now supported for properties file. Can we fix it? In the meantime, I am asking marketa to provide proper e-mail. |
||
We’d like to let you know that starting {0}, your current plan will be automatically updated.<br/>\ | ||
Current plan: {1} (€{2}/mo)<br/>\ | ||
New plan: {3} (€{4}/mo)<br/>\ | ||
<br/>\ | ||
If you’d prefer to switch to a different plan, you can easily do so in <a href="{5}">Subscriptions</a>\ | ||
<br/><br/>\ | ||
If you’re not happy with this change, please email us at <a href="mailto:{6}">{6}</a> and we’ll try to find a solution together.\ | ||
<br/><br/>\ | ||
Regards,<br/>\ | ||
Tolgee |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { styled, Tooltip, tooltipClasses, TooltipProps } from '@mui/material'; | ||
|
||
export const FullWidthTooltip = styled( | ||
({ className, ...props }: TooltipProps) => ( | ||
<Tooltip {...props} classes={{ popper: className }} /> | ||
) | ||
)({ | ||
[`& .${tooltipClasses.tooltip}`]: { | ||
maxWidth: 'none', | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,14 @@ Yup.setLocale({ | |
/> | ||
), | ||
}, | ||
number: { | ||
min: ({ min }) => ( | ||
<T | ||
keyName="validation_schema_number_min_message" | ||
params={{ min: min.toString() }} | ||
/> | ||
), | ||
}, | ||
}); | ||
|
||
export class Validation { | ||
|
@@ -521,6 +529,12 @@ export class Validation { | |
.required() | ||
.matches(/^#[0-9A-F]{6}$/i, t('validation_invalid_hex_color')), | ||
}); | ||
|
||
static readonly PLAN_MIRATION_FORM = () => | ||
Yup.object().shape({ | ||
monthlyOffsetDays: Yup.number().required().min(0), | ||
yearlyOffsetDays: Yup.number().required().min(0), | ||
}); | ||
Comment on lines
+533
to
+537
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainFix typo in constant name: PLAN_MIRATION_FORM → PLAN_MIGRATION_FORM. The constant is misspelled as Apply this diff to fix the typo: - static readonly PLAN_MIRATION_FORM = () =>
+ static readonly PLAN_MIGRATION_FORM = () =>
Yup.object().shape({
monthlyOffsetDays: Yup.number().required().min(0),
yearlyOffsetDays: Yup.number().required().min(0),
}); Then update all references across the codebase: 🏁 Script executed: #!/bin/bash
# Description: Find all references to the misspelled constant name
rg -n "PLAN_MIRATION_FORM" --type ts --type tsx Length of output: 27 🏁 Script executed: #!/bin/bash
# Search for references to the misspelled constant in all .ts and .tsx files
rg -n "PLAN_MIRATION_FORM" -g '*.ts*' Length of output: 252 Fix typo in constant name: PLAN_MIRATION_FORM → PLAN_MIGRATION_FORM --- a/webapp/src/constants/GlobalValidationSchema.tsx
@@ -533,7 +533,7 @@
- static readonly PLAN_MIRATION_FORM = () =>
+ static readonly PLAN_MIGRATION_FORM = () => --- a/webapp/src/ee/billing/administration/subscriptionPlans/components/migration/PlanMigrationForm.tsx
@@ -83,7 +83,7 @@
- validationSchema={Validation.PLAN_MIRATION_FORM}
+ validationSchema={Validation.PLAN_MIGRATION_FORM} Then verify no other references remain: rg -n "PLAN_MIRATION_FORM" -g '*.ts*' 🤖 Prompt for AI Agents
|
||
} | ||
|
||
let GLOBAL_VALIDATION_DEBOUNCE_TIMER: any = undefined; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
CreatePlanMigrationFormData, | ||
PlanMigrationForm, | ||
} from './PlanMigrationForm'; | ||
import { PlanType } from 'tg.ee.module/billing/administration/subscriptionPlans/components/migration/types'; | ||
|
||
const emptyDefaultValues: CreatePlanMigrationFormData = { | ||
enabled: true, | ||
sourcePlanId: 0, | ||
targetPlanId: 0, | ||
monthlyOffsetDays: 14, | ||
yearlyOffsetDays: 30, | ||
}; | ||
|
||
type Props = { | ||
onSubmit: (values: CreatePlanMigrationFormData) => void; | ||
loading?: boolean; | ||
planType?: PlanType; | ||
}; | ||
|
||
export const CreatePlanMigrationForm: React.FC<Props> = (props) => { | ||
return ( | ||
<PlanMigrationForm<CreatePlanMigrationFormData> | ||
defaultValues={emptyDefaultValues} | ||
{...props} | ||
/> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { PlanMigrationForm, PlanMigrationFormData } from './PlanMigrationForm'; | ||
import { components } from 'tg.service/billingApiSchema.generated'; | ||
import { PlanType } from 'tg.ee.module/billing/administration/subscriptionPlans/components/migration/types'; | ||
|
||
type CloudPlanMigrationModel = components['schemas']['CloudPlanMigrationModel']; | ||
type SelfHostedEePlanMigrationModel = | ||
components['schemas']['AdministrationSelfHostedEePlanMigrationModel']; | ||
|
||
type Props = { | ||
onSubmit: (values: PlanMigrationFormData) => void; | ||
loading?: boolean; | ||
onDelete?: (id: number) => void; | ||
migration: CloudPlanMigrationModel | SelfHostedEePlanMigrationModel; | ||
planType?: PlanType; | ||
}; | ||
|
||
export const EditPlanMigrationForm: React.FC<Props> = (props) => { | ||
const { migration } = props; | ||
const initialValues: PlanMigrationFormData = { | ||
enabled: migration.enabled, | ||
sourcePlanFree: migration.sourcePlan.free, | ||
targetPlanId: migration.targetPlan.id, | ||
monthlyOffsetDays: migration.monthlyOffsetDays, | ||
yearlyOffsetDays: migration.yearlyOffsetDays, | ||
}; | ||
return ( | ||
<PlanMigrationForm<PlanMigrationFormData> | ||
defaultValues={initialValues} | ||
{...props} | ||
/> | ||
); | ||
}; |
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.
Why not simply
date
instead of(forcedDate ?: date)
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.
true, my bad