-
Notifications
You must be signed in to change notification settings - Fork 33
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
base: develop
Are you sure you want to change the base?
[HUM-37] clarify colors on statuses on my jobs table #2734
Conversation
@KacperKoza343 is attempting to deploy a commit to the HUMAN Protocol Team on Vercel. A member of the Team first needs to authorize it. |
39e389d
to
fb487f1
Compare
There was a problem hiding this 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.
packages/apps/human-app/frontend/src/api/services/worker/my-jobs-data.ts
Show resolved
Hide resolved
fb487f1
to
8287e0d
Compare
There was a problem hiding this 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?
- changed job status magic string to enums - removed unused my-jobs-button.tsx - added new chip colors
packages/apps/human-app/frontend/src/shared/helpers/get-chip-status-color.ts
Show resolved
Hide resolved
REJECTED = 'REJECTED', | ||
} | ||
|
||
// Repeated because of linting rule |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this 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([ |
There was a problem hiding this comment.
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.
Description
HUM-37