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

feat: store MAINTENANCE_LEVELS as object, not array #286

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

Conversation

zz-hh-aa
Copy link
Collaborator

What does this PR do?

  • Makes the MAINTENANCE_LEVELS constant an object, not array; and exports a new type MaintenanceLevel for the keys
  • Correctly accesses the new data structure across the codebase
  • Deletes an unused component from an earlier UI version
    • When I was updating all instances of MAINTENANCE_LEVELS I found this unused component; following the principle of deleting unused code (Slack thread) because we have access to Git history, I've opted for deleting it (since it's not in the current Miro design anyway) and it meant one less thing to fix.

Why?

While starting on #251, I realised that we should update the data type of the MAINTENANCE_LEVELS constant first (before having to update it in more places).

This also just makes code more legible and useful in cases where we want the level itself (eg low and now the value eg 0.015).

Closes #274

@zz-hh-aa zz-hh-aa requested a review from a team January 16, 2025 16:48
Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fairhold-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2025 4:49pm

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

Nice 👌 Much more readable and consistent

Comment on lines +52 to +57
maintenanceLevel:
urlMaintenanceLevel === "high" ||
urlMaintenanceLevel === "medium" ||
urlMaintenanceLevel === "low" ||
urlMaintenanceLevel === "none"
? urlMaintenanceLevel
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
maintenanceLevel:
urlMaintenanceLevel === "high" ||
urlMaintenanceLevel === "medium" ||
urlMaintenanceLevel === "low" ||
urlMaintenanceLevel === "none"
? urlMaintenanceLevel
maintenanceLevel: ["high", "medium", "low", "none"].includes(urlMaintenanceLevel)
? urlMaintenanceLevel

@@ -40,7 +38,7 @@ export class Property {
* Size of the house in square meters
*/
size: number;
maintenancePercentage: MaintenancePercentage;
maintenanceLevel: 'none' | 'low' | 'medium' | 'high';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
maintenanceLevel: 'none' | 'low' | 'medium' | 'high';
maintenanceLevel: MaintenanceLevel

@@ -112,8 +110,10 @@ export class Property {
componentKey: keyof houseBreakdownType,
newBuildPrice: number,
age: number,
maintenanceLevel: number
maintenanceLevel: keyof typeof MAINTENANCE_LEVELS
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
maintenanceLevel: keyof typeof MAINTENANCE_LEVELS
maintenanceLevel: MaintenanceLevel

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.

Store MAINTENANCE_LEVELS constant as an object (with level keys) instead of array
2 participants