-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: unify avatar and personal info editing into 1 form * feat: remove commented code * feat: remove useless dev deps in api * refactor: change css naming duration
- Loading branch information
Showing
30 changed files
with
599 additions
and
902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { cloudStorageService } from 'services'; | ||
|
||
import { BackendFile, User } from 'types'; | ||
|
||
export const removeAvatar = async (user: User) => { | ||
if (user.avatarUrl) { | ||
const fileKey = cloudStorageService.getFileKey(user.avatarUrl); | ||
|
||
await cloudStorageService.deleteObject(fileKey); | ||
} | ||
}; | ||
|
||
export const uploadAvatar = async (user: User, file: BackendFile, customFileName?: string): Promise<string> => { | ||
await removeAvatar(user); | ||
|
||
const fileName = customFileName || `${user._id}-${Date.now()}-${file.originalFilename}`; | ||
|
||
const { location: avatarUrl } = await cloudStorageService.uploadPublic(`avatars/${fileName}`, file); | ||
|
||
if (!avatarUrl) { | ||
throw new Error("An error occurred while uploading the user's avatar"); | ||
} | ||
|
||
return avatarUrl; | ||
}; |
30 changes: 0 additions & 30 deletions
30
template/apps/api/src/resources/account/actions/remove-avatar.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
template/apps/api/src/resources/account/actions/upload-avatar.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import accountRoutes from './account.routes'; | ||
import * as accountUtils from './account.utils'; | ||
|
||
export { accountRoutes }; | ||
export { accountRoutes, accountUtils }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
template/apps/web/src/pages/profile/components/AvatarUpload/index.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
.root { | ||
--dropzone-size: 100px; | ||
--dropzone-hover-color: var(--mantine-color-gray-5); | ||
|
||
padding: 0; | ||
background-color: transparent; | ||
|
||
border: none; | ||
border-radius: 50%; | ||
|
||
@mixin hover { | ||
.addIcon { | ||
color: var(--dropzone-hover-color); | ||
} | ||
|
||
.browseButton { | ||
border-color: var(--dropzone-hover-color); | ||
} | ||
|
||
.editOverlay { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
|
||
.browseButton { | ||
width: var(--dropzone-size); | ||
height: var(--dropzone-size); | ||
|
||
border: 1px dashed var(--mantine-primary-color-filled); | ||
border-radius: 50%; | ||
|
||
cursor: pointer; | ||
overflow: hidden; | ||
transition: all 0.2s ease-in-out; | ||
} | ||
|
||
.imageExists { | ||
border-color: transparent !important; | ||
} | ||
|
||
.addIcon { | ||
color: var(--mantine-primary-color-filled); | ||
|
||
transition: all 0.2s ease-in-out; | ||
} | ||
|
||
.pencilIcon { | ||
color: var(--dropzone-hover-color); | ||
|
||
transition: all 0.2s ease-in-out; | ||
} | ||
|
||
.editOverlay { | ||
border-radius: 50%; | ||
background-color: alpha(var(--mantine-color-black), 0.5); | ||
|
||
opacity: 0; | ||
transition: all 0.3s ease-in-out; | ||
} |
Oops, something went wrong.