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

Enums properly defined and nothing broke #16

Merged
merged 5 commits into from
Sep 22, 2024

Conversation

truffer11
Copy link
Collaborator

@truffer11 truffer11 commented Sep 14, 2024

Pull Request Template

**Fixes issue #5 **

What was changed?

  • Made the 5 status types into enums and created a "constants" folder under client-app/src.
  • Replaced several handlings of statuses to work with the enums.

Why was it changed?

  • The statuses were changed to enums for consistency, avoids typo errors, and allows for easy access.

How was it changed?

  • A new folder named "constants" was created and a file "Enums.js" was created within that folder. Enums.js currently defines the 5 status types for our project as the JavaScript version of enums. There is also an export line at the end for ease of access.
  • References to an item's status in DonatedItemsList.js and StatusDisplayPage.js have been switched to enums.

@truffer11 truffer11 linked an issue Sep 14, 2024 that may be closed by this pull request
3 tasks
Copy link
Collaborator

@miabu-pashh miabu-pashh left a comment

Choose a reason for hiding this comment

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

The overall use of enums is useful here for the user for proper abstraction, ensure immutability, which is a good practice for maintaining consistent item status values across the application. This helps prevent accidental modifications of the status values, ensuring the integrity of the data.
It might be beneficial to define this as an enum for better type safety.

@Anjali0407-git Anjali0407-git deleted the 5-define-status-type-enums-for-donated-items branch September 22, 2024 00:21
@Anjali0407-git Anjali0407-git restored the 5-define-status-type-enums-for-donated-items branch September 22, 2024 00:24
RECEIVED: 'Received'
});

export default ItemStatus;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@truffer11 delete this file. All the app code should be within src/

RECEIVED: 'Received'
});

export default ItemStatus;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@truffer11 Can you please rename the file toEnums.ts. .ts is a typescript extension. Typescript has enum datatype (which is not there in javascript) which is very useful in our case.

@@ -100,6 +103,8 @@ const StatusDisplayPage = () => {
<input
type="radio"
name="status"
//value={ItemStatus.DONATED}
//checked={donorInfo.status === ItemStatus.DONATED}
checked={donorInfo.status.donated}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@truffer11 You can replace with enums in this file also.

client-app/constants/Enums.js Outdated Show resolved Hide resolved
@Anjali0407-git Anjali0407-git merged commit 7d68bc5 into main Sep 22, 2024
2 checks passed
@Anjali0407-git Anjali0407-git deleted the 5-define-status-type-enums-for-donated-items branch September 22, 2024 00:30
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.

Define Status Type Enums for Donated Items
4 participants