Fix user detail GraphQL query
Return monthly purchase totals with the correct GraphQL scalar and align frontend queries and generated types with the upgraded schema. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
11 files changed
+107
-54
No files matched your search
@@ -1,5 +1,5 @@
|
||||
query orderList($limit: Int = 10, $offset: Int = 0) {
|
||||
orderList(order: {created: DESC}, pagination: {limit: $limit, offset: $offset}) {
|
||||
orderList(ordering: [{created: DESC}], pagination: {limit: $limit, offset: $offset}) {
|
||||
id
|
||||
isExternal
|
||||
created
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
query transactionList($limit: Int = 10, $offset: Int = 0) {
|
||||
transactionList(order: {created: DESC}, pagination: {limit: $limit, offset: $offset}) {
|
||||
transactionList(ordering: [{created: DESC}], pagination: {limit: $limit, offset: $offset}) {
|
||||
id
|
||||
created
|
||||
amount
|
||||
|
||||
@@ -12,7 +12,7 @@ const sumTotal = (products: Omit<SchemaProduct, "userCounts">[], order: OrderLin
|
||||
const prices = order.map((orderLine: OrderLineInput) => {
|
||||
const product = products.find((product: Omit<SchemaProduct, "userCounts">) => product.id === orderLine.productId);
|
||||
if (!product) return 0;
|
||||
return orderLine.amount * (isExternal ? product.salePriceExt : product.salePriceInt);
|
||||
return orderLine.amount * Number(isExternal ? product.salePriceExt : product.salePriceInt);
|
||||
});
|
||||
return prices.reduce((partialSum, a) => partialSum + a, 0);
|
||||
};
|
||||
|
||||
@@ -35,13 +35,13 @@ const UserDetail = () => {
|
||||
<div>Stats</div>
|
||||
<ul>
|
||||
<li>
|
||||
Saldo: <strong>{profile.balance.toLocaleString("no")} kr</strong>
|
||||
Saldo: <strong>{Number(profile.balance).toLocaleString("no")} kr</strong>
|
||||
</li>
|
||||
<li>
|
||||
Siste kjøp: <strong>{formatTime(profile.lastPurchaseDate)}</strong>
|
||||
</li>
|
||||
<li>
|
||||
Kjøp totalt: <strong>{profile.orderSumTotal.toLocaleString("no")} kr</strong>
|
||||
Kjøp totalt: <strong>{Number(profile.orderSumTotal).toLocaleString("no")} kr</strong>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user