Skip to content

Commit 20e0ad1

Browse files
committed
More fixes
1 parent a4fb7bf commit 20e0ad1

15 files changed

+104
-69
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"rollForward": false
1111
},
1212
"chillicream.nitro.commandline": {
13-
"version": "16.0.0-p.9.20",
13+
"version": "16.0.0-p.9.19",
1414
"commands": [
1515
"nitro"
1616
],

Directory.Packages.props

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
55
<ItemGroup Label="HotChocolate">
6-
<PackageVersion Include="HotChocolate" Version="16.0.0-p.9.16" />
7-
<PackageVersion Include="HotChocolate.AspNetCore" Version="16.0.0-p.9.16" />
8-
<PackageVersion Include="HotChocolate.AspNetCore.Authorization" Version="16.0.0-p.9.16" />
9-
<PackageVersion Include="HotChocolate.AspNetCore.CommandLine" Version="16.0.0-p.9.16" />
10-
<PackageVersion Include="HotChocolate.Data.EntityFramework" Version="16.0.0-p.9.16" />
11-
<PackageVersion Include="HotChocolate.Fusion.Composition" Version="16.0.0-p.9.16" />
12-
<PackageVersion Include="HotChocolate.Fusion.Packaging" Version="16.0.0-p.9.16" />
13-
<PackageVersion Include="HotChocolate.Subscriptions.Postgres" Version="16.0.0-p.9.16" />
14-
<PackageVersion Include="HotChocolate.Fusion.AspNetCore" Version="16.0.0-p.9.16" />
15-
<PackageVersion Include="HotChocolate.Fusion.Aspire" Version="16.0.0-p.9.16" />
16-
<PackageVersion Include="HotChocolate.Diagnostics" Version="16.0.0-p.9.16" />
17-
<PackageVersion Include="HotChocolate.Execution" Version="16.0.0-p.9.16" />
18-
<PackageVersion Include="HotChocolate.Types.Analyzers" Version="16.0.0-p.9.16">
6+
<PackageVersion Include="HotChocolate" Version="16.0.0-p.9.19" />
7+
<PackageVersion Include="HotChocolate.AspNetCore" Version="16.0.0-p.9.19" />
8+
<PackageVersion Include="HotChocolate.AspNetCore.Authorization" Version="16.0.0-p.9.19" />
9+
<PackageVersion Include="HotChocolate.AspNetCore.CommandLine" Version="16.0.0-p.9.19" />
10+
<PackageVersion Include="HotChocolate.Data.EntityFramework" Version="16.0.0-p.9.19" />
11+
<PackageVersion Include="HotChocolate.Fusion.Composition" Version="16.0.0-p.9.19" />
12+
<PackageVersion Include="HotChocolate.Fusion.Packaging" Version="16.0.0-p.9.19" />
13+
<PackageVersion Include="HotChocolate.Subscriptions.Postgres" Version="16.0.0-p.9.19" />
14+
<PackageVersion Include="HotChocolate.Fusion.AspNetCore" Version="16.0.0-p.9.19" />
15+
<PackageVersion Include="HotChocolate.Fusion.Aspire" Version="16.0.0-p.9.19" />
16+
<PackageVersion Include="HotChocolate.Diagnostics" Version="16.0.0-p.9.19" />
17+
<PackageVersion Include="HotChocolate.Execution" Version="16.0.0-p.9.19" />
18+
<PackageVersion Include="HotChocolate.Types.Analyzers" Version="16.0.0-p.9.19">
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2121
</PackageVersion>

src/SourceSchemas/Cart/Data/CartItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class CartItem
1515
public int ProductId { get; set; }
1616

1717
[Required]
18-
public int Amount { get; set; }
18+
public int Quantity { get; set; }
1919

2020
[Required]
2121
public DateTime AddedAt { get; set; }

src/SourceSchemas/Cart/Types/CartMutations.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ public static partial class CartMutations
1010
[Error<ProductAmountCannotBeLowerThanOneException>]
1111
public static async Task<Data.Cart> AddProductToCartAsync(
1212
[ID<Product>] int productId,
13-
int amount,
13+
int quantity,
1414
CartContext context,
1515
CancellationToken cancellationToken)
1616
{
17-
if (amount < 1)
17+
if (quantity < 1)
1818
{
19-
throw new ProductAmountCannotBeLowerThanOneException(productId, amount);
19+
throw new ProductAmountCannotBeLowerThanOneException(productId, quantity);
2020
}
2121

2222
var cart = await context.Carts.FirstOrDefaultAsync(cancellationToken);
@@ -32,20 +32,20 @@ public static partial class CartMutations
3232
}
3333

3434
var existingCartItem = await context.CartItems.FirstOrDefaultAsync(
35-
item => item.CartId == cart.Id
35+
item => item.CartId == cart.Id
3636
&& item.ProductId == productId, cancellationToken);
3737

3838
if (existingCartItem is not null)
3939
{
40-
existingCartItem.Amount += amount;
40+
existingCartItem.Quantity += quantity;
4141
}
4242
else
4343
{
4444
var cartItem = new CartItem
4545
{
4646
CartId = cart.Id,
4747
ProductId = productId,
48-
Amount = amount,
48+
Quantity = quantity,
4949
AddedAt = DateTime.UtcNow
5050
};
5151
context.CartItems.Add(cartItem);
@@ -59,13 +59,13 @@ public static partial class CartMutations
5959
[Error<ProductAmountCannotBeLowerThanOneException>]
6060
public static async Task<Data.Cart?> RemoveProductFromCartAsync(
6161
[ID<Product>] int productId,
62-
int amount,
62+
int quantity,
6363
CartContext context,
6464
CancellationToken cancellationToken)
6565
{
66-
if (amount < 1)
66+
if (quantity < 1)
6767
{
68-
throw new ProductAmountCannotBeLowerThanOneException(productId, amount);
68+
throw new ProductAmountCannotBeLowerThanOneException(productId, quantity);
6969
}
7070

7171
var cart = await context.Carts
@@ -77,14 +77,14 @@ public static partial class CartMutations
7777
}
7878

7979
var cartItem = await context.CartItems.FirstOrDefaultAsync(
80-
item => item.CartId == cart.Id
80+
item => item.CartId == cart.Id
8181
&& item.ProductId == productId, cancellationToken);
8282

8383
if (cartItem is not null)
8484
{
85-
cartItem.Amount -= amount;
85+
cartItem.Quantity -= quantity;
8686

87-
if (cartItem.Amount <= 0)
87+
if (cartItem.Quantity <= 0)
8888
{
8989
context.CartItems.Remove(cartItem);
9090
}

src/SourceSchemas/Products/Types/ProductQueries.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,36 @@ public static partial class ProductQueries
1717
[Tag("team-products")]
1818
[UsePaging]
1919
public static async Task<Connection<Product>> GetProducts(
20+
string? searchText,
21+
double? minPrice,
22+
double? maxPrice,
2023
PagingArguments arguments,
2124
ProductContext context,
2225
CancellationToken cancellationToken)
23-
=> await context.Products
24-
.OrderBy(t => t.Name)
25-
.ThenBy(t => t.Id)
26-
.ToPageAsync(arguments, cancellationToken)
27-
.ToConnectionAsync();
26+
{
27+
IQueryable<Product> query = context.Products;
28+
29+
if (!string.IsNullOrWhiteSpace(searchText))
30+
{
31+
query = query.Where(t => t.Name!.Contains(searchText));
32+
}
33+
34+
if (minPrice.HasValue)
35+
{
36+
var p = minPrice.Value;
37+
query = query.Where(t => t.Price >= p);
38+
}
39+
40+
if (maxPrice.HasValue)
41+
{
42+
var p = maxPrice.Value;
43+
query = query.Where(t => t.Price <= p);
44+
}
45+
46+
return await query
47+
.OrderBy(t => t.Name)
48+
.ThenBy(t => t.Id)
49+
.ToPageAsync(arguments, cancellationToken)
50+
.ToConnectionAsync();
51+
}
2852
}

src/frontend/src/CartItem.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useState } from "react";
1111
const CartItemFragment = graphql`
1212
fragment CartItem_item on CartItem {
1313
id
14-
amount
14+
quantity
1515
addedAt
1616
product {
1717
id
@@ -127,7 +127,7 @@ export default function CartItem({ item }: CartItemProps) {
127127
variables: {
128128
input: {
129129
productId: data.product.id,
130-
amount: 1,
130+
quantity: 1,
131131
},
132132
},
133133
onCompleted: () => {
@@ -145,7 +145,7 @@ export default function CartItem({ item }: CartItemProps) {
145145
variables: {
146146
input: {
147147
productId: data.product.id,
148-
amount: 1,
148+
quantity: 1,
149149
},
150150
},
151151
onCompleted: () => {
@@ -163,7 +163,7 @@ export default function CartItem({ item }: CartItemProps) {
163163
variables: {
164164
input: {
165165
productId: data.product.id,
166-
amount: data.amount,
166+
quantity: data.quantity,
167167
},
168168
},
169169
onCompleted: () => {
@@ -205,7 +205,7 @@ export default function CartItem({ item }: CartItemProps) {
205205
>
206206
<RemoveIcon fontSize="small" />
207207
</IconButton>
208-
<Typography sx={quantityTextStyles}>{data.amount}</Typography>
208+
<Typography sx={quantityTextStyles}>{data.quantity}</Typography>
209209
<IconButton
210210
onClick={handleIncrease}
211211
disabled={isUpdating}

src/frontend/src/ProductCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function ProductCard({ product }: ProductCardProps) {
8989
variables: {
9090
input: {
9191
productId: data.id,
92-
amount: 1,
92+
quantity: 1,
9393
},
9494
},
9595
onCompleted: () => {

src/frontend/src/__generated__/CartItemAddMutation.graphql.ts

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/frontend/src/__generated__/CartItemRemoveMutation.graphql.ts

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/frontend/src/__generated__/CartItem_item.graphql.ts

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)