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:
leanderandCopilot committed 2026-10-22 04:40:53 +02:00
1 parent 407523b61a
commit 65e532be30
11 files changed
+107 -54

No files matched your search

+1 -1
View File
@@ -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);
};
+2 -2
View File
@@ -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>