Skip to content

Commit 93e96b2

Browse files
[Human App FE] Staking Requirements UI (#3725)
Co-authored-by: Dmitry Nechay <lelekkofe@gmail.com>
1 parent 3df929f commit 93e96b2

60 files changed

Lines changed: 1703 additions & 272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/apps/human-app/frontend/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ VITE_H_CAPTCHA_ORACLE_TASK_TYPES=image_points,image_boxes
2525
# Other
2626
VITE_HUMAN_PROTOCOL_HELP_URL=https://docs.humanprotocol.org/
2727
VITE_HUMAN_PROTOCOL_URL=https://humanprotocol.org/
28+
VITE_STAKING_DASHBOARD_URL=https://staking.humanprotocol.org/
2829
VITE_HUMAN_SUPPORT_EMAIL=support@local.app
2930
VITE_NAVBAR__LINK__HOW_IT_WORK_URL=https://humanprotocol.org/
3031
VITE_NAVBAR__LINK__PROTOCOL_URL=https://humanprotocol.org/
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

packages/apps/human-app/frontend/src/main.tsx

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { HomePageStateProvider } from '@/shared/contexts/homepage-state';
2323
import { NotificationProvider } from '@/shared/providers/notifications-provider';
2424
import { ModalProvider } from './shared/contexts/modal-context';
2525
import { GlobalModal } from './shared/components/ui/modal/global-modal';
26+
import { UiConfigProvider } from './shared/providers/ui-config-provider';
2627

2728
const root = document.getElementById('root');
2829
if (!root) throw Error('root element is undefined');
@@ -39,25 +40,30 @@ createRoot(root).render(
3940
<ColorModeProvider>
4041
<CssBaseline />
4142
<QueryClientProvider client={queryClient}>
42-
<NotificationProvider>
43-
<BrowserRouter>
44-
<WalletConnectProvider>
45-
<HomePageStateProvider>
46-
<ModalProvider>
47-
<Web3AuthProvider>
48-
<AuthProvider>
49-
<GlobalModal />
50-
<JWTExpirationCheck>
51-
<Router />
52-
</JWTExpirationCheck>
53-
</AuthProvider>
54-
</Web3AuthProvider>
55-
</ModalProvider>
56-
</HomePageStateProvider>
57-
<ReactQueryDevtools client={queryClient} initialIsOpen={false} />
58-
</WalletConnectProvider>
59-
</BrowserRouter>
60-
</NotificationProvider>
43+
<UiConfigProvider>
44+
<NotificationProvider>
45+
<BrowserRouter>
46+
<WalletConnectProvider>
47+
<HomePageStateProvider>
48+
<ModalProvider>
49+
<Web3AuthProvider>
50+
<AuthProvider>
51+
<GlobalModal />
52+
<JWTExpirationCheck>
53+
<Router />
54+
</JWTExpirationCheck>
55+
</AuthProvider>
56+
</Web3AuthProvider>
57+
</ModalProvider>
58+
</HomePageStateProvider>
59+
<ReactQueryDevtools
60+
client={queryClient}
61+
initialIsOpen={false}
62+
/>
63+
</WalletConnectProvider>
64+
</BrowserRouter>
65+
</NotificationProvider>
66+
</UiConfigProvider>
6167
</QueryClientProvider>
6268
</ColorModeProvider>
6369
</StrictMode>

packages/apps/human-app/frontend/src/modules/auth/context/auth-context.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const userDataSchema = z.object({
1111
user_id: z.number(),
1212
reputation_network: z.string(),
1313
exp: z.number(),
14+
is_stake_eligible: z.boolean(),
1415
});
1516

1617
export type UserData = z.infer<typeof userDataSchema>;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
2+
import {
3+
deleteExchangeApiKeys,
4+
enrollExchangeApiKeys,
5+
getExchangeApiKeys,
6+
getSupportedExchanges,
7+
} from '../services/exchangeApiKeys.service';
8+
9+
function useGetSupportedExchanges() {
10+
return useQuery({
11+
queryKey: ['supported-exchanges'],
12+
queryFn: () => getSupportedExchanges(),
13+
});
14+
}
15+
16+
function useGetExchangeApiKeys() {
17+
return useQuery({
18+
queryKey: ['exchange-api-keys'],
19+
queryFn: () => getExchangeApiKeys(),
20+
});
21+
}
22+
23+
function useEnrollExchangeApiKeys() {
24+
const queryClient = useQueryClient();
25+
26+
return useMutation({
27+
mutationKey: ['enroll-exchange-api-keys'],
28+
mutationFn: (data: {
29+
exchange: string;
30+
apiKey: string;
31+
secretKey: string;
32+
}) => enrollExchangeApiKeys(data),
33+
onSuccess: () => {
34+
queryClient.invalidateQueries({ queryKey: ['exchange-api-keys'] });
35+
queryClient.invalidateQueries({ queryKey: ['staking-summary'] });
36+
},
37+
});
38+
}
39+
40+
function useDeleteExchangeApiKeys() {
41+
const queryClient = useQueryClient();
42+
43+
return useMutation({
44+
mutationKey: ['delete-exchange-api-keys'],
45+
mutationFn: () => deleteExchangeApiKeys(),
46+
onSuccess: () => {
47+
queryClient.invalidateQueries({ queryKey: ['exchange-api-keys'] });
48+
queryClient.invalidateQueries({ queryKey: ['staking-summary'] });
49+
},
50+
});
51+
}
52+
53+
export {
54+
useGetSupportedExchanges,
55+
useDeleteExchangeApiKeys,
56+
useGetExchangeApiKeys,
57+
useEnrollExchangeApiKeys,
58+
};

0 commit comments

Comments
 (0)