Display bids in auction details

This commit is contained in:
IshaVenikar 2024-10-10 18:09:03 +05:30 committed by Nabarun
parent b16e0a951c
commit 430d9dcca9
14 changed files with 224 additions and 125 deletions

View File

@ -377,7 +377,7 @@ export class Registry {
return records.filter((record: AppDeploymentRecord) => return records.filter((record: AppDeploymentRecord) =>
deployments.some( deployments.some(
(deployment) => (deployment) =>
deployment.applicationRecordId === record.attributes.application deployment.applicationDeploymentRequestId === record.attributes.request
) )
); );
} }

View File

@ -197,6 +197,18 @@ type Fee {
quantity: String! quantity: String!
} }
type Bid {
auctionId: String!
bidderAddress: String!
status: String!
commitHash: String!
commitTime: String
commitFee: Fee
revealTime: String
revealFee: Fee
bidAmount: Fee
}
type Auction { type Auction {
id: String! id: String!
kind: String! kind: String!
@ -209,11 +221,12 @@ type Auction {
revealFee: Fee! revealFee: Fee!
minimumBid: Fee minimumBid: Fee
winnerAddresses: [String!]! winnerAddresses: [String!]!
winningBids: [String!] winnerBids: [Fee!]
winningPrice: String winnerPrice: Fee
maxPrice: String maxPrice: Fee
numProviders: Int! numProviders: Int!
fundsReleased: Boolean! fundsReleased: Boolean!
bids: [Bid!]!
} }
input AuctionData { input AuctionData {

View File

@ -165,7 +165,7 @@ export class Service {
async updateDeploymentsWithRecordData( async updateDeploymentsWithRecordData(
records: AppDeploymentRecord[], records: AppDeploymentRecord[],
): Promise<void> { ): Promise<void> {
// Get deployments for ApplicationDeploymentRecords // Deployments that are completed, not updated(are in building state and ApplicationDeploymentRecord is present)
const deployments = await this.db.getDeployments({ const deployments = await this.db.getDeployments({
where: records.map((record) => ({ where: records.map((record) => ({
applicationRecordId: record.attributes.application, applicationRecordId: record.attributes.application,
@ -174,13 +174,9 @@ export class Service {
createdAt: 'DESC', createdAt: 'DESC',
}, },
}); });
const requestRecordIds = new Set(records.map((record) => record.attributes.request).filter(Boolean));
const filteredDeployments = deployments.filter((deployment) =>
deployment.applicationDeploymentRequestId && requestRecordIds.has(deployment.applicationDeploymentRequestId)
);
// Get project IDs of deployments that are in production environment // Get project IDs of deployments that are in production environment
const productionDeploymentProjectIds = filteredDeployments.reduce( const productionDeploymentProjectIds = deployments.reduce(
(acc, deployment): Set<string> => { (acc, deployment): Set<string> => {
if (deployment.environment === Environment.Production) { if (deployment.environment === Environment.Production) {
acc.add(deployment.projectId); acc.add(deployment.projectId);
@ -209,6 +205,10 @@ export class Service {
const deploymentUpdatePromises = records.map(async (record) => { const deploymentUpdatePromises = records.map(async (record) => {
const deployment = recordToDeploymentsMap[record.attributes.request]; const deployment = recordToDeploymentsMap[record.attributes.request];
if(!deployment) {
log('Deployment does not exist')
}
await this.db.updateDeploymentById(deployment.id, { await this.db.updateDeploymentById(deployment.id, {
applicationDeploymentRecordId: record.id, applicationDeploymentRecordId: record.id,
applicationDeploymentRecordData: record.attributes, applicationDeploymentRecordData: record.attributes,

View File

@ -82,11 +82,12 @@ export interface Auction {
revealFee?: string; revealFee?: string;
minimumBid?: string; minimumBid?: string;
winnerAddresses: string[]; winnerAddresses: string[];
winningBids: string[]; winnerBids?: string[];
winningPrice?: string; winnerPrice?: string;
maxPrice?: string; maxPrice?: string;
numProviders: number; numProviders: number;
fundsReleased: boolean; fundsReleased: boolean;
bids: string[];
} }
export interface AuctionData { export interface AuctionData {

View File

@ -2,10 +2,6 @@ import { useCallback, useEffect, useState } from 'react';
import { Auction, Project } from 'gql-client'; import { Auction, Project } from 'gql-client';
import { import {
Card,
CardContent,
CardHeader,
Typography,
Dialog, Dialog,
DialogTitle, DialogTitle,
DialogContent, DialogContent,
@ -14,119 +10,87 @@ import {
import { CheckRoundFilledIcon, LoadingIcon } from 'components/shared/CustomIcon'; import { CheckRoundFilledIcon, LoadingIcon } from 'components/shared/CustomIcon';
import { useGQLClient } from 'context/GQLClientContext'; import { useGQLClient } from 'context/GQLClientContext';
import { Button, Tag } from 'components/shared'; import { Button, Heading, Tag } from 'components/shared';
const CHECK_AUCTION_STATUS_INTERVAL = 2000; const CHECK_AUCTION_STATUS_INTERVAL = 2000;
export const AuctionCard = ({ export const AuctionCard = ({ project }: { project: Project }) => {
project,
}: {
project: Project;
}) => {
const [auctionStatus, setAuctionStatus] = useState<string>(''); const [auctionStatus, setAuctionStatus] = useState<string>('');
const [deployerLrns, setDeployerLrns] = useState<string[]>([]); const [deployerLrns, setDeployerLrns] = useState<string[]>([]);
const [auctionDetails, setAuctionDetails] = useState<Auction | null>(null); const [auctionDetails, setAuctionDetails] = useState<Auction | null>(null);
const [openDialog, setOpenDialog] = useState<boolean>(false); const [openDialog, setOpenDialog] = useState<boolean>(false);
const client = useGQLClient(); const client = useGQLClient();
const getIconByAuctionStatus = (status: string) => { const getIconByAuctionStatus = (status: string) =>
return status === 'completed' ? ( status === 'completed' ? <CheckRoundFilledIcon /> : <LoadingIcon className="animate-spin" />;
<CheckRoundFilledIcon />
) : (
<LoadingIcon className="animate-spin" />
);
};
const checkAuctionStatus = async () => { const checkAuctionStatus = useCallback(async () => {
const result = await client.getAuctionData(project.auctionId); const result = await client.getAuctionData(project.auctionId);
setAuctionStatus(result.status); setAuctionStatus(result.status);
setAuctionDetails(result); setAuctionDetails(result);
}; setDeployerLrns(project.deployerLrn);
}, [client, project.auctionId, project.deployerLrn]);
useEffect(() => { useEffect(() => {
let intervalId: NodeJS.Timeout | null = null;
if (auctionStatus !== 'completed') { if (auctionStatus !== 'completed') {
const intervalId = setInterval(checkAuctionStatus, CHECK_AUCTION_STATUS_INTERVAL);
checkAuctionStatus(); checkAuctionStatus();
intervalId = setInterval(checkAuctionStatus, CHECK_AUCTION_STATUS_INTERVAL);
} else {
setDeployerLrns(project.deployerLrn)
}
return () => { return () => clearInterval(intervalId);
if (intervalId) {
clearInterval(intervalId);
} }
}; }, [auctionStatus, checkAuctionStatus]);
}, [auctionStatus]);
const renderAuctionStatus = useCallback( const renderAuctionStatus = useCallback(
() => ( () => (
<Tag <Tag leftIcon={getIconByAuctionStatus(auctionStatus)} size="xs" type={auctionStatus === 'completed' ? 'positive' : 'emphasized'}>
leftIcon={getIconByAuctionStatus(auctionStatus)}
size="xs"
type={auctionStatus === 'completed' ? "positive" : "neutral"}
>
{auctionStatus.toUpperCase()} {auctionStatus.toUpperCase()}
</Tag> </Tag>
), ),
[auctionStatus], [auctionStatus]
); );
const handleOpenDialog = () => { const handleOpenDialog = () => setOpenDialog(true);
setOpenDialog(true); const handleCloseDialog = () => setOpenDialog(false);
};
const handleCloseDialog = () => {
setOpenDialog(false);
};
return ( return (
<> <>
<Card variant="outlined" className="my-4"> <div className="p-3 gap-2 rounded-xl border border-gray-200 transition-colors hover:bg-base-bg-alternate flex flex-col mt-8">
<CardHeader <div className="flex justify-between items-center">
title="Auction Details" <Heading className="text-lg leading-6 font-medium">Auction details</Heading>
titleTypographyProps={{ variant: 'h6' }}
action={
<Button onClick={handleOpenDialog} variant="tertiary" size="sm"> <Button onClick={handleOpenDialog} variant="tertiary" size="sm">
View details View details
</Button> </Button>
} </div>
sx={{ pb: 0.1 }}
/>
<CardContent>
<div className="flex justify-between items-center mt-1"> <div className="flex justify-between items-center mt-1">
<Typography variant="subtitle1">Auction Status</Typography> <span className="text-elements-high-em text-sm font-medium tracking-tight">Auction Status</span>
<div className="ml-2">{renderAuctionStatus()}</div> <div className="ml-2">{renderAuctionStatus()}</div>
</div> </div>
<div className="flex justify-between items-center mt-2"> <div className="flex justify-between items-center mt-2">
<Typography variant="subtitle1">Auction Id</Typography> <span className="text-elements-high-em text-sm font-medium tracking-tight">Auction Id</span>
<Typography variant="body2" className="mt-1 text-right"> <span className="text-elements-mid-em text-sm text-right">
{project.auctionId} {project.auctionId}
</Typography> </span>
</div> </div>
<Typography variant="subtitle1" className="mt-3"> {project.deployerLrn && (
Deployer LRNs <div className="mt-3">
</Typography> <span className="text-elements-high-em text-sm font-medium tracking-tight">Deployer LRNs</span>
<div>
{deployerLrns.map((lrn, index) => ( {deployerLrns.map((lrn, index) => (
<Typography key={index} variant="body2" className="text-elements"> <p key={index} className="text-elements-mid-em text-sm">
{'\u2022'} {lrn} {'\u2022'} {lrn}
</Typography> </p>
))} ))}
</div> </div>
</CardContent> )}
</Card> </div>
<Dialog open={openDialog} onClose={handleCloseDialog} maxWidth="lg" fullWidth> <Dialog open={openDialog} onClose={handleCloseDialog} fullWidth maxWidth="md">
<DialogTitle>Auction Details</DialogTitle> <DialogTitle>Auction Details</DialogTitle>
<DialogContent> <DialogContent>
{auctionDetails && ( {auctionDetails && (
<Typography variant="body1">
<pre>{JSON.stringify(auctionDetails, null, 2)}</pre> <pre>{JSON.stringify(auctionDetails, null, 2)}</pre>
</Typography>
)} )}
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>

View File

@ -60,8 +60,8 @@ const DeleteProjectDialog = ({
<Modal.Body> <Modal.Body>
<Input <Input
label={ label={
"Deleting your project is irreversible. Enter your project's name " + "Deleting your project is irreversible. Enter your project's name " + '"' +
project.name + project.name + '"' +
' below to confirm you want to permanently delete it:' ' below to confirm you want to permanently delete it:'
} }
id="input" id="input"

View File

@ -28,6 +28,17 @@ type Fee = {
type: string; type: string;
quantity: string; quantity: string;
}; };
type Bid = {
auctionId: string;
bidderAddress: string;
status: string;
commitHash: string;
commitTime?: Date;
commitFee?: string;
revealTime?: Date;
revealFee?: string;
bidAmount?: string;
};
type Auction = { type Auction = {
id: string; id: string;
kind: string; kind: string;
@ -40,11 +51,12 @@ type Auction = {
revealFee?: string; revealFee?: string;
minimumBid?: string; minimumBid?: string;
winnerAddresses: string[]; winnerAddresses: string[];
winningBids?: string[]; winnerBids?: string[];
winningPrice?: string; winnerPrice?: string;
maxPrice?: string; maxPrice?: string;
numProviders: number; numProviders: number;
fundsReleased: boolean; fundsReleased: boolean;
bids: Bid[];
}; };
declare enum DomainStatus { declare enum DomainStatus {
Live = "Live", Live = "Live",
@ -328,4 +340,4 @@ declare class GQLClient {
getAuctionData(auctionId: string): Promise<Auction>; getAuctionData(auctionId: string): Promise<Auction>;
} }
export { type AddDomainInput, type AddDomainResponse, type AddEnvironmentVariableInput, type AddEnvironmentVariablesResponse, type AddProjectFromTemplateInput, type AddProjectFromTemplateResponse, type AddProjectInput, type AddProjectMemberInput, type AddProjectMemberResponse, type AddProjectResponse, type Auction, type AuctionData, AuctionStatus, type AuthenticateGitHubResponse, type DeleteDeploymentResponse, type DeleteDomainResponse, type DeleteProjectResponse, type Deployment, DeploymentStatus, type Domain, DomainStatus, Environment, type EnvironmentVariable, type Fee, type FilterDomainInput, GQLClient, type GetDeploymentsResponse, type GetDomainsResponse, type GetEnvironmentVariablesResponse, type GetOrganizationsResponse, type GetProjectMembersResponse, type GetProjectResponse, type GetProjectsInOrganizationResponse, type GetUserResponse, type GraphQLConfig, type Organization, type OrganizationMember, type OrganizationProject, Permission, type Project, type ProjectMember, type RedeployToProdResponse, type RemoveEnvironmentVariableResponse, type RemoveProjectMemberResponse, Role, type RollbackDeploymentResponse, type SearchProjectsResponse, type UnauthenticateGitHubResponse, type UpdateDeploymentToProdResponse, type UpdateDomainInput, type UpdateDomainResponse, type UpdateEnvironmentVariableInput, type UpdateEnvironmentVariableResponse, type UpdateProjectInput, type UpdateProjectMemberInput, type UpdateProjectMemberResponse, type UpdateProjectResponse, type User }; export { type AddDomainInput, type AddDomainResponse, type AddEnvironmentVariableInput, type AddEnvironmentVariablesResponse, type AddProjectFromTemplateInput, type AddProjectFromTemplateResponse, type AddProjectInput, type AddProjectMemberInput, type AddProjectMemberResponse, type AddProjectResponse, type Auction, type AuctionData, AuctionStatus, type AuthenticateGitHubResponse, type Bid, type DeleteDeploymentResponse, type DeleteDomainResponse, type DeleteProjectResponse, type Deployment, DeploymentStatus, type Domain, DomainStatus, Environment, type EnvironmentVariable, type Fee, type FilterDomainInput, GQLClient, type GetDeploymentsResponse, type GetDomainsResponse, type GetEnvironmentVariablesResponse, type GetOrganizationsResponse, type GetProjectMembersResponse, type GetProjectResponse, type GetProjectsInOrganizationResponse, type GetUserResponse, type GraphQLConfig, type Organization, type OrganizationMember, type OrganizationProject, Permission, type Project, type ProjectMember, type RedeployToProdResponse, type RemoveEnvironmentVariableResponse, type RemoveProjectMemberResponse, Role, type RollbackDeploymentResponse, type SearchProjectsResponse, type UnauthenticateGitHubResponse, type UpdateDeploymentToProdResponse, type UpdateDomainInput, type UpdateDomainResponse, type UpdateEnvironmentVariableInput, type UpdateEnvironmentVariableResponse, type UpdateProjectInput, type UpdateProjectMemberInput, type UpdateProjectMemberResponse, type UpdateProjectResponse, type User };

View File

@ -28,6 +28,17 @@ type Fee = {
type: string; type: string;
quantity: string; quantity: string;
}; };
type Bid = {
auctionId: string;
bidderAddress: string;
status: string;
commitHash: string;
commitTime?: Date;
commitFee?: string;
revealTime?: Date;
revealFee?: string;
bidAmount?: string;
};
type Auction = { type Auction = {
id: string; id: string;
kind: string; kind: string;
@ -40,11 +51,12 @@ type Auction = {
revealFee?: string; revealFee?: string;
minimumBid?: string; minimumBid?: string;
winnerAddresses: string[]; winnerAddresses: string[];
winningBids?: string[]; winnerBids?: string[];
winningPrice?: string; winnerPrice?: string;
maxPrice?: string; maxPrice?: string;
numProviders: number; numProviders: number;
fundsReleased: boolean; fundsReleased: boolean;
bids: Bid[];
}; };
declare enum DomainStatus { declare enum DomainStatus {
Live = "Live", Live = "Live",
@ -328,4 +340,4 @@ declare class GQLClient {
getAuctionData(auctionId: string): Promise<Auction>; getAuctionData(auctionId: string): Promise<Auction>;
} }
export { type AddDomainInput, type AddDomainResponse, type AddEnvironmentVariableInput, type AddEnvironmentVariablesResponse, type AddProjectFromTemplateInput, type AddProjectFromTemplateResponse, type AddProjectInput, type AddProjectMemberInput, type AddProjectMemberResponse, type AddProjectResponse, type Auction, type AuctionData, AuctionStatus, type AuthenticateGitHubResponse, type DeleteDeploymentResponse, type DeleteDomainResponse, type DeleteProjectResponse, type Deployment, DeploymentStatus, type Domain, DomainStatus, Environment, type EnvironmentVariable, type Fee, type FilterDomainInput, GQLClient, type GetDeploymentsResponse, type GetDomainsResponse, type GetEnvironmentVariablesResponse, type GetOrganizationsResponse, type GetProjectMembersResponse, type GetProjectResponse, type GetProjectsInOrganizationResponse, type GetUserResponse, type GraphQLConfig, type Organization, type OrganizationMember, type OrganizationProject, Permission, type Project, type ProjectMember, type RedeployToProdResponse, type RemoveEnvironmentVariableResponse, type RemoveProjectMemberResponse, Role, type RollbackDeploymentResponse, type SearchProjectsResponse, type UnauthenticateGitHubResponse, type UpdateDeploymentToProdResponse, type UpdateDomainInput, type UpdateDomainResponse, type UpdateEnvironmentVariableInput, type UpdateEnvironmentVariableResponse, type UpdateProjectInput, type UpdateProjectMemberInput, type UpdateProjectMemberResponse, type UpdateProjectResponse, type User }; export { type AddDomainInput, type AddDomainResponse, type AddEnvironmentVariableInput, type AddEnvironmentVariablesResponse, type AddProjectFromTemplateInput, type AddProjectFromTemplateResponse, type AddProjectInput, type AddProjectMemberInput, type AddProjectMemberResponse, type AddProjectResponse, type Auction, type AuctionData, AuctionStatus, type AuthenticateGitHubResponse, type Bid, type DeleteDeploymentResponse, type DeleteDomainResponse, type DeleteProjectResponse, type Deployment, DeploymentStatus, type Domain, DomainStatus, Environment, type EnvironmentVariable, type Fee, type FilterDomainInput, GQLClient, type GetDeploymentsResponse, type GetDomainsResponse, type GetEnvironmentVariablesResponse, type GetOrganizationsResponse, type GetProjectMembersResponse, type GetProjectResponse, type GetProjectsInOrganizationResponse, type GetUserResponse, type GraphQLConfig, type Organization, type OrganizationMember, type OrganizationProject, Permission, type Project, type ProjectMember, type RedeployToProdResponse, type RemoveEnvironmentVariableResponse, type RemoveProjectMemberResponse, Role, type RollbackDeploymentResponse, type SearchProjectsResponse, type UnauthenticateGitHubResponse, type UpdateDeploymentToProdResponse, type UpdateDomainInput, type UpdateDomainResponse, type UpdateEnvironmentVariableInput, type UpdateEnvironmentVariableResponse, type UpdateProjectInput, type UpdateProjectMemberInput, type UpdateProjectMemberResponse, type UpdateProjectResponse, type User };

View File

@ -294,11 +294,39 @@ query ($auctionId: String!) {
quantity quantity
} }
winnerAddresses winnerAddresses
winningBids winnerBids {
winningPrice type
maxPrice quantity
}
winnerPrice {
type
quantity
}
maxPrice {
type
quantity
}
numProviders numProviders
fundsReleased fundsReleased
bids {
bidderAddress
status
commitHash
commitTime
revealTime
commitFee {
type
quantity
}
revealFee {
type
quantity
}
bidAmount {
type
quantity
}
}
} }
} }
`; `;

File diff suppressed because one or more lines are too long

View File

@ -266,11 +266,39 @@ query ($auctionId: String!) {
quantity quantity
} }
winnerAddresses winnerAddresses
winningBids winnerBids {
winningPrice type
maxPrice quantity
}
winnerPrice {
type
quantity
}
maxPrice {
type
quantity
}
numProviders numProviders
fundsReleased fundsReleased
bids {
bidderAddress
status
commitHash
commitTime
revealTime
commitFee {
type
quantity
}
revealFee {
type
quantity
}
bidAmount {
type
quantity
}
}
} }
} }
`; `;

File diff suppressed because one or more lines are too long

View File

@ -248,11 +248,39 @@ query ($auctionId: String!) {
quantity quantity
} }
winnerAddresses winnerAddresses
winningBids winnerBids {
winningPrice type
maxPrice quantity
}
winnerPrice {
type
quantity
}
maxPrice {
type
quantity
}
numProviders numProviders
fundsReleased fundsReleased
bids {
bidderAddress
status
commitHash
commitTime
revealTime
commitFee {
type
quantity
}
revealFee {
type
quantity
}
bidAmount {
type
quantity
}
}
} }
} }
`; `;

View File

@ -37,6 +37,18 @@ export type Fee = {
quantity: string; quantity: string;
} }
export type Bid = {
auctionId: string;
bidderAddress: string;
status: string;
commitHash: string;
commitTime?: Date;
commitFee?: string;
revealTime?: Date;
revealFee?: string;
bidAmount?: string;
}
export type Auction = { export type Auction = {
id: string; id: string;
kind: string; kind: string;
@ -49,11 +61,12 @@ export type Auction = {
revealFee?: string; revealFee?: string;
minimumBid?: string; minimumBid?: string;
winnerAddresses: string[]; winnerAddresses: string[];
winningBids?: string[]; winnerBids?: string[];
winningPrice?: string; winnerPrice?: string;
maxPrice?: string; maxPrice?: string;
numProviders: number; numProviders: number;
fundsReleased: boolean; fundsReleased: boolean;
bids: Bid[];
} }
export enum DomainStatus { export enum DomainStatus {