From 4048db9b62ff6e907c7fc1455e286c6bc3c34398 Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:53:34 +0100 Subject: [PATCH 1/4] Updated Confirm.tsx and related components Updated import statement in Confirm.tsx to include additional components from "@fluentui/react-icons/lib/fonts" and replaced ColFlex with Flex. Updated version of Confirm component in author comments. Added new 'title' style property to useStyles hook. Replaced Toast component with DialogSurface component for displaying success message after order placement. Swapped order of Update([]) and Nav("History", data) functions in onSuccess function and added new onStatusChange function to toast dispatch function. --- src/Components/ShopCart/Confirm.tsx | 46 ++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/Components/ShopCart/Confirm.tsx b/src/Components/ShopCart/Confirm.tsx index 640dfa3..38dccfe 100644 --- a/src/Components/ShopCart/Confirm.tsx +++ b/src/Components/ShopCart/Confirm.tsx @@ -1,11 +1,12 @@ -import { Button, Field, Textarea, Toast, ToastBody, ToastTitle, makeStyles, tokens } from "@fluentui/react-components"; +import { Badge, Button, DialogBody, DialogContent, DialogSurface, DialogTitle, Field, Textarea, makeStyles, tokens } from "@fluentui/react-components"; import { Drawer, DrawerBody, DrawerHeader, DrawerHeaderTitle } from "@fluentui/react-components/unstable"; import { useConst } from "@fluentui/react-hooks"; import { DismissRegular } from "@fluentui/react-icons"; +import { CheckmarkFilled } from "@fluentui/react-icons/lib/fonts"; import { useBoolean } from "ahooks"; import { useState } from "react"; import { Logger } from "~/Helpers/Logger"; -import { ColFlex } from "~/Helpers/Styles"; +import { ColFlex, Flex } from "~/Helpers/Styles"; import { useErrorToast } from "~/Helpers/useToast"; import { Hub } from "~/ShopNet"; import { DelegateDataGrid } from "../DataGrid"; @@ -17,7 +18,7 @@ import { PersonaInfo } from "./Persona"; /** * @author Aloento * @since 0.5.0 - * @version 0.1.0 + * @version 0.2.0 */ const useStyles = makeStyles({ body: { @@ -27,6 +28,11 @@ const useStyles = makeStyles({ sub: { width: "fit-content", alignSelf: "flex-end" + }, + title: { + ...Flex, + alignItems: "center", + columnGap: tokens.spacingHorizontalM, } }); @@ -35,7 +41,7 @@ const log = new Logger("TopNavBar", "ShopCart", "Confirm"); /** * @author Aloento * @since 0.1.0 - * @version 0.4.2 + * @version 0.5.0 */ export function Confirm() { const [cmt, setCmt] = useState(); @@ -58,16 +64,34 @@ export function Confirm() { }, onSuccess(data) { dispatchToast( - - Order Placed - Order Id: {data} - , - { intent: "success" } + + + + } /> + Thank You! + + + + Your order {data} has been placed and is being processed. +

+ You can click Avatar -{">"} History to view details, +
+ send us an additional comment or even cancel it. +

+ You will now be taken to your order details. +
+
+
, + { + onStatusChange(_, toast) { + if (toast.status === "unmounted") + Nav("History", data); + }, + } ); - Update([]); toggle(); - Nav("History", data); + Update([]); }, }); From 257d033f81eb2487fae62bb64e797d077d38b2c7 Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:30:08 +0100 Subject: [PATCH 2/4] Split `Name` field into `Surname` and `Forename` This commit splits the `Name` field into two separate fields: `Surname` and `Forename` across various classes and components including `AdminHub`, `ShopHub`, `DataSeeder`, `Persona`, `User`, `Setting`, and `PersonaInfo`. This change allows for more detailed user information. The `Name` field in the `Comment` type of the `OrderEntity` namespace has also been replaced with `Forename` to align with this change. Version numbers in `ShopHub`, `Persona`, and `User` classes have been updated. Tooltips and labels in the `Setting` component have been updated to reflect this change. Lastly, the `OrderGet` class now uses `Forename` instead of `Name` when creating comment objects. --- SoarCraft.AwaiShop/AdminHub/Order/Export.cs | 4 +- SoarCraft.AwaiShop/AdminHub/User/Entity.cs | 3 +- SoarCraft.AwaiShop/Helpers/DataSeeder.cs | 3 +- SoarCraft.AwaiShop/Hub/Order/Entity.cs | 4 +- SoarCraft.AwaiShop/Hub/User/Get.cs | 5 +- SoarCraft.AwaiShop/Hub/User/Persona.cs | 10 ++-- SoarCraft.AwaiShop/Hub/User/Post.cs | 8 ++-- SoarCraft.AwaiShop/Models/User.cs | 9 ++-- src/Components/Setting.tsx | 52 +++++++++++++++------ src/Components/ShopCart/Persona.tsx | 8 ++-- src/ShopNet/Order/Entity.ts | 2 +- src/ShopNet/Order/Get.ts | 2 +- 12 files changed, 73 insertions(+), 37 deletions(-) diff --git a/SoarCraft.AwaiShop/AdminHub/Order/Export.cs b/SoarCraft.AwaiShop/AdminHub/Order/Export.cs index 00b1ff0..cd9aaab 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 73a83b5..f005b1f 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 57902ce..d053c7d 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 39c31d3..1d71faf 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] @@ -51,7 +51,7 @@ public async Task OrderEntity(uint key, uint? version) { .Where(x => x.CommentId == key && x.Order.UserId == this.UserId) .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 318fd59..3dfbe58 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 a64fb12..608d96e 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 efe61af..07db210 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! @@ -53,7 +54,8 @@ await this.Db.Users.AddAsync(new() { 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/Models/User.cs b/SoarCraft.AwaiShop/Models/User.cs index 1e3c5b5..32fe5bb 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/Setting.tsx b/src/Components/Setting.tsx index 415a9f7..d4308b3 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]); @@ -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) {