Skip to content

Content creator - profile picture functionality added #143

Open
RasmusJensen1 wants to merge 115 commits intodevfrom
us-0092-update-profile-picture-content-creator
Open

Content creator - profile picture functionality added #143
RasmusJensen1 wants to merge 115 commits intodevfrom
us-0092-update-profile-picture-content-creator

Conversation

@RasmusJensen1
Copy link
Copy Markdown
Contributor

@RasmusJensen1 RasmusJensen1 commented Dec 3, 2025

Descrption

Added profile picture upload, update, and delete functionality for content creators.

Summary of Changes

Backend Manual Changes

schema.json

  • Added new field: profilePicture
    • Type: Media
    • Single image
    • Optional

Frontend Manual Changes

Profile.tsx

  • Added handleProfilePictureUpload()

    • Validates file type and max size (5MB) (Can be changed, but i think it is a pretty appropriate size)
  • Added handleProfilePictureDelete()

    • Deletes existing image
  • Integrated React Query for caching + automatic refetching

  • Updated API calls to include the profile picture field

PersonalInformation.tsx

  • Displays profile picture or fallback initials

  • Added UI actions:

    • Alterar foto de perfil
    • Deletar foto
  • Implemented getImageUrl()


Auto-Generated Files (Strapi)

These files are generated automatically and may include diffs unrelated to functional changes due to it being autogenerated.

  • strapi-spec.json
  • contentTypes.d.ts
  • types.gen.ts
  • sdk.gen.ts
  • zod.gen.ts

Generated by:

  • Strapi documentation plugin
  • npm run generate-strapi-client

Includes:

  • Updated TypeScript types
  • SDK functions
  • Zod schemas

Acceptence criteria

  • Content creator can upload a profile picture
  • Content creator can update their profile picture
  • Content creator can delete their profile picture, after which the default picture will be shown

Please make sure to test the functionality when reviewing, and if there is any questions that makes more sense to take over a Discord call, don't hesitate to give us a call ⚡

A front-end successor PBI will be made so it matches the Figma.

Co contributor: @OliverKjaer

DandingB and others added 30 commits October 14, 2025 19:19
* start

* save

* fixed

* fix
…w category (#31)

* multiselect new entries

can now add new entries in multiselects with a popup modal and error messages

* translation, button fix, course info multiselect

* Fix categories load, category creation. Clean error & loading states

* Translation fix

* feat: (web) file upload to course (#29)

* start

* save

* fixed

* fix

---------

Co-authored-by: Alfred <47451379+Alfenstein8@users.noreply.github.com>
Co-authored-by: Smidtty <148750415+Smidtty@users.noreply.github.com>
Co-authored-by: Albert <148211219+Alb9ert@users.noreply.github.com>
* Add useAuth hook, sync with language and preferences for usePaginatedData.

* Update web/src/shared/hooks/use-local-storage.ts

Co-authored-by: Albert <148211219+Alb9ert@users.noreply.github.com>

* Update web/src/shared/hooks/use-isomorphic-layout-effect.tsx

Co-authored-by: Albert <148211219+Alb9ert@users.noreply.github.com>

* Update web/src/shared/hooks/use-event-callback.tsx

Co-authored-by: Albert <148211219+Alb9ert@users.noreply.github.com>

---------

Co-authored-by: Alfred <47451379+Alfenstein8@users.noreply.github.com>
Co-authored-by: Albert <148211219+Alb9ert@users.noreply.github.com>
Added translation to rest of the english words
* start

* save

* fixed

* fix
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 7.1.9 to 7.1.11.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v7.1.11/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 7.1.11
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…59)

* Turborepo, npm scripts & docker

* Docs

* Update contributions docs

* Forgot to add Web to compose. Fix build errors too.

* Add and update docker docs.

* Check Workflow fix

* Experiment: Summary

* Test summary as comment

* Error handling

* Add permissions to workflow, to post message

* Update to reflect PR comment
* Fix npm not installing
DandingB and others added 7 commits November 24, 2025 13:21
* Changed notification dropdown to use shadcn popover

* Changed notification toast to use the shadcn toast

* Update course-editor-review.tsx

* Removed toasts from notifications

* Update course-editor-review.tsx

* Added translations

* Fixed imports

---------

Co-authored-by: DandingB <daniel@Daniels-MBP-2.home>
Co-authored-by: DandingB <daniel@Daniels-MacBook-Pro-2.local>
Updated the Content Creator schema and related OpenAPI and TypeScript definitions to require the lastName field. This ensures lastName is mandatory for content creator entities and improves validation consistency across the API and documentation.
* Wrote in the controller so that it can populate

* update inorder to populate so we can find subscribed courses

* Auto enable policies

* Removing manual populate

* Update documentation

* Updated to return pagination on the find

* Updated bootstrapi function

---------

Co-authored-by: PhilipShaffer <152175307+PhilipShaffer@users.noreply.github.com>
Co-authored-by: Jakob Rossander Kristensen <jakobrk@gmail.com>
Co-authored-by: Jakob Rossander Kristensen <152175219+Jakobrk@users.noreply.github.com>
* removed hero-icons and react-icons

* exchanged lucide icons with mdi
Profile picture for content creator
- Upload
- Replace
- Delete
@RasmusJensen1 RasmusJensen1 requested a review from Alb9ert December 3, 2025 10:36
@OliverKjaer
Copy link
Copy Markdown
Contributor

Co contributor: @OliverKjaer

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 3, 2025

🔴 Code Quality Report

✅ Required Checks

All required checks passed ✓ - This PR can be merged!

📊 Codebase Quality Metrics (Advisory)

🔍 Lint & Format
Metric Count
ESLint Errors 1952
ESLint Warnings 34 ⚠️
Files Needing Format 1 📝
🔤 Type Check
Metric Count
TypeScript Errors 156
🧪 Tests
Metric Count
Tests Passed 0
Tests Failed 0
Total Tests 0
Pass Rate NaN%
🏗️ Build
Metric Value
Build Status failed
Build Time 19s ⏱️
Dist Size N/A 📦

💡 Note: These metrics show the entire codebase health and won't block merging. Only changed files are required to pass checks.

📈 Track these numbers over time to see progress on technical debt!

Copy link
Copy Markdown

@JessicaTegner JessicaTegner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over all looks good. Clean changes, easy to follow. Added a few comments.

`http://localhost:8888/api/bucket/${formData.photo}`,
);

// Helper get correct image URL
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this doing what it's doing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure what if you mean why there is a comment or you mean the code

But i have fixed the comment to better explain it:

// Helper function to construct the full image URL from Strapi
// Handles both absolute URLs (starting with http) and relative URLs from Strapi

Please let me know if that explains it or else please reach back and i will fix it ⚡

@ollioddi ollioddi self-requested a review December 3, 2025 12:04
@ollioddi
Copy link
Copy Markdown
Contributor

ollioddi commented Dec 3, 2025

Looks good @RasmusJensen1 . There is however a bunch of image components and utilities pending in #124 which would be nice to reuse in this as well.

EDIT2: Added docs Media Docs as also suggested by @HasnainAliprogramming in PR review.

EDIT: If you want to use my code, one way to do that would be for you to rebase on top of my branch, and then rebase later on dev. Then you could get access to my shared functions before the PR merges.

# Your actions:
git checkout us-0092-update-profile-picture-content-creator
git rebase web/media

# Refactor to use shared functions etc. etc..

# Commit the changes
git add .
git commit -m "Use functions from web/media branch"
git push --force-with-lease # Because we rewrite history

Then, when #124 gets merged, you simply do:

# rebase onto the updated dev:
git checkout us-0092-update-profile-picture-content-creator
git fetch origin
git rebase origin/dev
git push --force-with-lease # Because we rewrite history

Git will recognize that the commits from the web/media branch are already in dev and automatically skip them during the rebase. Then your branch should only contain the unique commits on top of dev. Hopefully.

Copy link
Copy Markdown
Contributor

@EmilLykke EmilLykke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added some comments.
I think you should try and get your ESLint up and running. There are a lot of errors inside of your edited files:
image

@ollioddi
Copy link
Copy Markdown
Contributor

I have added some comments.
I think you should try and get your ESLint up and running. There are a lot of errors inside of your edited files:
image

npm run lint:check:changed

@RasmusJensen1
Copy link
Copy Markdown
Contributor Author

Looks good @RasmusJensen1 . There is however a bunch of image components and utilities pending in #124 which would be nice to reuse in this as well.

EDIT2: Added docs Media Docs as also suggested by @HasnainAliprogramming in PR review.

EDIT: If you want to use my code, one way to do that would be for you to rebase on top of my branch, and then rebase later on dev. Then you could get access to my shared functions before the PR merges.

# Your actions:
git checkout us-0092-update-profile-picture-content-creator
git rebase web/media

# Refactor to use shared functions etc. etc..

# Commit the changes
git add .
git commit -m "Use functions from web/media branch"
git push --force-with-lease # Because we rewrite history

Then, when #124 gets merged, you simply do:

# rebase onto the updated dev:
git checkout us-0092-update-profile-picture-content-creator
git fetch origin
git rebase origin/dev
git push --force-with-lease # Because we rewrite history

Git will recognize that the commits from the web/media branch are already in dev and automatically skip them during the rebase. Then your branch should only contain the unique commits on top of dev. Hopefully.

I think this would make more sense to make a follow op/succesor task for due to time constraints of the merge tomorrow

I hope that is ok or else let me know ⚡

Copy link
Copy Markdown
Contributor

@EmilLykke EmilLykke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you have merged dev into you branch and resolved merge conflicts then I will approve

…e component

- Cleaned up merge conflict markers in course-columns.tsx.
- Updated useFileUpload hook to return an array of UploadedFile objects instead of UploadPostResponses.
- Enhanced file upload logic to handle both single objects and arrays in useFileUpload.
- Modified Profile component to use the updated useFileUpload hook.
- Improved buildUpdatePayload function to validate statusValue and handle optional fields.
- Added detailed logging for debugging during profile updates and file uploads.
- Ensured proper error handling and user feedback for profile picture uploads.
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
23.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@AleksandarDzambas AleksandarDzambas self-requested a review December 11, 2025 17:43
Copy link
Copy Markdown

@AleksandarDzambas AleksandarDzambas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

// Disable unified-signatures rule due to crashes in @typescript-eslint/eslint-plugin
"@typescript-eslint/unified-signatures": "off",
// Prevents bugs from using "truthy" or "falsy" values in conditions.
"@typescript-eslint/strict-boolean-expressions": [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the rule


// eslint-disable-next-line sonarjs/class-name, @typescript-eslint/naming-convention
interface useFileUploadReturn {
uploadFile: (files: FileWithMetadata[]) => Promise<UploadPostResponses[200] | undefined>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is driven by the openapi spec. Why define and maintain it manually?


// Helper function to construct the full image URL from Strapi
// Handles both absolute URLs (starting with http) and relative URLs from Strapi
const getImageUrl = (url: string | undefined): string => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exists in media utils

return;
}

console.log("Form data before submit:", formData);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove logging

const firstName = nameParts[0] || "";
const lastName = nameParts.slice(1).join(" ");

console.log("Name parts:", { firstName, lastName });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove logging

if (error instanceof Error) {
toast.error(`Erro ao fazer upload da foto de perfil: ${error.message}`);
} else {
toast.error("Erro ao fazer upload da foto de perfil");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations

try {
const documentId = localStorage.getItem("id");
if (!documentId) {
toast.error("Erro: ID do usuário não encontrado");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations

const profilePictureId = contentCreatorData?.profilePicture?.id;
if (!profilePictureId) {
if (showToast) {
toast.info("Nenhuma foto de perfil para deletar");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations

});

if (showToast) {
toast.success("Foto de perfil deletada com sucesso!");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations

} catch (error) {
console.error("Error deleting profile picture:", error);
if (showToast) {
toast.error("Erro ao deletar foto de perfil");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.