Skip to content

Commit

Permalink
[Front] v1.1.0 (#63)
Browse files Browse the repository at this point in the history
* Update OIDCProvider version and redirect URIs

* Update dependencies in package.json

* Sync

* Fix formatting and add missing commas
  • Loading branch information
Aloento authored Dec 21, 2023
1 parent e17a4ef commit 034e10f
Show file tree
Hide file tree
Showing 86 changed files with 2,028 additions and 1,046 deletions.
6 changes: 3 additions & 3 deletions TSystems.LoveOTC/AdminHub/Order/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ internal partial class AdminHub {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 0.1.0
* @version 0.1.1
* </remarks>
*/
public async Task<dynamic?> OrderEntity(uint key, uint? version) {
public async Task<dynamic> OrderEntity(uint key, uint? version) {
if (version is not null) {
var noChange = await this.Db.Orders
.AnyAsync(x => x.OrderId == key && x.Version == version);
Expand All @@ -27,7 +27,7 @@ internal partial class AdminHub {
x.TrackingNumber,
x.Version
})
.SingleOrDefaultAsync();
.SingleAsync();
}

/**
Expand Down
27 changes: 27 additions & 0 deletions TSystems.LoveOTC/AdminHub/Order/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,31 @@ await this.Db.Orders
Quantity = (ushort)x.OrderCombos.Sum(o => o.Quantity)
})
.ToArrayAsync();

/**
* <remarks>
* @author Aloento
* @since 1.0.0
* @version 1.0.0
* </remarks>
*/
public async Task<dynamic> OrderGetDetail(uint orderId) {
var items = await this.Db.OrderCombos
.Where(x => x.OrderId == orderId)
.Select(x => new {
x.Quantity,
Types = x.Combo.Types.Select(t => t.TypeId).ToArray()
})
.ToArrayAsync();

var cmts = await this.Db.Comments
.Where(x => x.OrderId == orderId)
.Select(x => x.CommentId)
.ToArrayAsync();

return new {
Items = items,
Comments = cmts
};
}
}
31 changes: 26 additions & 5 deletions TSystems.LoveOTC/AdminHub/Order/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal partial class AdminHub {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.0
* @version 1.0.1
* </remarks>
*/
public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
Expand All @@ -31,7 +31,7 @@ public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
Content = cmt,
UserId = this.UserId,
CreateAt = DateTime.UtcNow,
Order = order
Order = order,
});

return await this.Db.SaveChangesAsync() > 0;
Expand Down Expand Up @@ -63,7 +63,7 @@ public async Task<bool> OrderPostClose(uint orderId, string reason) {
Content = "[Admin Close] " + reason,
UserId = this.UserId,
CreateAt = DateTime.UtcNow,
Order = order
Order = order,
});

return await this.Db.SaveChangesAsync() > 0;
Expand Down Expand Up @@ -99,6 +99,27 @@ public async Task<bool> OrderPostShip(uint orderId, string? track) {
return await this.Db.SaveChangesAsync() > 0;
}

// TODO: OrderPostAccept
// TODO: OrderPostReject
/**
* <remarks>
* @author Aloento
* @since 1.0.0
* @version 0.1.0
* </remarks>
*/
public async Task<bool> OrderPostAccept(uint orderId) {
var order = await this.Db.Orders
.Where(x => x.OrderId == orderId)
.Where(x => x.Status == OrderStatus.Pending)
.SingleAsync();

order.Status = OrderStatus.Processing;
order.Comments.Add(new() {
Content = "[Admin Accepted Order]",
UserId = this.UserId,
CreateAt = DateTime.UtcNow,
Order = order,
});

return await this.Db.SaveChangesAsync() > 0;
}
}
2 changes: 2 additions & 0 deletions TSystems.LoveOTC/AdminHub/Product/Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public async Task<bool> ProductDeletePhoto(uint photoId) {
* <summary>
* Include Types -> Combos
* </summary>
*
* <remarks>
* @author Aloento
* @since 0.5.0
Expand Down Expand Up @@ -69,6 +70,7 @@ await this.Db.Variants
* <summary>
* Include Combos
* </summary>
*
* <remarks>
* @author Aloento
* @since 0.5.0
Expand Down
1 change: 1 addition & 0 deletions TSystems.LoveOTC/AdminHub/Product/Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public async Task<bool> ProductPatchCaption(uint photoId, string caption) {
* <summary>
* Include Combos
* </summary>
*
* <remarks>
* @author Aloento
* @since 0.5.0
Expand Down
2 changes: 1 addition & 1 deletion TSystems.LoveOTC/AdminHub/Product/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public async Task<uint> ProductPostVariant(uint prodId, string name) {

var temp = await this.Db.Variants.AddAsync(new() {
ProductId = prodId,
Name = name
Name = name,
});

await this.Db.SaveChangesAsync();
Expand Down
5 changes: 3 additions & 2 deletions TSystems.LoveOTC/Entities/OrderStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ namespace TSystems.LoveOTC.Entities;
* <remarks>
* @author Aloento
* @since 0.1.0
* @version 0.1.0
* @version 0.1.1
* </remarks>
*/
public enum OrderStatus {
Pending,
Processing,
Shipping,
Finished,
Cancelled
Cancelled,
Returning,
}
25 changes: 25 additions & 0 deletions TSystems.LoveOTC/Hub/Order/Delete.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace TSystems.LoveOTC.Hub;

using Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore;

internal partial class ShopHub {
/**
* <remarks>
* @author Aloento
* @since 1.0.0
* @version 0.1.0
* </remarks>
*/
[Authorize]
public async Task<bool> OrderDeleteCancel(uint orderId) {
var row = await this.Db.Orders
.Where(x => x.UserId == this.UserId)
.Where(x => x.OrderId == orderId)
.Where(x => x.Status == OrderStatus.Cancelled)
.ExecuteDeleteAsync();

return row > 0;
}
}
6 changes: 3 additions & 3 deletions TSystems.LoveOTC/Hub/Order/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ internal partial class ShopHub {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 0.1.0
* @version 0.1.1
* </remarks>
*/
[Authorize]
public async Task<dynamic?> OrderEntity(uint key, uint? version) {
public async Task<dynamic> OrderEntity(uint key, uint? version) {
if (version is not null) {
var noChange = await this.Db.Orders
.AnyAsync(x => x.OrderId == key && x.Version == version);
Expand All @@ -28,7 +28,7 @@ internal partial class ShopHub {
x.TrackingNumber,
x.Version
})
.SingleOrDefaultAsync();
.SingleAsync();
}

/**
Expand Down
41 changes: 32 additions & 9 deletions TSystems.LoveOTC/Hub/Order/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task<uint> OrderPostNew(CartItem[] cart, string? cmt) {
order.Comments.Add(new() {
Content = cmt,
CreateAt = DateTime.UtcNow,
Order = order
Order = order,
});

foreach (var item in cart) {
Expand All @@ -57,13 +57,12 @@ public async Task<uint> OrderPostNew(CartItem[] cart, string? cmt) {
order.OrderCombos.Add(new() {
Order = order,
Combo = combo,
Quantity = item.Quantity
Quantity = item.Quantity,
});
}

return await this.Db.SaveChangesAsync() > 0
? order.OrderId
: throw new HubException();
? order.OrderId : throw new HubException();
}

/**
Expand Down Expand Up @@ -92,7 +91,7 @@ public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
order.Comments.Add(new() {
Content = cmt,
CreateAt = DateTime.UtcNow,
Order = order
Order = order,
});

return await this.Db.SaveChangesAsync() > 0;
Expand Down Expand Up @@ -121,16 +120,40 @@ public async Task<bool> OrderPostCancel(uint orderId, string reason) {
.Where(x => x.Status != OrderStatus.Finished)
.SingleAsync();

order.Status = OrderStatus.Cancelled;
order.Status = order.Status == OrderStatus.Shipping
? OrderStatus.Returning : OrderStatus.Cancelled;

order.Comments.Add(new() {
Content = "[User Cancel] " + reason,
CreateAt = DateTime.UtcNow,
Order = order
Order = order,
});

return await this.Db.SaveChangesAsync() > 0;
}

// TODO: OrderPostReceived
// TODO: OrderDelete
/**
* <remarks>
* @author Aloento
* @since 1.0.0
* @version 0.1.0
* </remarks>
*/
[Authorize]
public async Task<bool> OrderPostReceived(uint orderId) {
var order = await this.Db.Orders
.Where(x => x.UserId == this.UserId)
.Where(x => x.OrderId == orderId)
.Where(x => x.Status == OrderStatus.Shipping)
.SingleAsync();

order.Status = OrderStatus.Finished;
order.Comments.Add(new() {
Content = "[User Mark Received Order]",
CreateAt = DateTime.UtcNow,
Order = order,
});

return await this.Db.SaveChangesAsync() > 0;
}
}
3 changes: 2 additions & 1 deletion TSystems.LoveOTC/Models/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace TSystems.LoveOTC.Models;
public class Category : Concurrency {
public uint CategoryId { get; set; }

[StringLength(15, MinimumLength = 1)] public string Name { get; set; }
[StringLength(15, MinimumLength = 1)]
public string Name { get; set; }

public virtual ICollection<Product> Products { get; }
}
4 changes: 2 additions & 2 deletions TSystems.LoveOTC/Models/Combo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public class Combo : Concurrency, IArchive {

public virtual Product Product { get; set; }

public bool? IsArchived { get; set; }

public virtual ICollection<Type> Types { get; set; }

public virtual ICollection<ComboType> ComboTypes { get; init; }

public virtual ICollection<Order> Orders { get; init; }

public virtual ICollection<OrderCombo> OrderCombos { get; init; }

public bool? IsArchived { get; set; }
}
4 changes: 2 additions & 2 deletions TSystems.LoveOTC/Models/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class Product : Concurrency, IArchive {

public JsonElement? Description { get; set; }

public bool? IsArchived { get; set; }

public virtual ICollection<Variant> Variants { get; }

public virtual ICollection<Combo> Combos { get; }

public bool? IsArchived { get; set; }
}
4 changes: 2 additions & 2 deletions TSystems.LoveOTC/Models/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class Type : Concurrency, IArchive {

public virtual Variant Variant { get; set; }

public bool? IsArchived { get; set; }

public virtual ICollection<Combo> Combos { get; init; }

public virtual ICollection<ComboType> ComboTypes { get; init; }

public bool? IsArchived { get; set; }
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"update": "npx npm-check-updates -u"
},
"dependencies": {
"@fluentui/react-components": "^9.42.0",
"@fluentui/react-hooks": "^8.6.33",
"@fluentui/react-components": "^9.43.3",
"@fluentui/react-hooks": "^8.6.34",
"@fluentui/react-icons": "^2.0.224",
"@griffel/react": "^1.5.19",
"@lexical/clipboard": "^0.12.5",
Expand Down Expand Up @@ -51,9 +51,9 @@
"devDependencies": {
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.17",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react-swc": "^3.5.0",
"typescript": "^5.3.3",
"vite": "^5.0.8"
"vite": "^5.0.10"
}
}
Loading

0 comments on commit 034e10f

Please sign in to comment.