Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fp 8 add edit delete #8

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Fp 8 add edit delete #8

wants to merge 7 commits into from

Conversation

FranciscoPerez
Copy link
Owner

@FranciscoPerez FranciscoPerez commented May 10, 2023

Changes

Add "edit" and "delete" order functionality.

  1. Create custom select components (<ItemDescrSelect> and <ItemQntSelect>) for menu item and quantity select input fields.
  2. Wrap each custom select component with forwardRef to use it as a controlled and uncontrolled component.
  3. Replace select input fields in order-form.js with corresonding custom select components.
  4. Create edit and delete functions (onEditOrderHandler and onDeleteOrderHandler) in viewOrder.js to handle corressponding API logic.
  5. Move order-related JSX in ordersList.js to its own <Order> component.
  6. Add edit functionality into <Order> component by implementing custom select components and useState hook.

Purpose

The edit and delete buttons are non-functional.

Issue #8

Approach

By using semi-flexible select components, we ensure the order drop-down options match across pages while also reducing redundancy.

On Delete button click, invoke onDeleteOrderHandler method.

On Edit button click, change <Order> to allow changes to item description and quantity. User can choose to confirm changes or cancel changes.

Testing Steps

Navigate to /view-orders/ page.

Delete Test

  1. Click the Delete button.
  2. Verify the deleted order was removed.

Edit and Confirm Test

  1. Click the Edit button.
  2. Verify item description and quantity fields convert to select input fields.
  3. Verify button choices now display Confirm and Cancel.
  4. Change the item description and quantity values.
  5. Click the Confirm button and verify changes were saved.

Edit and Cancel Test

  1. Click the Edit button.
  2. Verify item description and quantity fields convert to select input fields.
  3. Verify button choices now display Confirm and Cancel.
  4. Change the item description and quantity values.
  5. Click the Cancel button.
  6. Verify item description and quantity remain unchanged.

Learning

Reviewed the useRef and forwardRef features in React's documentation to properly pass a reference to the custom <ItemDescrSelect> and <ItemQntSelect> components.

useRef Documentation

forwardRef

Closes #8

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.

1 participant