-
Notifications
You must be signed in to change notification settings - Fork 3.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
Nv 2996 reusable push preview component #5178
Nv 2996 reusable push preview component #5178
Conversation
@@ -119,6 +119,7 @@ export class ContentTemplatesController { | |||
public previewPush( | |||
@UserSession() user: IJwtPayload, | |||
@Body('content') content: string, | |||
@Body('title') title: 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.
Added title parsing support for push previews
</Stack> | ||
</When> | ||
</Group> | ||
<ContentAndOVerlayWrapperStyled onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}> |
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.
Added this to have better blur effect on hover
@@ -75,14 +76,14 @@ export function ChatPreview() { | |||
|
|||
return ( | |||
<div> | |||
<div> | |||
<Flex> |
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.
Forces the LocaleSelect to not take the Full-width of the available space
* combining title and content to get locales based upon variables in both title and content | ||
* The api is not concerned about the content type, it will parse the given string and return the locales | ||
*/ | ||
const combinedContent = `${previewData.current.title} ${previewData.current.content}`; | ||
getLocalesFromContent({ | ||
content: combinedContent, | ||
}); |
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.
The API parses any given string and returns the locales of the translation groups variable used in the given string. So it is okay to combine the title
and content
string into one to pass it to the API.
|
||
const templateContentError = useStepFormCombinedErrors(); |
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.
updated it to use the combined errors hooks
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.
Added this hook to get combined errors.
For example, when "content is missing" and "title is missing"
Instead of showing only one of them or both in different lines.
This hook will combine the error to Content and Title are missing
. if single error, then it just returns the single error like Content is missing
.
We already use this behaviour in our Workflow nodes error. this just adds a reusable hook to get those formatted errors
export function mapStepErrors(stepErrors) { | ||
if (stepErrors) { | ||
const keys = Object.keys(stepErrors); | ||
|
||
return keys.map((key) => stepErrors[key]?.message); | ||
} | ||
|
||
return []; | ||
} | ||
|
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.
moved it into a separate function to use it in the hook
|
||
if (command.title) { | ||
title = await this.compileStepTemplate(command.title, payload); | ||
} |
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.
Handles push title parsing
}; | ||
|
||
return ( | ||
<ContentAndOVerlayWrapperStyled onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}> |
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.
Added this to have better blur effect on hover
@@ -75,14 +76,14 @@ export function ChatPreview() { | |||
|
|||
return ( | |||
<div> | |||
<div> | |||
<Flex> |
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.
Forces the LocaleSelect to not take the Full-width of the available space
/* | ||
* combining title and content to get locales based upon variables in both title and content | ||
* The api is not concerned about the content type, it will parse the given string and return the locales | ||
*/ | ||
const combinedContent = `${previewData.current.title} ${previewData.current.content}`; | ||
getLocalesFromContent({ | ||
content: combinedContent, | ||
}); | ||
} |
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.
The API parses any given string and returns the locales of the translation groups variable used in the given string. So it is okay to combine the title and content string into one to pass it to the API.
@@ -33,7 +34,8 @@ const LocaleSelectStyled = styled(LocaleSelect)` | |||
export const SmsPreview = () => { | |||
const { control } = useFormContext<IForm>(); | |||
const path = useStepFormPath(); | |||
const error = useStepFormErrors(); | |||
|
|||
const templateContentError = useStepFormCombinedErrors(); |
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.
updated it to use the combined errors hooks
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.
Added this hook to get combined errors.
For example, when "content is missing" and "title is missing"
Instead of showing only one of them or both in different lines.
This hook will combine the error to Content and Title are missing. if single error, then it just returns the single error like Content is missing.
We already use this behaviour in our Workflow nodes error. this just adds a reusable hook to get those formatted errors
…h-preview-component
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.
hey Biswa, can we please run the images through: https://squoosh.app/ and generate webp instead? we will save a lot in size
https://caniuse.com/?search=webp
apps/web/src/components/workflow/preview/common/phone-simulator/MobileSimulator.tsx
Outdated
Show resolved
Hide resolved
const path = useStepFormPath(); | ||
const errorMsg = useStepFormCombinedErrors(); | ||
|
||
const [selectedLocale, setSelectedLocale] = useState<string | undefined>(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.
please take a look at this hook useTemplateLocales
apps/web/src/components/workflow/preview/push/Content.styles.ts
Outdated
Show resolved
Hide resolved
…to nv-2996-reusable-push-preview-component
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.
looks good to me! 🔥
…-preview-component
What change does this PR introduce?
Why was this change needed?
Other information (Screenshots)
Screen.Recording.2024-02-12.at.12.47.21.PM.mov