Skip to content

Commit

Permalink
fix(platform): Optimized user update request body (#605)
Browse files Browse the repository at this point in the history
Co-authored-by: rajdip-b <[email protected]>
  • Loading branch information
omarNaifer12 and rajdip-b authored Jan 9, 2025
1 parent d3432c5 commit ee1adf0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion apps/api/src/user/service/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { generateOtp, limitMaxItemsPerPage } from '@/common/util'
import { createUser } from '@/common/user'
import { CacheService } from '@/cache/cache.service'
import { UserWithWorkspace } from '../user.types'
import { UpdateSelfRequest } from '@keyshade/schema'

@Injectable()
export class UserService {
Expand Down Expand Up @@ -44,7 +45,7 @@ export class UserService {
}

async updateSelf(user: UserWithWorkspace, dto: UpdateUserDto) {
const data = {
const data: UpdateSelfRequest = {
name: dto?.name,
profilePictureUrl: dto?.profilePictureUrl,
isOnboardingFinished: dto.isOnboardingFinished
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/public/svg/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ThreeDotOptionSVG from './3dotOption.svg'
import AddSVG from './add.svg'
import LoadingSVG from './loading.svg'
import MessageSVG from './message.svg'
import VectorSVG from './vector.svg'
import VectorSVG from './Vector.svg'
import ErrorSVG from './Error.svg'

export {
Expand Down
10 changes: 6 additions & 4 deletions apps/platform/src/app/(main)/settings/@profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ function ProfilePage(): React.JSX.Element {
profilePictureUrl: ''
})
const [isModified, setIsModified] = useState<boolean>(false)
const [email, setEmail] = useState<string>('')

const updateSelf = useCallback(async () => {
try {
await ControllerInstance.getInstance().userController.updateSelf(
{
name: userData.name,
email: userData.email
email: userData.email === email ? null : email
},
{}
)
Expand All @@ -31,7 +32,7 @@ function ProfilePage(): React.JSX.Element {
console.error(error)
}
setIsModified(false)
}, [userData])
}, [userData, email])

useEffect(() => {
ControllerInstance.getInstance()
Expand All @@ -43,6 +44,7 @@ function ProfilePage(): React.JSX.Element {
name: data.name,
profilePictureUrl: data.profilePictureUrl || ''
})
setEmail(data.email)
setIsLoading(false)
} else {
// eslint-disable-next-line no-console -- we need to log the error
Expand Down Expand Up @@ -104,10 +106,10 @@ function ProfilePage(): React.JSX.Element {
disabled
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
// setIsModified(true)
// setUserData((prev) => ({ ...prev, email: e.target.value }))
// setEmail(e.target.value)
// }}
placeholder="email"
value={userData.email}
value={email}
/>
)}
</div>
Expand Down

0 comments on commit ee1adf0

Please sign in to comment.