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

[HUM-37] clarify colors on statuses on my jobs table #2734

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

KacperKoza343
Copy link
Contributor

Description

HUM-37

Copy link

vercel bot commented Oct 31, 2024

@KacperKoza343 is attempting to deploy a commit to the HUMAN Protocol Team on Vercel.

A member of the Team first needs to authorize it.

@dnechay dnechay self-requested a review October 31, 2024 10:17
@KacperKoza343 KacperKoza343 force-pushed the HUM-37-clarify-colors-on-statuses branch from 39e389d to fb487f1 Compare October 31, 2024 10:21
Copy link
Contributor

@dnechay dnechay left a comment

Choose a reason for hiding this comment

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

Nice!

Let's make another improvement here: we use hardcoded status values (e.g. ACTIVE) here and there, so would be better to move it to some sort of enum and use this enum in schema validation and other places.

@mpblocky mpblocky force-pushed the HUM-37-clarify-colors-on-statuses branch from fb487f1 to 8287e0d Compare November 5, 2024 09:55
@dnechay dnechay self-requested a review November 5, 2024 11:24
Copy link
Contributor

@dnechay dnechay left a comment

Choose a reason for hiding this comment

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

WRT to coloring status - lgtm

Could you please move status values to enum and refactor usage of hardcoded values?

@KacperKoza343 KacperKoza343 marked this pull request as draft November 6, 2024 08:46
- changed job status magic string to enums
- removed unused my-jobs-button.tsx
- added new chip colors
REJECTED = 'REJECTED',
}

// Repeated because of linting rule
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: linting rule prevented me from creating MyJobStatusWithUnknown with all the values based directly on the MyJobStatus. The UNKNOWN is a type for handling unknown statuses on frontend, hence why it's not in the filters list.
Using utility types was not an option as there were places where MyJobStatus was used as a value.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mpblocky

The UNKNOWN is a type for handling unknown statuses on frontend, hence why it's not in the filters list.

That's legit, we don't need this value in filters list. At the same time, we don't need to have a second enum.
You can have MyJobStatus enum as it as and the define next:

const UNKNOWN_JOB_STATUS = 'UNKNOWN';

export type MyJobStatusWithUnknown =
  | `${MyJobStatus}`
  | typeof UNKNOWN_JOB_STATUS;

in case you want exact types.

At the same time, the only place where you need it - is getChipStatusColor, so instead of having this MyJobStatusWithUnknown, you can simply change getChipStatusColor to accept status: string and return default value when not active|completed|validation. Right now this getChipStatusColor look like a common utility that can be used anywhere else because it's in shared helpers, but why we use MyJobStatusWithUnknown type then? It makes more sense to remove enum usage here and use hardcoded value if it's shared utility.

If we don't plan to have it like shared - let's move it some other place close to "my jobs" and keep MyJobStatusWithUnknown with unknown for it and throw in default block of switch-case statement

@KacperKoza343 KacperKoza343 marked this pull request as ready for review November 6, 2024 14:58
@dnechay dnechay self-requested a review November 11, 2024 14:20
Copy link
Contributor

@dnechay dnechay left a comment

Choose a reason for hiding this comment

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

Looks better with enum!

Let's get rid of duplicated enum values and fix validation for API response

Also please pay attention to failed linter (probably we can get rid of unused AvailableJobsStatusFilter component)

status: z.string().transform((value) => {
try {
return z
.enum([
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be .nativeEnum(MyJobStatus)?
From what I see we can have at least expired jobs, so I assume all of them needed.

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.

3 participants