-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
fix: your name translation #14863
fix: your name translation #14863
Conversation
@smitgol is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link. |
Graphite Automations"Add community label" took an action on this PR • (05/02/24)1 label was added to this PR based on Keith Williams's automation. "Add consumer team as reviewer" took an action on this PR • (05/02/24)1 reviewer was added to this PR based on Keith Williams's automation. |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
This PR is being marked as stale due to inactivity. |
I'd like to share another perspective. However, the correct label is already translated in:
My suggestion is to pass it down to the name component factory instead of translating it again: https://github.com/malbq/cal.com/commit/814fa953ae4ea0aa382e0f235647b5fdb28622cb |
b5cdc32
to
8d14d6d
Compare
/** | ||
* Get's the field's variantsConfig and if not available, then it will get the default variantsConfig from the fieldTypesConfigMap | ||
*/ | ||
export const getVariantsConfig = (field: Pick<z.infer<typeof fieldSchema>, "variantsConfig" | "type">) => { | ||
const fieldVariantsConfig = field.variantsConfig; | ||
const fieldTypeConfig = fieldTypesConfigMap[field.type as keyof typeof fieldTypesConfigMap]; | ||
|
||
if (!fieldTypeConfig) throw new Error(`Invalid field.type ${field.type}}`); | ||
|
||
const defaultVariantsConfig = fieldTypeConfig?.variantsConfig?.defaultValue; | ||
const variantsConfig = fieldVariantsConfig || defaultVariantsConfig; | ||
|
||
if (fieldTypeConfig.propsType === "variants" && !variantsConfig) { | ||
throw new Error(`propsType variants must have variantsConfig`); | ||
} | ||
return variantsConfig; | ||
}; |
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.
Refactored out in a separate module variantsConfig
export const getConfig = (field: Pick<z.infer<typeof fieldSchema>, "variantsConfig" | "type">) => { | ||
const fieldVariantsConfig = field.variantsConfig; | ||
const fieldTypeConfig = fieldTypesConfigMap[field.type as keyof typeof fieldTypesConfigMap]; | ||
|
||
if (!fieldTypeConfig) throw new Error(`Invalid field.type ${field.type}}`); | ||
|
||
const defaultVariantsConfig = fieldTypeConfig?.variantsConfig?.defaultValue; | ||
const variantsConfig = fieldVariantsConfig || defaultVariantsConfig; | ||
|
||
if (fieldTypeConfig.propsType === "variants" && !variantsConfig) { | ||
throw new Error(`propsType variants must have variantsConfig`); | ||
} | ||
return variantsConfig; | ||
}; |
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.
Copied from utils.ts
…. Allows the code to stay DRY
8d14d6d
to
54fe5f8
Compare
@@ -333,8 +334,8 @@ export const ComponentForField = ({ | |||
} | |||
|
|||
if (componentConfig.propsType === "variants") { | |||
const variantsConfig = getVariantsConfig(field); | |||
if (!variantsConfig) { | |||
const translatedVariantsConfig = getTranslatedVariantsConfig(field, t); |
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.
Passing the translatedVariantsConfig directly so that Components don't need to do the translation.
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.
@smitgol Thanks for the PR.
I was testing out the PR and found a better approach to fix it. Could you please check the changes out and see if they are acceptable to you
* your name translation fixed * do translation outside Components as that is needed by all components. Allows the code to stay DRY --------- Co-authored-by: Hariom <[email protected]>
What does this PR do?
Fixes #14734
Type of change
Mandatory Tasks