Skip to content

Commit

Permalink
fix: get product logic
Browse files Browse the repository at this point in the history
  • Loading branch information
suk-6 committed Sep 26, 2024
1 parent 6651114 commit fdae4b9
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/modules/product/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,33 +271,37 @@ export class ProductService {
}))
.then((product) => ({
...product,
graph: product.fundingLog
.map((log, x) => ({
graph: [
...product.fundingLog.map((log, x) => ({
x,
y: log.price,
}))
.push({
})),
{
x: product.fundingLog.length,
y: product.currentAmount,
}),
},
],
}))
.then((product) => ({
...product,
graph: product.fundingLog.length === 0 && [
{
x: 0,
y: product.currentAmount,
},
],
graph:
product.fundingLog.length === 0
? [
{
x: 0,
y: product.currentAmount,
},
]
: product.graph,
}))
.then((product) => ({
...product,
purchaseIsDisabled: !(
product.fundingEndDate < DateTime.now().toJSDate() && product.type === ProductType.FUNDING
),
purchaseIsDisabled:
product.fundingEndDate < DateTime.now().toJSDate() &&
product.type === ProductType.FUNDING,
}))
.then((product) => {
if (!product.userTokenBalancesOnProduct.length) return product;
if (!product.userTokenBalancesOnProduct.length) return { ...product, saleIsDisabled: true };
return {
...product,
saleIsDisabled:
Expand All @@ -309,6 +313,7 @@ export class ProductService {
const copy: { [key: string]: any } = { ...product };
delete copy['fundingLog'];
delete copy['userTokenBalancesOnProduct'];
delete copy['productDetailImage'];

return copy as unknown as GetProductDTO;
})
Expand Down

0 comments on commit fdae4b9

Please sign in to comment.