Skip to content

Commit

Permalink
Partial fix for enums conversion to lower case. (humanprotocol#2701)
Browse files Browse the repository at this point in the history
* Fix case conversion in JL Frontend and add @mui/icons-material as dependency

* Update CvatJobType and JobStatus enums

* Add import to TransformEnumInterceptor in Rec Oracle

* use lower case for enums in human app

* fix enums to lower case

---------

Co-authored-by: Francisco López <[email protected]>
  • Loading branch information
portuu3 and flopez7 authored Oct 28, 2024
1 parent 3577dfc commit ca513a6
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 118 deletions.
1 change: 1 addition & 0 deletions packages/apps/fortune/recording-oracle/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SnakeCaseInterceptor } from './common/interceptors/snake-case';
import { WebhookModule } from './modules/webhook/webhook.module';
import { envValidator } from './common/config/env-schema';
import { EnvConfigModule } from './common/config/config.module';
import { TransformEnumInterceptor } from './common/interceptors/transform-enum.interceptor';

@Module({
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { apiClient } from '@/api/api-client';
import { apiPaths } from '@/api/api-paths';

export enum PrepareSignatureType {
SignUp = 'SIGNUP',
SignIn = 'SIGNIN',
DisableOperator = 'DISABLE_OPERATOR',
RegisterAddress = 'REGISTER_ADDRESS',
SignUp = 'signup',
SignIn = 'signin',
DisableOperator = 'disable_operator',
RegisterAddress = 'register_address',
}

export const prepareSignatureSuccessSchema = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function useDisableWeb3Operator() {
});

await mutateAsync({ authType: 'web3' });
updateUserData({ status: 'INACTIVE' });
updateUserData({ status: 'inactive' });
return result;
},
mutationKey: ['disableOperator', address, chainId],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@ const data: AvailableJobs = {
{
escrow_address: '0x2db00C8A1793424e35f6Cc634Eb13CC174929A4A',
chain_id: 80002,
job_type: 'FORTUNE',
status: 'ACTIVE',
job_type: 'fortune',
status: 'active',
},
{
escrow_address: '0x7Cf6978f8699Cf22a121B6332BDF3c5C2F10e3e3',
chain_id: 80002,
job_type: 'FORTUNE',
status: 'ACTIVE',
job_type: 'fortune',
status: 'active',
},
{
escrow_address: '0xb389ac3678bF3723863dF92B5D531b0d12e82431',
chain_id: 80002,
job_type: 'FORTUNE',
status: 'ACTIVE',
job_type: 'fortune',
status: 'active',
},
{
escrow_address: '0xe9B9b198b093A078Fe8900b703637C26FD2f06a4',
chain_id: 80002,
job_type: 'FORTUNE',
status: 'ACTIVE',
job_type: 'fortune',
status: 'active',
},
{
escrow_address: '0x531e2CDB13f2c5606F8C251799f93CBb1219C14C',
chain_id: 80002,
job_type: 'FORTUNE',
status: 'ACTIVE',
job_type: 'fortune',
status: 'active',
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const data: MyJobs = {
assignment_id: 8,
escrow_address: '0x2db00C8A1793424e35f6Cc634Eb13CC174929A4A',
chain_id: 80002,
job_type: 'FORTUNE',
status: 'ACTIVE',
job_type: 'fortune',
status: 'active',
reward_amount: 14.004735281093245,
reward_token: 'HMT',
created_at: '2024-04-22T14:38:03.956Z',
Expand All @@ -42,8 +42,8 @@ const data: MyJobs = {
assignment_id: 9,
escrow_address: '0xb389ac3678bF3723863dF92B5D531b0d12e82431',
chain_id: 80002,
job_type: 'FORTUNE',
status: 'ACTIVE',
job_type: 'fortune',
status: 'active',
reward_amount: 14.550093644402695,
reward_token: 'HMT',
created_at: '2024-04-23T08:24:14.274Z',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PageSize } from '@/shared/types/entity.type';

export interface JobsFilterStoreProps {
filterParams: {
sort?: 'ASC' | 'DESC';
sort?: 'asc' | 'desc';
sort_field?:
| 'chain_id'
| 'job_type'
Expand All @@ -15,12 +15,12 @@ export interface JobsFilterStoreProps {
// TODO add allowed job types
job_type?: string;
status?:
| 'ACTIVE'
| 'COMPLETED'
| 'CANCELED'
| 'VALIDATION'
| 'EXPIRED'
| 'REJECTED';
| 'active'
| 'completed'
| 'canceled'
| 'validation'
| 'expired'
| 'rejected';
escrow_address?: string;
page: number;
page_size: PageSize;
Expand All @@ -40,7 +40,7 @@ const initialFiltersState = {
page: 0,
page_size: 5,
fields: ['reward_amount', 'job_description', 'reward_token'],
status: 'ACTIVE',
status: 'active',
escrow_address: '',
} satisfies Pick<
JobsFilterStoreProps['filterParams'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { create } from 'zustand';
import type { PageSize } from '@/shared/types/entity.type';

export const jobStatuses = [
'ACTIVE',
'COMPLETED',
'CANCELED',
'VALIDATION',
'EXPIRED',
'REJECTED',
'active',
'completed',
'canceled',
'validation',
'expired',
'rejected',
] as const;

type JobStatus = (typeof jobStatuses)[number];

export interface MyJobsFilterStoreProps {
filterParams: {
sort?: 'ASC' | 'DESC';
sort?: 'asc' | 'desc';
sort_field?: 'chain_id' | 'job_type' | 'reward_amount' | 'expires_at';
job_type?: string;
status?: JobStatus;
Expand Down
10 changes: 5 additions & 5 deletions packages/apps/human-app/frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@
"gotIt": "Got it!"
},
"jobTypeLabels": {
"FORTUNE": "Fortune",
"IMAGE_POINTS": "Points",
"IMAGE_BOXES": "Bounding Boxes",
"IMAGE_BOXES_FROM_POINTS": "Bounding Boxes from Points",
"IMAGE_SKELETONS_FROM_BOXES": "Skeletons from Bounding Boxes"
"fortune": "Fortune",
"image_points": "Points",
"image_boxes": "Bounding Boxes",
"image_boxes_from_points": "Bounding Boxes from Points",
"image_skeletons_from_boxes": "Skeletons from Bounding Boxes"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function OperatorProfilePage() {
refetch: refetchStats,
} = useGetOperatorStats();

const isOperatorActive = user.status === 'ACTIVE';
const isOperatorActive = user.status === 'active';

useEffect(() => {
if (keysData?.url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export function AvailableJobsRewardAmountSort() {
setFilterParams({
...filterParams,
sort_field: 'reward_amount',
sort: 'ASC',
sort: 'asc',
});
};

const sortDescRewardAmount = () => {
setFilterParams({
...filterParams,
sort_field: 'reward_amount',
sort: 'DESC',
sort: 'desc',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function AvailableJobsDrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'DESC',
sort: 'desc',
sort_field: 'reward_amount',
});
}}
Expand Down Expand Up @@ -133,7 +133,7 @@ export function AvailableJobsDrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'ASC',
sort: 'asc',
sort_field: 'reward_amount',
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function DrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'DESC',
sort: 'desc',
sort_field: 'reward_amount',
});
}}
Expand Down Expand Up @@ -159,7 +159,7 @@ export function DrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'ASC',
sort: 'asc',
sort_field: 'reward_amount',
});
}}
Expand Down Expand Up @@ -226,9 +226,9 @@ export function DrawerMobile({
key={crypto.randomUUID()}
>
<Checkbox
checked={filterParams.status === 'VALIDATION'}
checked={filterParams.status === 'validation'}
onClick={() => {
handleCheckboxClick('status', 'VALIDATION');
handleCheckboxClick('status', 'validation');
}}
/>
<Typography>
Expand All @@ -241,9 +241,9 @@ export function DrawerMobile({
key={crypto.randomUUID()}
>
<Checkbox
checked={filterParams.status === 'EXPIRED'}
checked={filterParams.status === 'expired'}
onClick={() => {
handleCheckboxClick('status', 'EXPIRED');
handleCheckboxClick('status', 'expired');
}}
/>
<Typography>
Expand All @@ -256,9 +256,9 @@ export function DrawerMobile({
key={crypto.randomUUID()}
>
<Checkbox
checked={filterParams.status === 'REJECTED'}
checked={filterParams.status === 'rejected'}
onClick={() => {
handleCheckboxClick('status', 'REJECTED');
handleCheckboxClick('status', 'rejected');
}}
/>
<Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ interface MyJobsButtonProps {
export function MyJobsButton({ status }: MyJobsButtonProps) {
// TODO add correct implementation depending on job status
const { t } = useTranslation();
if (status === 'RESIGN') {
if (status === 'resign') {
return <TableButton>{t('worker.jobs.resign')}</TableButton>;
}
if (status === 'ACTIVE') {
if (status === 'active') {
return <TableButton>{t('worker.jobs.solve')}</TableButton>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export function MyJobsExpiresAtSort() {
setFilterParams({
...filterParams,
sort_field: 'expires_at',
sort: 'ASC',
sort: 'asc',
});
};

const sortDescExpiresAt = () => {
setFilterParams({
...filterParams,
sort_field: 'expires_at',
sort: 'DESC',
sort: 'desc',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export function MyJobsRewardAmountSort() {
setFilterParams({
...filterParams,
sort_field: 'reward_amount',
sort: 'ASC',
sort: 'asc',
});
};

const sortDescRewardAmount = () => {
setFilterParams({
...filterParams,
sort_field: 'reward_amount',
sort: 'DESC',
sort: 'desc',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const getColumnsDefinition = (
enableSorting: true,
Cell: (props) => {
const { url, assignment_id, status } = props.row.original;
const buttonDisabled = status !== 'ACTIVE';
const buttonDisabled = status !== 'active';
return (
<Grid sx={{ display: 'flex', justifyContent: 'flex-end', gap: '1rem' }}>
{url ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function MyJobsDrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'DESC',
sort: 'desc',
sort_field: 'reward_amount',
});
}}
Expand Down Expand Up @@ -133,7 +133,7 @@ export function MyJobsDrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'ASC',
sort: 'asc',
sort_field: 'reward_amount',
});
}}
Expand Down Expand Up @@ -161,7 +161,7 @@ export function MyJobsDrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'DESC',
sort: 'desc',
sort_field: 'expires_at',
});
}}
Expand Down Expand Up @@ -193,7 +193,7 @@ export function MyJobsDrawerMobile({
onClick={() => {
setFilterParams({
...filterParams,
sort: 'ASC',
sort: 'asc',
sort_field: 'expires_at',
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function MyJobsTableMobile({
</Stack>
) : null}
{allPages.map((d) => {
const buttonDisabled = d.status !== 'ACTIVE';
const buttonDisabled = d.status !== 'active';
return (
<Paper
key={crypto.randomUUID()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function ProfileActions() {
}, [address, isWalletConnected, registerAddressMutation]);
const { user } = useAuthenticatedUser();
const { t } = useTranslation();
const emailVerified = user.status === 'ACTIVE';
const emailVerified = user.status === 'active';
const kycApproved = user.kyc_status === 'approved';

const getConnectWalletBtn = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function StartKycButton() {

return (
<Button
disabled={user.status !== 'ACTIVE'}
disabled={user.status !== 'active'}
fullWidth
loading={kycStartIsPending}
onClick={startKYC}
Expand Down
Loading

0 comments on commit ca513a6

Please sign in to comment.