== Add component to build == === Actors === Admin === Scenario === 1. In the admin dashboard, there is a button labeled 'Add Component' with which the admin can add any component needed. The labels and text fields are populated by back-end logic, so it's as seamless as possible. [[Image(component.png, width=800, height=420)]] 2. When the button is clicked, a popup appears which has some basic information, but one of the fields is a dropdown with all the component types. The admins can choose which component they want and the fields populate. [[Image(componentpopup.png, width=800, height=420)]] [[Image(componentdropdown.png, width=800, height=420)]] 3. When the admin selects a cpu, for example, it automatically populates the needed fields and then he can enter the information. [[Image(populatedfields.png, width=800, height=420)]] 4. After the admin clicks create component, the popup disappears and if we check popup with all the cpus we can see that the new cpu is inserted successfully. [[Image(newComponent.png, width=800, height=420)]] {{{ BEGIN; SELECT * FROM build WHERE id = $buildId AND user_id = $userId LIMIT 1; SELECT * FROM build_component WHERE build_id = $buildId AND component_id = $componentId LIMIT 1; INSERT INTO build_component (build_id, component_id) VALUES ($buildId, $componentId); SELECT c.price FROM build_component bc JOIN components c ON c.id = bc.component_id WHERE bc.build_id = $buildId; UPDATE build SET total_price = ( SELECT COALESCE(ROUND(SUM(c.price), 2), 0) FROM build_component bc JOIN components c ON c.id = bc.component_id WHERE bc.build_id = $buildId ) WHERE id = $buildId; COMMIT; }}} [[Image(addedComponent.png, width=800, height=420)]]