-
Notifications
You must be signed in to change notification settings - Fork 2
PIN-7318: Added NotificationConfig page and its components #1352
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: dev
Are you sure you want to change the base?
Conversation
|
6df6c0c to
aba7bec
Compare
66554f9 to
126fc62
Compare
24bf3d0 to
07a6b9a
Compare
|
sandrotaje
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.
It looks good to me, If I'm not wrong this PR is missing the link to the configuration page but I think it will be included in another PR.
|
| | UserNotificationConfig['emailNotificationPreference'] | ||
| | UserNotificationConfig['inAppNotificationPreference'] | ||
| ) => { | ||
| const unnecessaryKeys = ['preferenceChoice'] |
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.
Is there any way to type this?
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.
!! Too many as for my taste, can you try to remove it and make the typing work without them?
| const isEnabledShowPreferencesSwitch = (): boolean => { | ||
| return match(type) | ||
| .with('email', () => { | ||
| return preferenceChoice === 'ENABLED' | ||
| }) | ||
| .with('inApp', () => { | ||
| return !!preferenceChoice | ||
| }) | ||
| .exhaustive() | ||
| } |
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.
MINOR: any reason why this is a function and not directly a computer property?
| return () => { | ||
| subscription.unsubscribe() | ||
| } | ||
| }, [formMethods, formMethods.watch, formMethods.formState.isDirty, debouncedUpdate]) |
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 formMethods.formState.isDirty dependency in this useEffect makes me a bit worried.
What's the reason it is there? It's important for a specific behaviour?
Can you remove it? If it is important I would at least document it in a comment
| type: NotificationConfigType | ||
| } | ||
|
|
||
| export const NotificationConfigUserTab: React.FC<NotificationConfigUserTabProps> = ({ |
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.
This component does TOO much.
I suggest at least to move all this form logic in a useNotificationConfigForm
| const SectionIcon = notificationSchema[sectionName].icon | ||
|
|
||
| return ( | ||
| <Box key={sectionName} data-testid={`config-section-${sectionName}`} sx={{ mb: 3 }}> |
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.
Can you move out this component?
| const notificationSchema: NotificationConfigSchema = match(type) | ||
| .with('inApp', () => { | ||
| return notificationConfigSchema | ||
| }) | ||
| .with('email', () => { | ||
| return notificationConfigSchema | ||
| }) | ||
| .exhaustive() |
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.
Is this for a future implementation when the inApp and email have their own scema?
| import { ConsumerIcon, ProviderIcon, MyTenantIcon } from '@/icons' | ||
| import CodeIcon from '@mui/icons-material/Code' | ||
|
|
||
| export function useNotificationConfigHook(type: NotificationConfigType) { |
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 Hook suffix communicates nothing, can you find a better one? What about useGetNotificationConfigSchema?
| const { isAdmin } = AuthHooks.useJwt() | ||
|
|
||
| const { data: user } = TenantHooks.useGetActiveUserParty() | ||
| const { data: tenantEmailNotifictionConfigs } = useQuery({ |
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.
typo
| const { data: tenantEmailNotifictionConfigs } = useQuery({ | |
| const { data: tenantEmailNotificationConfigs } = useQuery({ |
| const { data: tenantEmailNotifictionConfigs } = useQuery({ | ||
| ...NotificationQueries.getTenantNotificationConfigs(), | ||
| }) |
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.
No need to spread when you have nothing to add, it's a waste of performance
| const { data: tenantEmailNotifictionConfigs } = useQuery({ | |
| ...NotificationQueries.getTenantNotificationConfigs(), | |
| }) | |
| const { data: tenantEmailNotifictionConfigs } = useQuery(NotificationQueries.getTenantNotificationConfigs()) |


No description provided.