Skip to content

Commit

Permalink
Extend vouchers page (#1521)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitriy <128726599+Magorsky@users.noreply.github.com>
Co-authored-by: magorsky <di@gear.foundation>
  • Loading branch information
3 people authored Apr 19, 2024
1 parent b418c30 commit 031439f
Show file tree
Hide file tree
Showing 94 changed files with 1,389 additions and 537 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/CI-CD-k8s-gear-js-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand All @@ -25,7 +25,7 @@ env:


jobs:

build-frontend-image-staging:
runs-on: ubuntu-latest
environment: staging
Expand Down Expand Up @@ -53,9 +53,10 @@ jobs:
build-args: |
VITE_NODE_ADDRESS=${{ secrets.REACT_APP_NODE_ADDRESS }}
VITE_API_URL=${{ secrets.REACT_APP_API_URL }}
VITE_DEFAULT_NODES_URL=${{ secrets.REACT_APP_DEFAULT_NODES_URL }}
VITE_DEFAULT_TRANSFER_BALANCE_VALUE=${{ secrets.REACT_APP_DEFAULT_TRANSFER_BALANCE_VALUE }}
VITE_HCAPTCHA_SITE_KEY=${{ secrets.REACT_APP_HCAPTCHA_SITE_KEY }}
VITE_NODES_API_URL= ${{ secrets.REACT_APP_DEFAULT_NODES_URL }}
VITE_VOUCHERS_API_URL=${{ secrets.VITE_VOUCHERS_API_URL }}
build-indexer-image-staging:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -131,7 +132,7 @@ jobs:
file: idea/test-balance/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-test-balance:qa

build-and-push-meta-storage-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/CI-CD-k8s-release-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ jobs:
build-args: |
VITE_NODE_ADDRESS=${{ secrets.REACT_APP_NODE_ADDRESS }}
VITE_API_URL=${{ secrets.REACT_APP_API_URL }}
VITE_DEFAULT_NODES_URL=${{ secrets.REACT_APP_DEFAULT_NODES_URL }}
VITE_DEFAULT_TRANSFER_BALANCE_VALUE=${{ secrets.REACT_APP_DEFAULT_TRANSFER_BALANCE_VALUE }}
VITE_HCAPTCHA_SITE_KEY=${{ secrets.REACT_APP_HCAPTCHA_SITE_KEY }}
VITE_NODES_API_URL=${{ secrets.REACT_APP_DEFAULT_NODES_URL }}
VITE_VOUCHERS_API_URL=${{ secrets.VITE_VOUCHERS_API_URL }}
build-indexer-image-prod:
runs-on: ubuntu-latest
needs: [tag-prod-version]
Expand Down
11 changes: 6 additions & 5 deletions idea/frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VITE_API_URL=https://idea.gear-tech.io/api
VITE_NODE_ADDRESS=wss://testnet.vara-network.io
VITE_HCAPTCHA_SITE_KEY=xxxx-xxxx-xxxx-xxxx-xxxx
VITE_DEFAULT_TRANSFER_BALANCE_VALUE=250000000000
VITE_DEFAULT_NODES_URL=https://idea.gear-tech.io/gear-nodes
VITE_API_URL=
VITE_VOUCHERS_API_URL=
VITE_NODES_API_URL=
VITE_NODE_ADDRESS=
VITE_HCAPTCHA_SITE_KEY=
VITE_DEFAULT_TRANSFER_BALANCE_VALUE=
8 changes: 5 additions & 3 deletions idea/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ RUN yarn install --mode=skip-build

ARG VITE_NODE_ADDRESS \
VITE_API_URL \
VITE_DEFAULT_NODES_URL \
VITE_NODES_API_URL \
VITE_DEFAULT_TRANSFER_BALANCE_VALUE \
VITE_HCAPTCHA_SITE_KEY
VITE_HCAPTCHA_SITE_KEY \
VITE_VOUCHERS_API_URL
ENV VITE_NODE_ADDRESS=${VITE_NODE_ADDRESS} \
VITE_VOUCHERS_API_URL=${VITE_VOUCHERS_API_URL} \
VITE_API_URL=${VITE_API_URL} \
VITE_DEFAULT_NODES_URL=${VITE_DEFAULT_NODES_URL} \
VITE_NODES_API_URL=${VITE_NODES_API_URL} \
VITE_DEFAULT_TRANSFER_BALANCE_VALUE=${VITE_DEFAULT_TRANSFER_BALANCE_VALUE} \
VITE_HCAPTCHA_SITE_KEY=${VITE_HCAPTCHA_SITE_KEY}

Expand Down
1 change: 1 addition & 0 deletions idea/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@polkadot/types": "10.11.2",
"@polkadot/util": "12.6.2",
"@react-aria/utils": "3.21.0",
"@tanstack/react-query": "5.29.0",
"bignumber.js": "9.1.2",
"clsx": "2.0.0",
"ky": "1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions idea/frontend/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NodeSection } from '@/entities/node';
import { DEFAULT_NODES_URL } from '@/shared/config';
import { NODES_API_URL } from '@/shared/config';
import { fetchCode, fetchCodes, addCodeName } from './code';
import { fetchProgram, fetchPrograms, addProgramName } from './program';
import { fetchTestBalance } from './balance';
Expand All @@ -8,7 +8,7 @@ import { fetchMetadata, addMetadata } from './metadata';
import { getLocalMetadata, PROGRAMS_LOCAL_FORAGE } from './LocalDB';
import { addState, fetchStates, fetchState } from './state';

const getNodes = (): Promise<NodeSection[]> => fetch(DEFAULT_NODES_URL).then((result) => result.json());
const getNodes = (): Promise<NodeSection[]> => fetch(NODES_API_URL).then((result) => result.json());

export {
getNodes,
Expand Down
21 changes: 21 additions & 0 deletions idea/frontend/src/app/providers/query/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactNode } from 'react';

const queryClient = new QueryClient({
defaultOptions: {
queries: {
gcTime: 0,
staleTime: Infinity,
},
},
});

type Props = {
children: ReactNode;
};

const QueryProvider = ({ children }: Props) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);

export { QueryProvider };
2 changes: 2 additions & 0 deletions idea/frontend/src/app/providers/withProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ModalProvider } from './modal';
import { EventsProvider } from './events';
import { ChainProvider } from './chain';
import { OnboardingProvider } from './onboarding';
import { QueryProvider } from './query';

const providers = [
BrowserRouter,
Expand All @@ -20,6 +21,7 @@ const providers = [
ModalProvider,
EventsProvider,
BlocksProvider,
QueryProvider,
];

const withProviders = (Component: ComponentType) => () =>
Expand Down
4 changes: 2 additions & 2 deletions idea/frontend/src/features/explorer/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExplorerSearch, Events, Block } from './ui';
import { Events, Block } from './ui';
import { Section, Method } from './consts';
import { EventRecords } from './types';
import { IdeaEvent } from './idea-event';

export { Section, Method, IdeaEvent, ExplorerSearch, Events, Block };
export { Section, Method, IdeaEvent, Events, Block };
export type { EventRecords };

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions idea/frontend/src/features/explorer/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExplorerSearch } from './explorer-search';
import { Events } from './events';
import { Block } from './block';

export { ExplorerSearch, Events, Block };
export { Events, Block };
3 changes: 2 additions & 1 deletion idea/frontend/src/features/filters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { Radio } from './ui/radio';
import { Filters } from './ui/Filters';
import { FilterGroup } from './ui/filterGroup';
import { StatusCheckbox } from './ui/statusCheckbox';
import { StatusRadio } from './ui/status-radio';

export { Filters, Radio, FilterGroup, StatusCheckbox };
export { Filters, Radio, FilterGroup, StatusCheckbox, StatusRadio };
8 changes: 0 additions & 8 deletions idea/frontend/src/features/filters/ui/radio/Radio.module.scss

This file was deleted.

9 changes: 2 additions & 7 deletions idea/frontend/src/features/filters/ui/radio/Radio.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Radio as UIRadio, RadioProps } from '@gear-js/ui';
import clsx from 'clsx';
import { FieldValues, Path, PathValue, useFormContext } from 'react-hook-form';

import styles from './Radio.module.scss';

type Props<T> = Omit<RadioProps, 'name' | 'onChange' | 'onSubmit'> & {
type Props<T> = Omit<RadioProps, 'name' | 'value' | 'onChange' | 'onSubmit'> & {
onSubmit: (values: T) => void;
name: Path<T>;
value: PathValue<T, Path<T>>;
Expand All @@ -15,9 +12,7 @@ const Radio = <T extends FieldValues>({ name, value, label, className, onSubmit

const onChange = () => handleSubmit(onSubmit)();

return (
<UIRadio label={label} className={clsx(styles.radio, className)} value={value} {...register(name, { onChange })} />
);
return <UIRadio label={label} className={className} value={value} {...register(name, { onChange })} />;
};

export { Radio };
3 changes: 3 additions & 0 deletions idea/frontend/src/features/filters/ui/status-radio/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { StatusRadio } from './status-radio';

export { StatusRadio };
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { RadioProps, radioStyles } from '@gear-js/ui';
import clsx from 'clsx';
import { FieldValues, Path, PathValue, useFormContext } from 'react-hook-form';

import { BulbBlock, BulbStatus } from '@/shared/ui/bulbBlock';

type Props<T> = Omit<RadioProps, 'name' | 'value' | 'onChange' | 'onSubmit'> & {
onSubmit: (values: T) => void;
name: Path<T>;
value: PathValue<T, Path<T>>;
status: BulbStatus;
};

const StatusRadio = <T extends FieldValues>({ name, label, value, status, onSubmit }: Props<T>) => {
const { register, handleSubmit } = useFormContext<T>();

const onChange = () => handleSubmit(onSubmit)();

return (
<label className={radioStyles.label}>
<input
type="radio"
value={value}
className={clsx(radioStyles.input, radioStyles.radio)}
{...register(name, { onChange })}
/>

<BulbBlock size="large" color="primary" weight="normal" status={status} text={label} />
</label>
);
};

export { StatusRadio };

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { FieldValues, Path, PathValue, useFormContext } from 'react-hook-form';

import { BulbBlock, BulbStatus } from '@/shared/ui/bulbBlock';

import styles from './StatusCheckbox.module.scss';

type Props<T> = Omit<CheckboxProps, 'name' | 'value' | 'onChange'> & {
type Props<T> = Omit<CheckboxProps, 'name' | 'value' | 'onChange' | 'onSubmit'> & {
onSubmit: (values: T) => void;
name: Path<T>;
value: PathValue<T, Path<T>>;
Expand All @@ -20,12 +18,17 @@ const StatusCheckbox = <T extends FieldValues>({ name, label, value, status, onS

const onChange = () => handleSubmit(onSubmit)();

const inputClasses = clsx(checkboxStyles.input, checkboxStyles.checkbox);

return (
<label htmlFor={id} className={checkboxStyles.label}>
<input type="checkbox" id={id} value={value} className={inputClasses} {...register(name, { onChange })} />
<BulbBlock size="large" color="primary" status={status} text={label} className={styles.status} />
<input
type="checkbox"
id={id}
value={value}
className={clsx(checkboxStyles.input, checkboxStyles.checkbox)}
{...register(name, { onChange })}
/>

<BulbBlock size="large" color="primary" weight="normal" status={status} text={label} />
</label>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import { Input } from '@gear-js/ui';
import { CSSTransition } from 'react-transition-group';
import { useForm } from 'react-hook-form';

import { Filters, FilterGroup, Radio, StatusCheckbox } from '@/features/filters';
import { AnimationTimeout } from '@/shared/config';
import { BulbStatus } from '@/shared/ui/bulbBlock';
import { SearchForm } from '@/shared/ui';

import { ProgramStatus, PROGRAM_STATUS_NAME } from '../../consts';
import { FiltersValues, RequestParams } from '../../types';
import styles from './programs-search.module.scss';

type Props = {
initQuery: string;
isLoggedIn: boolean;
initialValues: FiltersValues;
onSubmit: (values: RequestParams) => void;
};

const ProgramsSearch = ({ initQuery, isLoggedIn, initialValues, onSubmit }: Props) => {
const form = useForm({ defaultValues: { query: initQuery } });

const ProgramsSearch = ({ isLoggedIn, initialValues, onSubmit }: Props) => {
return (
<section className={styles.searchSettings}>
<form className={styles.searchForm} onSubmit={form.handleSubmit(({ query }) => onSubmit({ query }))}>
<Input type="search" placeholder="Search by name, code hash, id..." {...form.register('query')} />
</form>
<SearchForm
placeholder="Search by name, code hash, id..."
className={styles.searchForm}
onSubmit={(query) => onSubmit({ query })}
/>

<Filters initialValues={initialValues} onSubmit={onSubmit}>
<FilterGroup name="owner" onSubmit={onSubmit}>
<Radio name="owner" value="all" label="All programs" onSubmit={onSubmit} />
Expand Down
3 changes: 3 additions & 0 deletions idea/frontend/src/features/voucher/assets/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions idea/frontend/src/features/voucher/assets/remove.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions idea/frontend/src/features/voucher/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { useIssueVoucher } from './use-issue-voucher';
import { useBalanceSchema } from './use-balance-schema';
import { useDurationSchema } from './use-duration-schema';
import { useProgramIdSchema } from './use-program-id-schema';
import { useVoucherType } from './use-voucher-type';
import { useModal } from './use-modal';
import { useLoading } from './use-loading';
import { useVouchers } from './use-vouchers';
import { useVoucherFilters } from './use-voucher-filters';

export { useIssueVoucher, useBalanceSchema, useDurationSchema, useProgramIdSchema, useVoucherType };
export {
useBalanceSchema,
useDurationSchema,
useProgramIdSchema,
useVoucherType,
useModal,
useLoading,
useVouchers,
useVoucherFilters,
};
Loading

0 comments on commit 031439f

Please sign in to comment.