Fetch project details in overview tab in a loop
This commit is contained in:
parent
b214702a5e
commit
047ee01ad5
@ -1,4 +1,8 @@
|
|||||||
import { Select, Option, Spinner } from '@snowballtools/material-tailwind-react-fork';
|
import {
|
||||||
|
Select,
|
||||||
|
Option,
|
||||||
|
Spinner,
|
||||||
|
} from '@snowballtools/material-tailwind-react-fork';
|
||||||
|
|
||||||
const AccountsDropdown = ({
|
const AccountsDropdown = ({
|
||||||
accounts,
|
accounts,
|
||||||
|
@ -23,7 +23,10 @@ import { useGQLClient } from '../../../context/GQLClientContext';
|
|||||||
import IFrameModal from './IFrameModal';
|
import IFrameModal from './IFrameModal';
|
||||||
import EnvironmentVariablesForm from 'pages/org-slug/projects/id/settings/EnvironmentVariablesForm';
|
import EnvironmentVariablesForm from 'pages/org-slug/projects/id/settings/EnvironmentVariablesForm';
|
||||||
import { EnvironmentVariablesFormValues } from 'types/types';
|
import { EnvironmentVariablesFormValues } from 'types/types';
|
||||||
import { VITE_LACONICD_CHAIN_ID, VITE_WALLET_IFRAME_URL } from 'utils/constants';
|
import {
|
||||||
|
VITE_LACONICD_CHAIN_ID,
|
||||||
|
VITE_WALLET_IFRAME_URL,
|
||||||
|
} from 'utils/constants';
|
||||||
import AccountsDropdown from './AccountsDropdown';
|
import AccountsDropdown from './AccountsDropdown';
|
||||||
|
|
||||||
type ConfigureDeploymentFormValues = {
|
type ConfigureDeploymentFormValues = {
|
||||||
@ -211,10 +214,7 @@ const Configure = () => {
|
|||||||
|
|
||||||
const amountToBePaid = amount.replace(/\D/g, '').toString();
|
const amountToBePaid = amount.replace(/\D/g, '').toString();
|
||||||
|
|
||||||
txHash = await cosmosSendTokensHandler(
|
txHash = await cosmosSendTokensHandler(senderAddress, amountToBePaid);
|
||||||
senderAddress,
|
|
||||||
amountToBePaid,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!txHash) {
|
if (!txHash) {
|
||||||
toast({
|
toast({
|
||||||
@ -228,11 +228,8 @@ const Configure = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate transaction hash
|
// Validate transaction hash
|
||||||
const isTxHashValid = await verifyTx(
|
const isTxHashValid = await verifyTx(senderAddress, txHash, amount);
|
||||||
senderAddress,
|
setIsPaymentLoading(false);
|
||||||
txHash,
|
|
||||||
amount,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isTxHashValid) {
|
if (isTxHashValid) {
|
||||||
toast({
|
toast({
|
||||||
@ -277,19 +274,19 @@ const Configure = () => {
|
|||||||
if (templateId) {
|
if (templateId) {
|
||||||
createFormData.option === 'Auction'
|
createFormData.option === 'Auction'
|
||||||
? navigate(
|
? navigate(
|
||||||
`/${orgSlug}/projects/create/success/${projectId}?isAuction=true`,
|
`/${orgSlug}/projects/create/success/${projectId}?isAuction=true`,
|
||||||
)
|
)
|
||||||
: navigate(
|
: navigate(
|
||||||
`/${orgSlug}/projects/create/template/deploy?projectId=${projectId}&templateId=${templateId}`,
|
`/${orgSlug}/projects/create/template/deploy?projectId=${projectId}&templateId=${templateId}`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
createFormData.option === 'Auction'
|
createFormData.option === 'Auction'
|
||||||
? navigate(
|
? navigate(
|
||||||
`/${orgSlug}/projects/create/success/${projectId}?isAuction=true`,
|
`/${orgSlug}/projects/create/success/${projectId}?isAuction=true`,
|
||||||
)
|
)
|
||||||
: navigate(
|
: navigate(
|
||||||
`/${orgSlug}/projects/create/deploy?projectId=${projectId}`,
|
`/${orgSlug}/projects/create/deploy?projectId=${projectId}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast({
|
toast({
|
||||||
@ -382,14 +379,17 @@ const Configure = () => {
|
|||||||
console.error('Error in transaction:', error);
|
console.error('Error in transaction:', error);
|
||||||
throw new Error('Error in transaction');
|
throw new Error('Error in transaction');
|
||||||
} finally {
|
} finally {
|
||||||
setIsPaymentLoading(false);
|
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[client, dismiss, toast],
|
[client, dismiss, toast],
|
||||||
);
|
);
|
||||||
|
|
||||||
const requestTx = async (sender: string, recipient: string, amount: string,) => {
|
const requestTx = async (
|
||||||
|
sender: string,
|
||||||
|
recipient: string,
|
||||||
|
amount: string,
|
||||||
|
) => {
|
||||||
const iframe = document.getElementById('walletIframe') as HTMLIFrameElement;
|
const iframe = document.getElementById('walletIframe') as HTMLIFrameElement;
|
||||||
|
|
||||||
if (!iframe.contentWindow) {
|
if (!iframe.contentWindow) {
|
||||||
@ -405,7 +405,7 @@ const Configure = () => {
|
|||||||
toAddress: recipient,
|
toAddress: recipient,
|
||||||
amount,
|
amount,
|
||||||
},
|
},
|
||||||
VITE_WALLET_IFRAME_URL
|
VITE_WALLET_IFRAME_URL,
|
||||||
);
|
);
|
||||||
|
|
||||||
setIsFrameVisible(true);
|
setIsFrameVisible(true);
|
||||||
@ -577,7 +577,11 @@ const Configure = () => {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<AccountsDropdown accounts={accounts} onAccountChange={onAccountChange} isDataReceived={isAccountsDataReceived} />
|
<AccountsDropdown
|
||||||
|
accounts={accounts}
|
||||||
|
onAccountChange={onAccountChange}
|
||||||
|
isDataReceived={isAccountsDataReceived}
|
||||||
|
/>
|
||||||
<IFrameModal
|
<IFrameModal
|
||||||
setAccounts={setAccounts}
|
setAccounts={setAccounts}
|
||||||
setIsDataReceived={setIsAccountsDataReceived}
|
setIsDataReceived={setIsAccountsDataReceived}
|
||||||
@ -607,8 +611,7 @@ const Configure = () => {
|
|||||||
: 'Pay and Deploy'
|
: 'Pay and Deploy'
|
||||||
: isLoading
|
: isLoading
|
||||||
? 'Deploying'
|
? 'Deploying'
|
||||||
: 'Deploy'
|
: 'Deploy'}
|
||||||
}
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -2,7 +2,10 @@ import { useCallback, useEffect } from 'react';
|
|||||||
|
|
||||||
import { Box, Modal } from '@mui/material';
|
import { Box, Modal } from '@mui/material';
|
||||||
|
|
||||||
import { VITE_LACONICD_CHAIN_ID, VITE_WALLET_IFRAME_URL } from 'utils/constants';
|
import {
|
||||||
|
VITE_LACONICD_CHAIN_ID,
|
||||||
|
VITE_WALLET_IFRAME_URL,
|
||||||
|
} from 'utils/constants';
|
||||||
|
|
||||||
const IFrameModal = ({
|
const IFrameModal = ({
|
||||||
setAccounts,
|
setAccounts,
|
||||||
@ -48,7 +51,7 @@ const IFrameModal = ({
|
|||||||
type: 'REQUEST_WALLET_ACCOUNTS',
|
type: 'REQUEST_WALLET_ACCOUNTS',
|
||||||
chainId: VITE_LACONICD_CHAIN_ID,
|
chainId: VITE_LACONICD_CHAIN_ID,
|
||||||
},
|
},
|
||||||
VITE_WALLET_IFRAME_URL
|
VITE_WALLET_IFRAME_URL,
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -82,7 +85,7 @@ const IFrameModal = ({
|
|||||||
></iframe>
|
></iframe>
|
||||||
</Box>
|
</Box>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default IFrameModal;
|
export default IFrameModal;
|
||||||
|
@ -4,10 +4,7 @@ import { cloneIcon } from 'utils/cloneIcon';
|
|||||||
import { PWAIcon } from './PWAIcon';
|
import { PWAIcon } from './PWAIcon';
|
||||||
import { WebAppIcon } from './WebAppIcon';
|
import { WebAppIcon } from './WebAppIcon';
|
||||||
|
|
||||||
const TEMPLATE_ICONS = [
|
const TEMPLATE_ICONS = ['pwa', 'web'] as const;
|
||||||
'pwa',
|
|
||||||
'web'
|
|
||||||
] as const;
|
|
||||||
export type TemplateIconType = (typeof TEMPLATE_ICONS)[number];
|
export type TemplateIconType = (typeof TEMPLATE_ICONS)[number];
|
||||||
|
|
||||||
export interface TemplateIconProps extends CustomIconProps {
|
export interface TemplateIconProps extends CustomIconProps {
|
||||||
|
@ -60,9 +60,9 @@ const Id = () => {
|
|||||||
fetchProject(id);
|
fetchProject(id);
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
const onUpdate = async () => {
|
const onUpdate = useCallback(async () => {
|
||||||
await fetchProject(id);
|
await fetchProject(id);
|
||||||
};
|
}, [fetchProject, id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full">
|
<div className="h-full">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { Link, useNavigate, useOutletContext } from 'react-router-dom';
|
import { Link, useNavigate, useOutletContext } from 'react-router-dom';
|
||||||
import { RequestError } from 'octokit';
|
import { RequestError } from 'octokit';
|
||||||
|
|
||||||
@ -24,6 +24,7 @@ import { Domain, DomainStatus } from 'gql-client';
|
|||||||
import { AuctionCard } from 'components/projects/project/overview/Activity/AuctionCard';
|
import { AuctionCard } from 'components/projects/project/overview/Activity/AuctionCard';
|
||||||
|
|
||||||
const COMMITS_PER_PAGE = 4;
|
const COMMITS_PER_PAGE = 4;
|
||||||
|
const WAIT_DURATION = 5000;
|
||||||
|
|
||||||
const OverviewTabPanel = () => {
|
const OverviewTabPanel = () => {
|
||||||
const { octokit } = useOctokit();
|
const { octokit } = useOctokit();
|
||||||
@ -33,8 +34,7 @@ const OverviewTabPanel = () => {
|
|||||||
const [liveDomain, setLiveDomain] = useState<Domain>();
|
const [liveDomain, setLiveDomain] = useState<Domain>();
|
||||||
|
|
||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
|
const { project, onUpdate } = useOutletContext<OutletContextType>();
|
||||||
const { project } = useOutletContext<OutletContextType>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFetchingActivities(true);
|
setFetchingActivities(true);
|
||||||
@ -96,7 +96,20 @@ const OverviewTabPanel = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchRepoActivity();
|
fetchRepoActivity();
|
||||||
}, [octokit, project]);
|
}, []);
|
||||||
|
|
||||||
|
const fetchUpdatedProject = useCallback(async () => {
|
||||||
|
await onUpdate();
|
||||||
|
}, [onUpdate]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchUpdatedProject();
|
||||||
|
const timerId = setInterval(() => {
|
||||||
|
fetchUpdatedProject();
|
||||||
|
}, WAIT_DURATION);
|
||||||
|
|
||||||
|
return () => clearInterval(timerId);
|
||||||
|
}, [fetchUpdatedProject]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchLiveProdDomain = async () => {
|
const fetchLiveProdDomain = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user