-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Feat #63 accounts language email #5171
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
Conversation
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
β¦eter Signed-off-by: Jaka Maver <[email protected]>
β¦meter Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
β¦include language Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
β¦ing language Signed-off-by: Jaka Maver <[email protected]>
β¦before setting it in orders Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
β¦anguages Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
β¦account shop Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
Signed-off-by: Jaka Maver <[email protected]>
β¦or languages Signed-off-by: Jaka Maver <[email protected]>
aldeed
left a comment
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.
Good work here. I haven't tested yet, but I reviewed the code and the approach seems solid. There are a few changes necessary for style reasons, but we should be able to test and merge this after that.
| """ | ||
| shopId: String! | ||
|
|
||
| language: String |
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.
All fields must have a description and should be alphabetized
| "The date and time at which this order was last updated" | ||
| updatedAt: DateTime! | ||
|
|
||
| language: String |
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.
All fields must have a description and should be alphabetized
| @@ -1,4 +1,5 @@ | |||
| import SimpleSchema from "simpl-schema"; | |||
| import R from "ramda"; | |||
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.
Single character variables are not allowed by Reaction style rules. I'd recommend just using the standard array .find in this case, though.
|
|
||
| // set to undefined value so order language will not be set | ||
| if (!shopLanguage) { | ||
| language = undefined; |
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.
Throwing a helpful error would be better so they aren't confused why the language they specified isn't set.
| * @summary Sets users profile language | ||
| * @returns {Object} Account document | ||
| */ | ||
| export default function setProfileLanguage(languageCode, accountId) { |
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.
Move this to a non-Meteor mutation function in /imports/plugins/core/accounts/server/no-meteor/mutations/setProfileLanguage.js and call it as const updatedAccount = await context.mutations.setProfileLanguage(context, languageCode, dbAccountId); in the resolver. Using callMeteorMethod is deprecated and soon going away.
| optional: true | ||
| }, | ||
| "history.$": History, | ||
| "language": { |
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.
I think this should be more specifically named, maybe ordererPreferredLanguage?
|
Sending the current language per order seems to be a resonable solution to me. In a typical scenario I'd expect the storefront to offer multiple languages - The currently used language would then be part of the order, regardless if it was placed anonymously or by an existing account. Storing a language field on the account makes sense to me aswell, although I wouldn't treat that as specific for emails, but also to set defaults for whatever i18n provider is used in the frontend, if that account language might differ from the one requested by the browser. First I was unsure about the part where the account language is used to determine the email language, as we can send it only with the order, regardless if we have an account or anonymous users. The last things missing for me:
We could make the storefront determine the language and send it over to the idp register form as part of the url query. The Login IDP shouldn't check language on its own, as the user might have set a different language in the storefront than the browser default.
One option would be to just to give the user the choice like a dropdown for the current display language. Now every time the user selects a language here that differs from the account language a dialog could be shown asking if the default should be changed. The profile page could still have a seperate language preference field regardless of that, or do the same thing vice versa and ask if the current display language should be changed accordingly to avoid any confusion for users. |
|
@janus-reith Reaction 1.x had such a language select which would set It would be nice to eventually tie it in with IDP and new account registration, but that can be done later, and it's a separate concern since the goal is to eventually make IDP+auth a third-party component. |
|
@jm18457 Will you have time to address the comments? |
I will be busy for a certain period of time right now, but I will see if I can address them over the weekend or next weekend. |
|
It would probably be easier to redo this PR from scratch with the new meteor-free |
|
Hello, I will close this pull request and create a new pull request, since updated changes are in different repository. |
Resolves #63
Impact: minor
Type: feature
Issue
Currently all emails are sent based on language (field in mongodb) of the shop account belongs to. This means users cannot specify which language emails they want to receive. Similar for anonymous purchases.
Solution
With this solution:
Overview
If user / order does not have specified account it still looks at shop language to find template.
Breaking changes
There are no breaking changes.
Testing
TBD