Skip to content

Commit

Permalink
Merge pull request #674 from artizen-fund/lottie
Browse files Browse the repository at this point in the history
added changes
  • Loading branch information
rubelux authored Oct 31, 2023
2 parents 8800c33 + c5e7b5e commit 4b47c4b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib/calculateSales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ const getMatchFundMoney = (totalSales: number, countH: number, spli80: number):
}

export const calculateSales = (isWinner: boolean, matchFundPooled: number, count: number, totalSales: number) => {
const salesArtifacts = BASE_ARTIFACT_PRICE * count
const getSalesArtifacts = (artifactCount: number) => BASE_ARTIFACT_PRICE * artifactCount

const totalProjectSales = getSalesArtifacts(count)

const spli80 = (80 * matchFundPooled) / 100
const split20 = (20 * matchFundPooled) / 100
const projectMatchFund = getMatchFundMoney(totalSales, count, spli80) + salesArtifacts
const projectMatchFund = getMatchFundMoney(totalSales, count, spli80) + totalProjectSales

const totalAward = (salesArtifacts + projectMatchFund + (isWinner ? split20 : 0)).toFixed(2)
const totalAward = (totalProjectSales + projectMatchFund + (isWinner ? split20 : 0)).toFixed(2)

return {
salesArtifacts,
salesArtifacts: totalProjectSales,
projectMatchFund: projectMatchFund.toFixed(2),
spli80: spli80.toFixed(2),
prize: split20.toFixed(2),
totalAward,
calculateMatchFundContribution: (newCount: any) => {
return (salesArtifacts + getMatchFundMoney(totalSales, newCount, spli80)).toFixed(2)
return (getSalesArtifacts(newCount) + getMatchFundMoney(totalSales, newCount, spli80)).toFixed(2)
},
}
}
17 changes: 17 additions & 0 deletions src/pages/project/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ const ProjectPage = () => {
},
},
},
onError: error => {
console.log('error loading project', error)
},
})

console.log('data', data)

const project: any = data?.Projects?.length > 0 && data?.Projects[0]

const {
Expand All @@ -51,6 +56,10 @@ const ProjectPage = () => {
} = useContext(SeasonSubcriptionContext)
const { setVisibleModalWithAttrs } = useContext(LayoutContext)

console.log('seasonData ', seasonData)
console.log('seasonIsActive ', seasonIsActive)
console.log('project ', project)

//this should be only done when the season is active otherwise we should use the season from the project
const { data: openEditionsSub } = useSubscription<IOpenEditionsSubscription>(SUBSCRIBE_OPEN_EDITIONS, {
skip: !project || !seasonIsActive,
Expand All @@ -60,6 +69,9 @@ const ProjectPage = () => {
artifactId: { _eq: project && project.artifacts[0].id },
},
},
onError: error => {
console.log('error loading openEditionsSub', error)
},
})

const { data: openEditionsQuery } = useQuery(LOAD_OPEN_EDITIONS, {
Expand All @@ -70,10 +82,15 @@ const ProjectPage = () => {
artifactId: { _eq: project && project?.artifacts[0].id },
},
},
onError: error => {
console.log('error loading openEditionsQuery', error)
},
})

const openEditions = openEditionsSub || openEditionsQuery

console.log('openEditions', openEditions)

const lead = project?.members?.find((m: any) => m.type === 'lead')?.user

const rank = arrangedSeasonList?.findIndex(submission => submission.project?.id === project.id) || 0
Expand Down

0 comments on commit 4b47c4b

Please sign in to comment.