Skip to content

Commit

Permalink
add EditProfilePhoto type
Browse files Browse the repository at this point in the history
  • Loading branch information
luiqor committed Nov 23, 2024
1 parent b0694e3 commit f809939
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/pages/edit-profile/EditProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ButtonVariantEnum,
SizeEnum,
UpdatedPhoto,
EditProfilePhoto,
UpdateUserParams,
UserProfileTabsEnum,
UserRole
Expand Down Expand Up @@ -90,14 +91,14 @@ const EditProfile = () => {
return JSON.stringify(initialData) !== JSON.stringify(currentData)
}

const isUpdatedPhoto = (photo: string | null | UpdatedPhoto): boolean => {
const isUpdatedPhoto = (photo: EditProfilePhoto): boolean => {
return photo !== null && typeof photo === 'object' && 'name' in photo
}

const hasPhotoChanges = useCallback(
(
initialPhoto: string | null | UpdatedPhoto,
currentPhoto: string | null | UpdatedPhoto
initialPhoto: EditProfilePhoto,
currentPhoto: EditProfilePhoto
): boolean => {
if (initialPhoto !== '' && currentPhoto === '') {
return true
Expand Down
4 changes: 2 additions & 2 deletions src/redux/features/editProfileSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
NotificationSettings,
ProfessionalBlock,
SubjectNameInterface,
UpdatedPhoto,
EditProfilePhoto,
UpdateUserParams,
UserMainSubject,
UserMainSubjectFieldValues,
Expand All @@ -31,7 +31,7 @@ export interface EditProfileState {
professionalSummary?: string
nativeLanguage: string | null
videoLink: DataByRole<string>
photo: UpdatedPhoto | string | null
photo: EditProfilePhoto
categories: DataByRole<UserMainSubject[]>
professionalBlock: ProfessionalBlock
notificationSettings: NotificationSettings
Expand Down
7 changes: 3 additions & 4 deletions src/types/edit-profile/interfaces/editProfile.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {
CategoryInterface,
SubjectNameInterface,
UpdatedPhoto
SubjectNameInterface
} from '~/types/common/common.index'
import { UserResponse, VideoUserRole } from '~/types'
import { EditProfilePhoto, UserResponse, VideoUserRole } from '~/types'

export interface EditProfileForm
extends Pick<UserResponse, 'firstName' | 'lastName'> {
Expand All @@ -12,7 +11,7 @@ export interface EditProfileForm
professionalSummary: string
nativeLanguage: string | null
videoLink: string
photo: UpdatedPhoto | string | null
photo: EditProfilePhoto
}

export interface EditProfileFormSubmitData
Expand Down
5 changes: 4 additions & 1 deletion src/types/edit-profile/types/editProfile.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
CategoryNameInterface,
SubjectNameInterface,
UserMainSubject
UserMainSubject,
UpdatedPhoto
} from '~/types'

export type OpenProfessionalCategoryModalHandler = (
Expand All @@ -13,3 +14,5 @@ export type UserMainSubjectFieldValues = string &
boolean &
CategoryNameInterface &
SubjectNameInterface[]

export type EditProfilePhoto = UpdatedPhoto | string | null
4 changes: 2 additions & 2 deletions src/types/user/user-interfaces/user.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RequestParams,
Faq,
DataByRole,
UpdatedPhoto,
EditProfilePhoto,
UpdateFields,
UserStatusEnum,
UserMainSubject,
Expand Down Expand Up @@ -78,7 +78,7 @@ export interface UpdateUserParams
extends Partial<Pick<UserResponse, UpdateFields>> {
mainSubjects?: DataByRole<UserMainSubject[]>
videoLink?: string
photo?: UpdatedPhoto | string | null
photo?: EditProfilePhoto
}

export interface LoginParams {
Expand Down

0 comments on commit f809939

Please sign in to comment.