== Use-case 6 - Favorite Build Initiating actor: User \\ Other actors: / \\ The registered user wants to add a build to a list of favorite builds. The system ensures the user is logged in and that the build exists. Then it stores the build as 'favorited' for that user. == Scenario Step 1. User goes to the COMPLETED BUILDS page. \\ Step 2. System gets the approved builds that the user can see. \\ {{{ SELECT b.id, b.name, b.total_price, b.created_at FROM build b WHERE b.is_approved = TRUE; }}} [[Image(builds.png)]] Step 3. The user selects a build that he wants to favorite from the page. \\ [[Image(completed.png)]] Step 4. The user clicks on ADD TO FAVORITES button. \\ Step 5. The system checks if the build has already been added to the favorites list: {{{ SELECT * FROM favorite_builds WHERE user_id = userId AND build_id = buildId LIMIT 1; }}} * If the build hasn't already been favorited, the system inserts it: {{{ INSERT INTO favorite_builds (user_id, build_id) VALUES (userId, buildId); }}} [[Image(favorite.png)]] * If the build was already favorited, the system removes it from the favorites list: {{{ DELETE FROM favorite_builds WHERE user_id = userId AND build_id = buildId; }}} Step 6. The user can see his favorited builds in the user dashboard, by clicking on the username in the top right corner. [[Image(dashboard.png)]]