diff --git a/package.json b/package.json index ab11a54e8..87e570a23 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "@subql/contract-sdk": "^0.100.3", "@subql/network-clients": "^0.100.0", "@subql/network-config": "^0.100.0", - "@subql/network-query": "0.100.2", - "@subql/react-hooks": "0.100.3-0", + "@subql/network-query": "0.100.3-0", + "@subql/react-hooks": "0.100.3-1", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", diff --git a/src/pages/consumer/MyFlexPlans/MyFlexPlanTable.tsx b/src/pages/consumer/MyFlexPlans/MyFlexPlanTable.tsx index 62ff2aeeb..a647f6b95 100644 --- a/src/pages/consumer/MyFlexPlans/MyFlexPlanTable.tsx +++ b/src/pages/consumer/MyFlexPlans/MyFlexPlanTable.tsx @@ -4,14 +4,15 @@ import * as React from 'react'; import { useTranslation } from 'react-i18next'; import { useLocation, useNavigate } from 'react-router'; -import { TableTitle } from '@subql/components'; +import { useRouteQuery } from '@hooks'; +import { TableTitle, Typography } from '@subql/components'; import { StateChannelFieldsFragment as ConsumerFlexPlan } from '@subql/network-query'; import { ChannelStatus } from '@subql/network-query'; -import { useGetConsumerClosedFlexPlansLazyQuery, useGetConsumerOngoingFlexPlansLazyQuery } from '@subql/react-hooks'; -import { TableProps, Tag, Typography } from 'antd'; +import { useGetConsumerFlexPlansByDeploymentIdLazyQuery } from '@subql/react-hooks'; +import { TableProps, Tag } from 'antd'; +import dayjs from 'dayjs'; import { BigNumber } from 'ethers'; import i18next from 'i18next'; -import moment from 'moment'; import { AntDTable, DeploymentMeta, EmptyList, Spinner, TableText } from '../../../components'; import { ConnectedIndexer } from '../../../components/IndexerDetails/IndexerName'; @@ -23,18 +24,22 @@ import { OngoingFlexPlanActions } from './OngoingFlexPlanActions'; const { ONGOING_PLANS_NAV, CLOSED_PLANS_NAV } = ROUTES; -interface MyFlexPlanTableProps { - queryFn: typeof useGetConsumerOngoingFlexPlansLazyQuery | typeof useGetConsumerClosedFlexPlansLazyQuery; -} - -export const MyFlexPlanTable: React.FC = ({ queryFn }) => { +export const MyFlexPlanTable: React.FC = () => { const { account } = useWeb3(); const { pathname } = useLocation(); + const query = useRouteQuery(); const navigate = useNavigate(); const { t } = useTranslation(); - const [now] = React.useState(moment().toDate()); - const sortedParams = { consumer: account ?? '', now, offset: 0 }; - const [loadFlexPlan, flexPlans] = queryFn({ variables: sortedParams, fetchPolicy: 'no-cache' }); + const sortedParams = { + consumer: account ?? '', + now: dayjs('1970-1-1').toDate(), + offset: 0, + deploymentId: query.get('deploymentId') || '', + }; + const [loadFlexPlan, flexPlans] = useGetConsumerFlexPlansByDeploymentIdLazyQuery({ + variables: sortedParams, + fetchPolicy: 'no-cache', + }); const fetchMoreFlexPlans = () => { loadFlexPlan(); @@ -76,11 +81,7 @@ export const MyFlexPlanTable: React.FC = ({ queryFn }) => { dataIndex: 'expiredAt', width: 30, - title: ( - - ), + title: , render: (expiredAt) => { return ; }, @@ -148,11 +149,21 @@ export const MyFlexPlanTable: React.FC = ({ queryFn }) => }, flexPlans), { loading: () => , - error: (e) => {`Failed to load flex plans: ${e}`}, + error: (e) => {`Failed to load flex plans: ${e}`}, empty: () => , data: (flexPlanList) => { return ( -
+
+ + {query.get('projectName')} + { }, ]} > -
)} @@ -128,14 +111,7 @@ export const MyFlexPlans: React.FC = () => { element={ } /> - } - > - } - > + }> } /> } /> diff --git a/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx b/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx index 3f4cadd9c..6385a047b 100644 --- a/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx +++ b/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx @@ -122,7 +122,7 @@ const MyHostedPlan: FC = (props) => { style={{ color: 'var(--sq-blue600)', padding: '6px 10px' }} onClick={() => { navigate( - `/consumer/flex-plans/ongoing/details/${record.id}/ongoing?id=${record.id}&projectName=${record.projectName}&deploymentId=${record.deployment.deployment}`, + `/consumer/flex-plans/ongoing/details/${record.id}?id=${record.id}&projectName=${record.projectName}&deploymentId=${record.deployment.deployment}`, ); }} > diff --git a/yarn.lock b/yarn.lock index a97cf26f9..b539b0074 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4669,10 +4669,10 @@ dependencies: graphql "^16.5.0" -"@subql/network-query@0.100.2": - version "0.100.2" - resolved "https://registry.npmjs.org/@subql/network-query/-/network-query-0.100.2.tgz#5f44100dd144c4139291b8258a1d4110d39f896f" - integrity sha512-QEDs0HZj+ChADhKzaoIbx3VKQlGr9PPuu3ErRkCGcMrtFIFO9/N0CdR7loDmUCf9xHB0Y5goFLenSCYNWZTrTQ== +"@subql/network-query@0.100.3-0": + version "0.100.3-0" + resolved "https://registry.npmjs.org/@subql/network-query/-/network-query-0.100.3-0.tgz#46fa62091c815a383a3e276b6f8e6ee0c32a22d1" + integrity sha512-VJBjlcXAece8xjK/7Ii8cEuBvmgXyf3h2bLVtrX6vDuM5+cddn4xpl3pY9tLA330G5/mkQd2GmP+A9lHO7RkDA== dependencies: graphql "^16.5.0" @@ -4687,15 +4687,15 @@ jwt-decode "^3.1.2" lru-cache "^10.0.1" -"@subql/react-hooks@0.100.3-0": - version "0.100.3-0" - resolved "https://registry.npmjs.org/@subql/react-hooks/-/react-hooks-0.100.3-0.tgz#c399ae23e54470abeb91d0841190fed5fdcc767a" - integrity sha512-lvpoz1CURkf/iaqXaXc5SvYUB55ncUQq5crsnngvJXC9gCdsYt6gn69ZqPYC3TolWMsQhdJ+hygw36bpxd1akA== +"@subql/react-hooks@0.100.3-1": + version "0.100.3-1" + resolved "https://registry.npmjs.org/@subql/react-hooks/-/react-hooks-0.100.3-1.tgz#2fb270747568b6f7d0ab8b75b6a114b8984ee2f9" + integrity sha512-HdYx+rNDu8qyzF6gn38w0hbtZvQ2Rupbcnem5jA8/lbgxVF05k0K6nAsBOdNUvxybp7YijPJQqxUAZ2nw0NWZg== dependencies: "@graphql-tools/code-file-loader" "^7.3.6" "@graphql-tools/graphql-tag-pluck" "^7.3.6" "@graphql-tools/load" "^7.7.7" - "@subql/network-query" "0.100.2" + "@subql/network-query" "0.100.3-0" ahooks "^3.7.8" bignumber.js "^9.1.2" class-transformer "^0.5.1"