-
Notifications
You must be signed in to change notification settings - Fork 2
BA-1809 [FE] Simplify CurrentProfileProvider #140
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
Changes from all commits
fc564a8
a65a0d1
3bb3b2f
50d7436
59970ad
2465eec
3a11154
b1e7d29
881b4d4
25338fb
b6b77d0
2ec8f7e
ee4bc9c
025aae0
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,23 +1,22 @@ | ||||||||||||||||||
| import { MinimalProfile } from '@baseapp-frontend/utils' | ||||||||||||||||||
|
|
||||||||||||||||||
| export interface User { | ||||||||||||||||||
| id: number | ||||||||||||||||||
| email: string | ||||||||||||||||||
| isEmailVerified: boolean | ||||||||||||||||||
| newEmail: string | ||||||||||||||||||
| isNewEmailConfirmed: boolean | ||||||||||||||||||
| referralCode: string | ||||||||||||||||||
| avatar: { | ||||||||||||||||||
| fullSize: string | ||||||||||||||||||
| small: string | ||||||||||||||||||
| } | ||||||||||||||||||
| firstName: string | ||||||||||||||||||
| lastName: string | ||||||||||||||||||
| profile: MinimalProfile | ||||||||||||||||||
| phoneNumber: string | ||||||||||||||||||
| preferredLanguage: string | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| export interface UserUpdateParams<TUser extends Partial<User>> { | ||||||||||||||||||
| userId: TUser['id'] | ||||||||||||||||||
| data: Partial<Omit<TUser, 'avatar' | 'id'>> & { | ||||||||||||||||||
| data: Partial<Omit<TUser, 'id'>> & { | ||||||||||||||||||
| avatar?: File | string | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+19
to
21
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. Resolve inconsistency between User and UserUpdateParams interfaces. The export interface UserUpdateParams<TUser extends Partial<User>> {
userId: TUser['id']
data: Partial<Omit<TUser, 'id'>> & {
- avatar?: File | string
+ profile?: Partial<MinimalProfile> & {
+ image?: File | string
+ }
}
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||
| } | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,11 @@ import { User, UserApi } from '@baseapp-frontend/authentication' | |
| import { createTestEnvironment } from '@baseapp-frontend/graphql' | ||
|
|
||
| import { Meta, StoryObj } from '@storybook/react' | ||
| import Cookies from 'js-cookie' | ||
|
|
||
| import AccountPopover from '..' | ||
| import { withTokenSetup } from '../../../../../../.storybook/decorators' | ||
| import { CURRENT_PROFILE_STORAGE_KEY } from '../../../../../profiles/context/CurrentProfileProvider/constants' | ||
| import { PROFILE_KEY } from '../../../../../profiles/useCurrentProfile/constants' | ||
|
Collaborator
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. wrong import |
||
| import { AccountPopoverProps } from '../types' | ||
| import { mockResolvers } from './mockResolvers' | ||
|
|
||
|
|
@@ -31,7 +32,15 @@ export default { | |
| decorators: [ | ||
| withTokenSetup, | ||
| (Story, context) => { | ||
| localStorage.removeItem(CURRENT_PROFILE_STORAGE_KEY) | ||
| Cookies.set( | ||
| PROFILE_KEY, | ||
| JSON.stringify({ | ||
| id: '1234', | ||
| name: 'test', | ||
| image: null, | ||
| url: { path: 'path' }, | ||
| }), | ||
| ) | ||
|
Comment on lines
+35
to
+43
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. 💡 Codebase verification Mock profile structure needs to be updated to match MinimalProfile type The mock profile structure in the story doesn't match the
Update the mock data to match the type: Cookies.set(
PROFILE_KEY,
JSON.stringify({
id: '1234',
name: 'test',
image: null,
- url: { path: 'path' },
+ urlPath: '/path',
}),
COOKIE_OPTIONS
)🔗 Analysis chainConsider enhancing cookie security and mock data management While the implementation works, consider these improvements:
Consider updating the code like this: + import { MOCK_PROFILE_DATA } from './mockData'
+ const COOKIE_OPTIONS = {
+ secure: true,
+ sameSite: 'strict',
+ path: '/'
+ }
Cookies.set(
PROFILE_KEY,
- JSON.stringify({
- id: '1234',
- name: 'test',
- image: null,
- url: { path: 'path' },
- }),
+ JSON.stringify(MOCK_PROFILE_DATA),
+ COOKIE_OPTIONS
)Let's verify the profile structure matches the type definition: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for MinimalProfile type definition
ast-grep --pattern 'type MinimalProfile = {
$$$
}'
Length of output: 374 |
||
|
|
||
| const { queueOperationResolver } = context.parameters.relayMockEnvironment as ReturnType< | ||
| typeof createTestEnvironment | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import type { MinimalProfile } from '@baseapp-frontend/authentication' | ||
| import type { AvatarWithPlaceholderProps } from '@baseapp-frontend/design-system' | ||
|
|
||
| import { MenuItemProps } from '@mui/material' | ||
|
|
@@ -10,7 +11,7 @@ import type { | |
| export interface ProfileMenuItemProps { | ||
| profileRef: ProfileItemFragment$key | ||
| onProfileChange: (newProfile: ProfileItemFragment$data) => void | ||
| currentProfile?: ProfileItemFragment$data | ||
| currentProfile?: MinimalProfile | null | ||
|
Collaborator
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. let's not pass |
||
| avatarProps?: AvatarWithPlaceholderProps | ||
| width?: number | ||
| height?: number | ||
|
|
||
This file was deleted.
This file was deleted.
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.
💡 Codebase verification
Based on the search results, I can now generate the final response:
Breaking change requires GraphQL schema updates and component modifications
The transition from
avatartoprofile.imageaffects GraphQL-related code:profile.imageinstead ofavatarpackages/components/__generated__/need to be regeneratedprofilefield definitions in placePlease ensure:
user.avatar🔗 Analysis chain
Verify the impact of this breaking change across the application.
The transition from direct
avatarproperty toprofile.imageis a significant architectural change that affects how profile data is accessed throughout the application.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 255
Script:
Length of output: 383
Script:
Length of output: 77631
Script:
Length of output: 2652