diff --git a/SoarCraft.AwaiShop/AdminHub/Order/Export.cs b/SoarCraft.AwaiShop/AdminHub/Order/Export.cs index 00b1ff01..cd9aaab9 100644 --- a/SoarCraft.AwaiShop/AdminHub/Order/Export.cs +++ b/SoarCraft.AwaiShop/AdminHub/Order/Export.cs @@ -182,7 +182,7 @@ public async IAsyncEnumerable ExportOrder() { data.AddRange([ new() { DataType = CellValues.SharedString, - CellValue = new(shared(user.Name)) + CellValue = new(shared($"{user.Surname}, {user.Forename}")) }, new() { DataType = CellValues.SharedString, @@ -207,7 +207,7 @@ public async IAsyncEnumerable ExportOrder() { prev.Append('['); prev.Append(curr.CreateAt.ToString("yyyy-MM-dd HH:mm")); prev.Append("] : "); - prev.AppendLine(curr.User?.Name ?? "User"); + prev.AppendLine(curr.User?.Forename ?? "User"); prev.AppendLine(curr.Content); return prev; diff --git a/SoarCraft.AwaiShop/AdminHub/User/Entity.cs b/SoarCraft.AwaiShop/AdminHub/User/Entity.cs index 73a83b5d..f005b1f8 100644 --- a/SoarCraft.AwaiShop/AdminHub/User/Entity.cs +++ b/SoarCraft.AwaiShop/AdminHub/User/Entity.cs @@ -21,7 +21,8 @@ internal partial class AdminHub { return await this.Db.Users .Where(x => x.UserId == key) .Select(x => new { - x.Name, + x.Surname, + x.Forename, x.EMail, x.Phone, x.Address, diff --git a/SoarCraft.AwaiShop/Helpers/DataSeeder.cs b/SoarCraft.AwaiShop/Helpers/DataSeeder.cs index 57902ce9..d053c7d0 100644 --- a/SoarCraft.AwaiShop/Helpers/DataSeeder.cs +++ b/SoarCraft.AwaiShop/Helpers/DataSeeder.cs @@ -16,7 +16,8 @@ public static async Task SeedData(IApplicationBuilder host) { var user = context.Users.Add(new() { UserId = Guid.Parse("171B20BE-E180-410D-AAE2-EE28773AA0B7"), - Name = "Aloento", + Surname = "Aloento", + Forename = "Soar", EMail = "me@example.com", Phone = "+1 300000000", Address = "Address, Address", diff --git a/SoarCraft.AwaiShop/Hub/Order/Entity.cs b/SoarCraft.AwaiShop/Hub/Order/Entity.cs index 39c31d37..00b554aa 100644 --- a/SoarCraft.AwaiShop/Hub/Order/Entity.cs +++ b/SoarCraft.AwaiShop/Hub/Order/Entity.cs @@ -35,7 +35,7 @@ public async Task OrderEntity(uint key, uint? version) { * * @author Aloento * @since 0.5.0 - * @version 0.1.1 + * @version 0.2.0 * */ [Authorize] @@ -49,9 +49,10 @@ public async Task OrderEntity(uint key, uint? version) { return await this.Db.Comments .Where(x => x.CommentId == key && x.Order.UserId == this.UserId) + .Include(x => x.User) .Select(x => new { x.Content, - x.User!.Name, + x.User!.Forename, x.CreateAt, x.Version }) diff --git a/SoarCraft.AwaiShop/Hub/User/Get.cs b/SoarCraft.AwaiShop/Hub/User/Get.cs index 318fd590..3dfbe583 100644 --- a/SoarCraft.AwaiShop/Hub/User/Get.cs +++ b/SoarCraft.AwaiShop/Hub/User/Get.cs @@ -8,7 +8,7 @@ internal partial class ShopHub { * * @author Aloento * @since 0.5.0 - * @version 0.1.1 + * @version 0.2.0 * */ [Authorize] @@ -26,7 +26,8 @@ internal partial class ShopHub { return await this.Db.Users .Where(x => x.UserId == this.UserId) .Select(x => new { - x.Name, + x.Surname, + x.Forename, x.EMail, x.Phone, x.Address, diff --git a/SoarCraft.AwaiShop/Hub/User/Persona.cs b/SoarCraft.AwaiShop/Hub/User/Persona.cs index a64fb12a..608d96ed 100644 --- a/SoarCraft.AwaiShop/Hub/User/Persona.cs +++ b/SoarCraft.AwaiShop/Hub/User/Persona.cs @@ -6,13 +6,17 @@ namespace SoarCraft.AwaiShop.Hub; * * @author Aloento * @since 0.1.0 - * @version 0.1.0 + * @version 0.2.0 * */ internal class Persona { [Required] - [StringLength(50, MinimumLength = 2)] - public string? Name { get; set; } + [StringLength(20, MinimumLength = 2)] + public string? Surname { get; set; } + + [Required] + [StringLength(20, MinimumLength = 2)] + public string? Forename { get; set; } [Required] [Phone] diff --git a/SoarCraft.AwaiShop/Hub/User/Post.cs b/SoarCraft.AwaiShop/Hub/User/Post.cs index efe61af4..2d139771 100644 --- a/SoarCraft.AwaiShop/Hub/User/Post.cs +++ b/SoarCraft.AwaiShop/Hub/User/Post.cs @@ -12,7 +12,7 @@ internal partial class ShopHub { * * @author Aloento * @since 0.5.0 - * @version 0.1.2 + * @version 0.2.0 * */ [Authorize] @@ -38,7 +38,8 @@ public async Task UserPostUpdate(Persona req) { await this.Db.Users.AddAsync(new() { UserId = this.UserId, - Name = req.Name!, + Surname = req.Surname!, + Forename = req.Forename!, EMail = req.EMail!, Phone = req.Phone!, Address = req.Address! @@ -46,14 +47,15 @@ await this.Db.Users.AddAsync(new() { var row1 = await this.Db.SaveChangesAsync(); this.Context.Items.Remove("NewUser"); - this.Logger.NewUser(req.Name, this.Context); + this.Logger.NewUser($"{req.Surname}, {req.Forename}", this.Context); return row1 > 0; } var row = await this.Db.Users .Where(x => x.UserId == this.UserId) .ExecuteUpdateAsync(x => x - .SetProperty(u => u.Name, req.Name!) + .SetProperty(u => u.Surname, req.Surname!) + .SetProperty(u => u.Forename, req.Forename!) .SetProperty(u => u.EMail, req.EMail!) .SetProperty(u => u.Phone, req.Phone!) .SetProperty(u => u.Address, req.Address!) diff --git a/SoarCraft.AwaiShop/Migrations/20240301205204_Init.Designer.cs b/SoarCraft.AwaiShop/Migrations/20240304123656_Init.Designer.cs similarity index 98% rename from SoarCraft.AwaiShop/Migrations/20240301205204_Init.Designer.cs rename to SoarCraft.AwaiShop/Migrations/20240304123656_Init.Designer.cs index ff1c22de..532b6737 100644 --- a/SoarCraft.AwaiShop/Migrations/20240301205204_Init.Designer.cs +++ b/SoarCraft.AwaiShop/Migrations/20240304123656_Init.Designer.cs @@ -12,7 +12,7 @@ namespace SoarCraft.AwaiShop.Migrations { [DbContext(typeof(ShopContext))] - [Migration("20240301205204_Init")] + [Migration("20240304123656_Init")] partial class Init { /// @@ -356,16 +356,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasMaxLength(100) .HasColumnType("character varying(100)"); - b.Property("Name") + b.Property("Forename") .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); + .HasMaxLength(20) + .HasColumnType("character varying(20)"); b.Property("Phone") .IsRequired() .HasMaxLength(15) .HasColumnType("character varying(15)"); + b.Property("Surname") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + b.Property("Version") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() diff --git a/SoarCraft.AwaiShop/Migrations/20240301205204_Init.cs b/SoarCraft.AwaiShop/Migrations/20240304123656_Init.cs similarity index 98% rename from SoarCraft.AwaiShop/Migrations/20240301205204_Init.cs rename to SoarCraft.AwaiShop/Migrations/20240304123656_Init.cs index ecc72a43..52083519 100644 --- a/SoarCraft.AwaiShop/Migrations/20240301205204_Init.cs +++ b/SoarCraft.AwaiShop/Migrations/20240304123656_Init.cs @@ -47,7 +47,8 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: table => new { UserId = table.Column(type: "uuid", nullable: false), - Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Surname = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + Forename = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), EMail = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Phone = table.Column(type: "character varying(15)", maxLength: 15, nullable: false), Address = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), diff --git a/SoarCraft.AwaiShop/Migrations/ShopContextModelSnapshot.cs b/SoarCraft.AwaiShop/Migrations/ShopContextModelSnapshot.cs index fbdf607d..3533e392 100644 --- a/SoarCraft.AwaiShop/Migrations/ShopContextModelSnapshot.cs +++ b/SoarCraft.AwaiShop/Migrations/ShopContextModelSnapshot.cs @@ -353,16 +353,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(100) .HasColumnType("character varying(100)"); - b.Property("Name") + b.Property("Forename") .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); + .HasMaxLength(20) + .HasColumnType("character varying(20)"); b.Property("Phone") .IsRequired() .HasMaxLength(15) .HasColumnType("character varying(15)"); + b.Property("Surname") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + b.Property("Version") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() diff --git a/SoarCraft.AwaiShop/Models/User.cs b/SoarCraft.AwaiShop/Models/User.cs index 1e3c5b5a..32fe5bb9 100644 --- a/SoarCraft.AwaiShop/Models/User.cs +++ b/SoarCraft.AwaiShop/Models/User.cs @@ -8,15 +8,18 @@ * * @author Aloento * @since 0.1.0 - * @version 0.1.0 + * @version 1.0.0 * */ [Index(nameof(EMail), IsUnique = true)] public class User : Concurrency { public Guid UserId { get; set; } - [StringLength(50, MinimumLength = 2)] - public required string Name { get; set; } + [StringLength(20, MinimumLength = 2)] + public required string Surname { get; set; } + + [StringLength(20, MinimumLength = 2)] + public required string Forename { get; set; } [EmailAddress] [StringLength(100, MinimumLength = 6)] diff --git a/src/Components/Order/Info.tsx b/src/Components/Order/Info.tsx index dd167f0c..b869318d 100644 --- a/src/Components/Order/Info.tsx +++ b/src/Components/Order/Info.tsx @@ -52,7 +52,7 @@ export function OrderInfo({ OrderId, Admin, ParentLog }: IOrderComp) {
- +
diff --git a/src/Components/Setting.tsx b/src/Components/Setting.tsx index 415a9f7c..39240d4f 100644 --- a/src/Components/Setting.tsx +++ b/src/Components/Setting.tsx @@ -1,5 +1,5 @@ import { useMsal } from "@azure/msal-react"; -import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, DialogTrigger, Field, Input, Label, Toast, ToastBody, ToastTitle, Tooltip, makeStyles, tokens } from "@fluentui/react-components"; +import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, DialogTrigger, Field, Input, Toast, ToastBody, ToastTitle, Tooltip, makeStyles, tokens } from "@fluentui/react-components"; import { useEffect, useState } from "react"; import { Logger } from "~/Helpers/Logger"; import { ColFlex, Flex } from "~/Helpers/Styles"; @@ -39,13 +39,15 @@ const log = new Logger("Setting"); /** * @author Aloento * @since 0.1.0 - * @version 0.7.0 + * @version 0.8.0 */ export function Setting({ Open, Toggle, New }: ISetting) { const style = useStyles(); const claim = useMsal().instance.getActiveAccount(); - const [name, setName] = useState(); + const [surname, setSurname] = useState(); + const [forename, setForename] = useState(); + const [phone, setPhone] = useState(); const [address, setAddress] = useState(); @@ -54,9 +56,10 @@ export function Setting({ Open, Toggle, New }: ISetting) { useEffect(() => { if (New || !data) return; - const { Name, Phone, Address } = data; + const { Surname, Forename, Phone, Address } = data; - setName(Name); + setSurname(Surname); + setForename(Forename); setPhone(Phone); setAddress(Address); }, [data]); @@ -82,7 +85,7 @@ export function Setting({ Open, Toggle, New }: ISetting) { Info {New ? "Created" : "Updated"} - {req.Name} + {req.Surname}, {req.Forename}
{req.Phone}
@@ -111,17 +114,29 @@ export function Setting({ Open, Toggle, New }: ISetting) {
- - setName(v.value)} /> + + setSurname(v.value)} /> + + setForename(v.value)} /> + + +
+ +
+ @@ -129,14 +144,20 @@ export function Setting({ Open, Toggle, New }: ISetting) { setPhone(v.value)} /> -
- - - + + + + + +
@@ -155,7 +176,8 @@ export function Setting({ Open, Toggle, New }: ISetting) {