From ca513a6426c02b976c448ab99357c319275a0518 Mon Sep 17 00:00:00 2001 From: portuu3 <61605646+portuu3@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:23:36 +0100 Subject: [PATCH] Partial fix for enums conversion to lower case. (#2701) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- .../recording-oracle/src/app.module.ts | 1 + .../api/services/common/prepare-signature.ts | 8 ++-- .../api/services/operator/disable-operator.ts | 2 +- .../available-jobs-table-service-mock.ts | 20 +++++----- .../worker/my-jobs-table-service-mock.ts | 8 ++-- .../src/hooks/use-jobs-filter-store.tsx | 16 ++++---- .../src/hooks/use-my-jobs-filter-store.tsx | 14 +++---- .../apps/human-app/frontend/src/i18n/en.json | 10 ++--- .../pages/operator/profile/profile.page.tsx | 2 +- .../available-jobs-reward-amount-sort.tsx | 4 +- .../mobile/available-jobs-drawer-mobile.tsx | 4 +- .../worker/jobs/components/drawer-mobile.tsx | 16 ++++---- .../my-jobs/desktop/my-jobs-button.tsx | 4 +- .../desktop/my-jobs-expires-at-sort.tsx | 4 +- .../desktop/my-jobs-reward-amount-sort.tsx | 4 +- .../my-jobs/desktop/my-jobs-table.tsx | 2 +- .../my-jobs/mobile/my-jobs-drawer-mobile.tsx | 8 ++-- .../my-jobs/mobile/my-jobs-table-mobile.tsx | 2 +- .../pages/worker/profile/profile-actions.tsx | 2 +- .../pages/worker/profile/start-kyc-btn.tsx | 2 +- .../src/smart-contracts/EthKVStore/config.ts | 10 ++--- .../apps/job-launcher/client/package.json | 1 + .../client/src/state/auth/types.ts | 6 +-- .../job-launcher/client/src/types/index.ts | 32 ++++++++-------- yarn.lock | 38 +++++-------------- 25 files changed, 102 insertions(+), 118 deletions(-) diff --git a/packages/apps/fortune/recording-oracle/src/app.module.ts b/packages/apps/fortune/recording-oracle/src/app.module.ts index d147acbcaf..5f0836f482 100644 --- a/packages/apps/fortune/recording-oracle/src/app.module.ts +++ b/packages/apps/fortune/recording-oracle/src/app.module.ts @@ -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: [ diff --git a/packages/apps/human-app/frontend/src/api/services/common/prepare-signature.ts b/packages/apps/human-app/frontend/src/api/services/common/prepare-signature.ts index e17c73a50f..8890b02a4d 100644 --- a/packages/apps/human-app/frontend/src/api/services/common/prepare-signature.ts +++ b/packages/apps/human-app/frontend/src/api/services/common/prepare-signature.ts @@ -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({ diff --git a/packages/apps/human-app/frontend/src/api/services/operator/disable-operator.ts b/packages/apps/human-app/frontend/src/api/services/operator/disable-operator.ts index 43f606b446..adeee0e6b9 100644 --- a/packages/apps/human-app/frontend/src/api/services/operator/disable-operator.ts +++ b/packages/apps/human-app/frontend/src/api/services/operator/disable-operator.ts @@ -22,7 +22,7 @@ export function useDisableWeb3Operator() { }); await mutateAsync({ authType: 'web3' }); - updateUserData({ status: 'INACTIVE' }); + updateUserData({ status: 'inactive' }); return result; }, mutationKey: ['disableOperator', address, chainId], diff --git a/packages/apps/human-app/frontend/src/api/services/worker/available-jobs-table-service-mock.ts b/packages/apps/human-app/frontend/src/api/services/worker/available-jobs-table-service-mock.ts index 12f3f58ce6..71af139f0f 100644 --- a/packages/apps/human-app/frontend/src/api/services/worker/available-jobs-table-service-mock.ts +++ b/packages/apps/human-app/frontend/src/api/services/worker/available-jobs-table-service-mock.ts @@ -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', }, ], }; diff --git a/packages/apps/human-app/frontend/src/api/services/worker/my-jobs-table-service-mock.ts b/packages/apps/human-app/frontend/src/api/services/worker/my-jobs-table-service-mock.ts index 3fd94cb3da..9505dd28fc 100644 --- a/packages/apps/human-app/frontend/src/api/services/worker/my-jobs-table-service-mock.ts +++ b/packages/apps/human-app/frontend/src/api/services/worker/my-jobs-table-service-mock.ts @@ -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', @@ -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', diff --git a/packages/apps/human-app/frontend/src/hooks/use-jobs-filter-store.tsx b/packages/apps/human-app/frontend/src/hooks/use-jobs-filter-store.tsx index 92fbb7f54f..b515257f48 100644 --- a/packages/apps/human-app/frontend/src/hooks/use-jobs-filter-store.tsx +++ b/packages/apps/human-app/frontend/src/hooks/use-jobs-filter-store.tsx @@ -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' @@ -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; @@ -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'], diff --git a/packages/apps/human-app/frontend/src/hooks/use-my-jobs-filter-store.tsx b/packages/apps/human-app/frontend/src/hooks/use-my-jobs-filter-store.tsx index 63cbbf21e1..8a101f66c4 100644 --- a/packages/apps/human-app/frontend/src/hooks/use-my-jobs-filter-store.tsx +++ b/packages/apps/human-app/frontend/src/hooks/use-my-jobs-filter-store.tsx @@ -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; diff --git a/packages/apps/human-app/frontend/src/i18n/en.json b/packages/apps/human-app/frontend/src/i18n/en.json index 97be230ddd..f48f4d31b5 100644 --- a/packages/apps/human-app/frontend/src/i18n/en.json +++ b/packages/apps/human-app/frontend/src/i18n/en.json @@ -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" } } diff --git a/packages/apps/human-app/frontend/src/pages/operator/profile/profile.page.tsx b/packages/apps/human-app/frontend/src/pages/operator/profile/profile.page.tsx index 6028401c0e..15cc540b4e 100644 --- a/packages/apps/human-app/frontend/src/pages/operator/profile/profile.page.tsx +++ b/packages/apps/human-app/frontend/src/pages/operator/profile/profile.page.tsx @@ -33,7 +33,7 @@ export function OperatorProfilePage() { refetch: refetchStats, } = useGetOperatorStats(); - const isOperatorActive = user.status === 'ACTIVE'; + const isOperatorActive = user.status === 'active'; useEffect(() => { if (keysData?.url) { diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/desktop/available-jobs-reward-amount-sort.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/desktop/available-jobs-reward-amount-sort.tsx index 62535540c1..37f6c92975 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/desktop/available-jobs-reward-amount-sort.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/desktop/available-jobs-reward-amount-sort.tsx @@ -10,7 +10,7 @@ export function AvailableJobsRewardAmountSort() { setFilterParams({ ...filterParams, sort_field: 'reward_amount', - sort: 'ASC', + sort: 'asc', }); }; @@ -18,7 +18,7 @@ export function AvailableJobsRewardAmountSort() { setFilterParams({ ...filterParams, sort_field: 'reward_amount', - sort: 'DESC', + sort: 'desc', }); }; diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/mobile/available-jobs-drawer-mobile.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/mobile/available-jobs-drawer-mobile.tsx index 929db94719..702450dc11 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/mobile/available-jobs-drawer-mobile.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/mobile/available-jobs-drawer-mobile.tsx @@ -101,7 +101,7 @@ export function AvailableJobsDrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'DESC', + sort: 'desc', sort_field: 'reward_amount', }); }} @@ -133,7 +133,7 @@ export function AvailableJobsDrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'ASC', + sort: 'asc', sort_field: 'reward_amount', }); }} diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/drawer-mobile.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/drawer-mobile.tsx index 26a2db3c20..e7beecfb3c 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/drawer-mobile.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/drawer-mobile.tsx @@ -127,7 +127,7 @@ export function DrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'DESC', + sort: 'desc', sort_field: 'reward_amount', }); }} @@ -159,7 +159,7 @@ export function DrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'ASC', + sort: 'asc', sort_field: 'reward_amount', }); }} @@ -226,9 +226,9 @@ export function DrawerMobile({ key={crypto.randomUUID()} > { - handleCheckboxClick('status', 'VALIDATION'); + handleCheckboxClick('status', 'validation'); }} /> @@ -241,9 +241,9 @@ export function DrawerMobile({ key={crypto.randomUUID()} > { - handleCheckboxClick('status', 'EXPIRED'); + handleCheckboxClick('status', 'expired'); }} /> @@ -256,9 +256,9 @@ export function DrawerMobile({ key={crypto.randomUUID()} > { - handleCheckboxClick('status', 'REJECTED'); + handleCheckboxClick('status', 'rejected'); }} /> diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-button.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-button.tsx index de8ac73326..5fcb335055 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-button.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-button.tsx @@ -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 {t('worker.jobs.resign')}; } - if (status === 'ACTIVE') { + if (status === 'active') { return {t('worker.jobs.solve')}; } diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-expires-at-sort.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-expires-at-sort.tsx index 45a8d110ed..7204d1a572 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-expires-at-sort.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-expires-at-sort.tsx @@ -10,7 +10,7 @@ export function MyJobsExpiresAtSort() { setFilterParams({ ...filterParams, sort_field: 'expires_at', - sort: 'ASC', + sort: 'asc', }); }; @@ -18,7 +18,7 @@ export function MyJobsExpiresAtSort() { setFilterParams({ ...filterParams, sort_field: 'expires_at', - sort: 'DESC', + sort: 'desc', }); }; diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-reward-amount-sort.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-reward-amount-sort.tsx index 9ceb303393..51505007e5 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-reward-amount-sort.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-reward-amount-sort.tsx @@ -10,7 +10,7 @@ export function MyJobsRewardAmountSort() { setFilterParams({ ...filterParams, sort_field: 'reward_amount', - sort: 'ASC', + sort: 'asc', }); }; @@ -18,7 +18,7 @@ export function MyJobsRewardAmountSort() { setFilterParams({ ...filterParams, sort_field: 'reward_amount', - sort: 'DESC', + sort: 'desc', }); }; diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-table.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-table.tsx index dba69a8b01..9af184d199 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-table.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/desktop/my-jobs-table.tsx @@ -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 ( {url ? ( diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-drawer-mobile.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-drawer-mobile.tsx index a6de46a0d1..911be706b2 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-drawer-mobile.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-drawer-mobile.tsx @@ -101,7 +101,7 @@ export function MyJobsDrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'DESC', + sort: 'desc', sort_field: 'reward_amount', }); }} @@ -133,7 +133,7 @@ export function MyJobsDrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'ASC', + sort: 'asc', sort_field: 'reward_amount', }); }} @@ -161,7 +161,7 @@ export function MyJobsDrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'DESC', + sort: 'desc', sort_field: 'expires_at', }); }} @@ -193,7 +193,7 @@ export function MyJobsDrawerMobile({ onClick={() => { setFilterParams({ ...filterParams, - sort: 'ASC', + sort: 'asc', sort_field: 'expires_at', }); }} diff --git a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-table-mobile.tsx b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-table-mobile.tsx index b6b7ea5435..3a12ac8b0e 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-table-mobile.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-table-mobile.tsx @@ -102,7 +102,7 @@ export function MyJobsTableMobile({ ) : null} {allPages.map((d) => { - const buttonDisabled = d.status !== 'ACTIVE'; + const buttonDisabled = d.status !== 'active'; return ( { diff --git a/packages/apps/human-app/frontend/src/pages/worker/profile/start-kyc-btn.tsx b/packages/apps/human-app/frontend/src/pages/worker/profile/start-kyc-btn.tsx index 6e1cf3519c..b65b91a2d4 100644 --- a/packages/apps/human-app/frontend/src/pages/worker/profile/start-kyc-btn.tsx +++ b/packages/apps/human-app/frontend/src/pages/worker/profile/start-kyc-btn.tsx @@ -54,7 +54,7 @@ export function StartKycButton() { return (