type aligning of assets and proposals

This commit is contained in:
asiaznik 2022-09-14 11:53:45 +02:00
parent da12f0b5cd
commit eba2a8ac70
2 changed files with 8 additions and 7 deletions

View File

@ -16,14 +16,15 @@ type Proposal = {
type ProposalEdge = { type ProposalEdge = {
node: Proposal; node: Proposal;
}; };
type ProposalsConnection = { type ProposalEdges = {
proposalsConnection: {
edges: (ProposalEdge | null)[] | null; edges: (ProposalEdge | null)[] | null;
}; };
type ProposalsConnection = {
proposalsConnection: ProposalEdges | null;
}; };
export const getProposals = (data?: ProposalsConnection) => { export const getProposals = (data?: ProposalsConnection) => {
const proposals = data?.proposalsConnection.edges const proposals = data?.proposalsConnection?.edges
?.filter((e) => e?.node) ?.filter((e) => e?.node)
.map((e) => e?.node); .map((e) => e?.node);
return proposals ? (proposals as Proposal[]) : []; return proposals ? (proposals as Proposal[]) : [];

View File

@ -45,10 +45,10 @@ type AssetEdge<T extends Asset> = {
node: T; node: T;
}; };
type AssetEdges<T extends Asset> = { edges: (AssetEdge<T> | null)[] | null };
type AssetsConnection<T extends Asset> = { type AssetsConnection<T extends Asset> = {
assetsConnection: { assetsConnection: AssetEdges<T> | null;
edges: (AssetEdge<T> | null)[] | null;
};
}; };
export const getAssets = (data?: AssetsConnection<Asset>): Asset[] => export const getAssets = (data?: AssetsConnection<Asset>): Asset[] =>