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) =>
deployments.some(
(deployment) =>
deployment.applicationRecordId === record.attributes.application
deployment.applicationDeploymentRequestId === record.attributes.request
)
);
}

View File

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

View File

@ -165,7 +165,7 @@ export class Service {
async updateDeploymentsWithRecordData(
records: AppDeploymentRecord[],
): 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({
where: records.map((record) => ({
applicationRecordId: record.attributes.application,
@ -174,13 +174,9 @@ export class Service {
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
const productionDeploymentProjectIds = filteredDeployments.reduce(
const productionDeploymentProjectIds = deployments.reduce(
(acc, deployment): Set<string> => {
if (deployment.environment === Environment.Production) {
acc.add(deployment.projectId);
@ -209,6 +205,10 @@ export class Service {
const deploymentUpdatePromises = records.map(async (record) => {
const deployment = recordToDeploymentsMap[record.attributes.request];
if(!deployment) {
log('Deployment does not exist')
}
await this.db.updateDeploymentById(deployment.id, {
applicationDeploymentRecordId: record.id,
applicationDeploymentRecordData: record.attributes,

View File

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

View File

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

View File

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

View File

@ -28,6 +28,17 @@ type Fee = {
type: 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 = {
id: string;
kind: string;
@ -40,11 +51,12 @@ type Auction = {
revealFee?: string;
minimumBid?: string;
winnerAddresses: string[];
winningBids?: string[];
winningPrice?: string;
winnerBids?: string[];
winnerPrice?: string;
maxPrice?: string;
numProviders: number;
fundsReleased: boolean;
bids: Bid[];
};
declare enum DomainStatus {
Live = "Live",
@ -328,4 +340,4 @@ declare class GQLClient {
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;
quantity: string;
};
type Bid = {
auctionId: string;
bidderAddress: string;
status: string;
commitHash: string;
commitTime?: Date;
commitFee?: string;
revealTime?: Date;
revealFee?: string;
bidAmount?: string;
};
type Auction = {
id: string;
kind: string;
@ -40,11 +51,12 @@ type Auction = {
revealFee?: string;
minimumBid?: string;
winnerAddresses: string[];
winningBids?: string[];
winningPrice?: string;
winnerBids?: string[];
winnerPrice?: string;
maxPrice?: string;
numProviders: number;
fundsReleased: boolean;
bids: Bid[];
};
declare enum DomainStatus {
Live = "Live",
@ -328,4 +340,4 @@ declare class GQLClient {
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
}
winnerAddresses
winningBids
winningPrice
maxPrice
winnerBids {
type
quantity
}
winnerPrice {
type
quantity
}
maxPrice {
type
quantity
}
numProviders
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
}
winnerAddresses
winningBids
winningPrice
maxPrice
winnerBids {
type
quantity
}
winnerPrice {
type
quantity
}
maxPrice {
type
quantity
}
numProviders
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
}
winnerAddresses
winningBids
winningPrice
maxPrice
winnerBids {
type
quantity
}
winnerPrice {
type
quantity
}
maxPrice {
type
quantity
}
numProviders
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;
}
export type Bid = {
auctionId: string;
bidderAddress: string;
status: string;
commitHash: string;
commitTime?: Date;
commitFee?: string;
revealTime?: Date;
revealFee?: string;
bidAmount?: string;
}
export type Auction = {
id: string;
kind: string;
@ -49,11 +61,12 @@ export type Auction = {
revealFee?: string;
minimumBid?: string;
winnerAddresses: string[];
winningBids?: string[];
winningPrice?: string;
winnerBids?: string[];
winnerPrice?: string;
maxPrice?: string;
numProviders: number;
fundsReleased: boolean;
bids: Bid[];
}
export enum DomainStatus {