This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Back] Split OrderGetDetail - [Front] Merge OrderAppend | Split Order…
…Comment & OrderDetail | useItems | useSWR (#107) * Update dependencies in package.json and pnpm-lock.yaml * Update package.json and vite.config.ts * Update vite.config.ts with splitVendorChunkPlugin * The most significant changes involve renaming and replacing functions and components in `Append.tsx` and `Detail.tsx`. The `Order` property in the `IOrderInfo` interface has also been made optional, and a `@liveSafe` comment has been added to the `OrderEntity` class. 1. The `Order` property in the `IOrderInfo` interface in `OrderInfo.tsx` has been made optional. This change allows for instances where an order may not be present or necessary. (OrderInfo.tsx) 2. The `AdminOrderAppend` function in `Append.tsx` has been renamed to `AdminCommentAppend`. This change reflects a shift in functionality from appending orders to appending comments. (Append.tsx) 3. The `AdminOrderAppend` component in `Detail.tsx` has been replaced with `AdminCommentAppend`. This change ensures that the updated function is correctly referenced and used in the `Detail.tsx` file. (Detail.tsx) 4. The `OrderAppend` function in `Append.tsx` has been renamed to `CommentAppend`. Similar to the previous renaming, this change reflects a shift in functionality from appending orders to appending comments. (Append.tsx) 5. The `OrderAppend` component in `Detail.tsx` has been replaced with `CommentAppend`. This change ensures that the updated function is correctly referenced and used in the `Detail.tsx` file. (Detail.tsx) 6. The `OrderEntity` class in `Entity.ts` has been updated with a `@liveSafe` comment for the `Order` and `Comment` methods. This comment likely indicates that these methods have been reviewed and deemed safe for live deployment. (Entity.ts) * The most significant changes involve the removal of the `AdminCommentAppend` component from `Append.tsx` and its replacement with the `CommentAppend` component in `Detail.tsx`. Additionally, the `AdminHub` import was added to `Append.tsx` and the `IOrderAppend` interface was updated with the `Admin` prop. The `CommentAppend` function and `run: cancel` function in `Append.tsx` were also updated to use either `AdminHub` or `Hub` and `hub.useClose` or `hub.useCancel` respectively, based on the `Admin` prop. Lastly, the `Message` and `ToastTitle` in `Append.tsx` were updated to display either "Close" or "Cancel" based on the `Admin` prop. Changes: 1. Removed `AdminCommentAppend` component from `Append.tsx` along with its related imports and styles. 2. Replaced `AdminCommentAppend` import with `CommentAppend` import from a different path in `Detail.tsx`. 3. Replaced `AdminCommentAppend` component usage with `CommentAppend` component in `Detail.tsx`. 4. Added `AdminHub` import to `Append.tsx`. 5. Moved `Status` prop and added `Admin` prop in the `IOrderAppend` interface in `Append.tsx`. 6. Updated `CommentAppend` function in `Append.tsx` to include the `Admin` prop and to use either `AdminHub` or `Hub` based on the `Admin` prop. 7. Updated `run: cancel` function in `Append.tsx` to use either `hub.useClose` or `hub.useCancel` based on the `Admin` prop. 8. Updated `Message` and `ToastTitle` in `Append.tsx` to display either "Close" or "Cancel" based on the `Admin` prop. * Add "Admin" prop to CommentAppend component * The most significant changes involve the refactoring of the `OrderGetDetail` method in the `ShopHub` and `OrderGet` classes. This method has been split into two separate methods: `OrderGetItems` and `OrderGetCmts`, improving the separation of concerns in the code. The `OrderGet` class in `Get.ts` has been updated to reflect these changes. Additionally, a new `OrderComment` component has been added to `index.tsx` to display a list of comments related to an order. Here is a list of the changes: 1. The `OrderGetDetail` method in the `ShopHub` class has been split into `OrderGetItems` and `OrderGetCmts` methods. This change improves the separation of concerns in the code. 2. The `OrderGetDetail` method in the `OrderGet` class has been renamed to `OrderGetItems` and now returns an array of `ICartItem` objects. 3. A new method `OrderGetCmts` has been added to the `OrderGet` class. This method retrieves comments related to an order and returns an array of `IComment` objects. 4. The `Detail` method in the `OrderDetail` component has been updated to use the `OrderGetItems` method instead of the old `OrderGetDetail` method. 5. The `CommentAppend` component has been updated to include a condition for the admin user. If the user is an admin, the button text changes to "Force Close". 6. A new `OrderComment` component has been added to `index.tsx`. This component displays a list of comments related to an order. 7. The `IOrderDetail` import has been removed from `Get.ts` as it is no longer needed. 8. The `OrderGet` class in `Get.ts` has been updated to reflect the changes in the `ShopHub` class. The `Detail` method has been renamed to `Items` and a new `Cmts` method has been added. 9. The `OrderGet` class in `Get.ts` has been updated to use the new `OrderGetItems` and `OrderGetCmts` methods from the `ShopHub` class. The `Detail` method has been removed. 10. The `OrderGet` class in `Get.ts` has been updated to return the items and comments separately, instead of returning them together in a single object. * The most significant changes involve the introduction of a new interface `IOrderComp` and the refactoring of several functions to use this interface. The `OrderComment`, `OrderAction`, and `CommentAppend` functions now all take an `IOrderComp` object as a parameter. The `OrderDetail` function was also updated to include `OrderComment` and `OrderAction` components. Additionally, the `useRequest` hook was introduced in several places, and the `CommentAppend` component was moved to a different location. 1. New imports were added to `index.tsx`, including `useConst`, `useRequest`, `ICompLog`, `Hub`, and `CommentAppend` (index.tsx). 2. A new interface `IOrderComp` was added to `index.tsx`, extending `ICompLog` and adding new properties (index.tsx). 3. The `OrderComment` function was updated to take an `IOrderComp` object as a parameter and use the `useConst` and `useRequest` hooks (index.tsx). 4. The import of `CommentAppend` in `Detail.tsx` was updated (Detail.tsx). 5. The `IOrderAction` interface was removed and the `OrderAction` function was updated to take an `IOrderComp` object as a parameter (Action.tsx). 6. The entire contents of `Append.tsx` were replaced with new code defining a `CommentAppend` function (Append.tsx). 7. The entire contents of `Comment.tsx` were removed (Comment.tsx). 8. The `OrderDetail` function was updated to use the `useRequest` hook twice and include `OrderComment` and `OrderAction` components (Detail.tsx). 9. The import of `IComment` in `Get.ts` was updated (Get.ts). * Refactor Comment component and its dependencies * The most significant changes involve modifications to the import statements and function calls in Detail.tsx, Get.ts, and SignalR.ts. In Detail.tsx, the import path of `OrderComment` was changed and the `useRequest` function call was replaced with `Hub.Order.Get.useItems(OrderId, log)`. In Get.ts, new import statements were added and the `Items` method was refactored to use `useItems` instead of `async Items`. In SignalR.ts, new import statements were added and a new method `useSWR` was added to the `SignalR` class. 1. The import path of `OrderComment` was changed in Detail.tsx. (Detail.tsx) 2. The `useRequest` function call was replaced with `Hub.Order.Get.useItems(OrderId, log)` in Detail.tsx. (Detail.tsx) 3. The `runItem()` function call was removed from the `run` function in Detail.tsx. (Detail.tsx) 4. New import statements were added in Get.ts to import `useConst` and `useLiveQuery`. (Get.ts) 5. The `Items` method in the `OrderGet` class was refactored to use `useItems` instead of `async Items` in Get.ts. (Get.ts) 6. The `PhotoList` method in the `ProductGet` class was modified to use a constant `photoList` instead of a string literal in Get.ts. (Get.ts) 7. New import statements were added in SignalR.ts to import `useRequest` and `Options`. (SignalR.ts) 8. A new method `useSWR` was added to the `SignalR` class in SignalR.ts. (SignalR.ts) 9. A comment was added in SignalR.ts indicating a potential issue with the `LiveQuery` causing infinite refreshes. (SignalR.ts) * The most significant changes involve the replacement of the `dexie-react-hooks` library with the `useState` hook from React in the `Get.ts` file, and the replacement of the `useLiveQuery` hook with a manual implementation of state management and data fetching. These changes were made to have more control over state management and data fetching. Additionally, the `Promise.resolve` method was replaced with `Dexie.waitFor` in several files to ensure promises are resolved before proceeding with the next operation. Here are the changes in detail: 1. The `dexie-react-hooks` library was replaced with the `useState` hook from React in the `Get.ts` file for better state management within the component. 2. The `useLiveQuery` hook was removed and replaced with a manual implementation of state management and data fetching for more control over the data fetching process. 3. The `Promise.resolve` method was replaced with `Dexie.waitFor` in the `SignalR.ts` and `Table.ts` files to ensure promises are resolved before proceeding with the next operation. 4. The `Shared.Sto.delete` method was updated to be awaited in the `SignalR.ts` file to ensure the delete operation completes before proceeding. 5. The version annotation for the `useSWR` method in the `SignalR.ts` file was updated from `1.3.0` to `1.3.5`. 6. The `Table.ts` file was updated to use `Dexie.waitFor` instead of `Promise.resolve` when setting the value in the table to ensure the value is set before proceeding. 7. The `Table.ts` file was updated to format the object being put into the store in a more readable way to improve code readability. 8. The `Table.ts` file was updated to throw a `RangeError` if the expire time is less than the current time to prevent setting an expire time in the past. * The most significant changes involve the introduction of new hooks and the refactoring of the `DrawerBody` and `OrderGet` components. The `useEffect` and `useBoolean` hooks from the "ahooks" library have been updated, with the former now setting the state of `open` based on the comparison of `curr` and `OrderId`, and the latter now only using the `set` method. The `useInViewport` and `useRef` hooks have been added from the "ahooks" and "react" libraries respectively, and are used to create a reference to the `DrawerBody` component and check if it's in the viewport. The `DrawerBody` component has been updated to use a `ref` attribute and conditionally render the `DeferredBody` component if it's in the viewport. A new function `DeferredBody` has been added, which contains the previous logic for fetching and displaying order details. It uses the `useRequest` hook to fetch order and cart data and displays it using various components. The `useItems` method in the `OrderGet` class has been updated to use the `useSWR` hook to fetch data and returns an object containing the request and the data. Lastly, the version number in the `OrderDetail` function comment has been updated from 0.4.0 to 1.0.0. Changes: 1. Updated `useEffect` and `useBoolean` hooks from "ahooks" library. 2. Added `useInViewport` and `useRef` hooks from "ahooks" and "react" libraries. 3. Updated `DrawerBody` component to use a `ref` attribute and conditionally render `DeferredBody`. 4. Added new function `DeferredBody` for fetching and displaying order details. 5. Updated `useItems` method in `OrderGet` class to use `useSWR` hook. 6. Updated version number in `OrderDetail` function comment. * The most significant changes were made to the `Detail.tsx`, `Get.ts`, and `SignalR.ts` files. In `Detail.tsx`, the import statement was updated to include `SkeletonItem` from `@fluentui/react-components` and a `loading` state was added to the `DeferredBody` function. The `Get.ts` file was updated to use `useAsyncEffect` from `ahooks` for handling asynchronous operations. The `SignalR.ts` file saw changes in the `update` function, including the addition of a `setCache` function and changes to the conditions for updating the cache. 1. In `Detail.tsx`, the import statement was updated to include `SkeletonItem` from `@fluentui/react-components`. The `DeferredBody` function was updated to include a `loading` state from `Hub.Order.Get.useItems`. A `run` function was also added to run `runItems` and `runOrder` together. A `SkeletonItem` component was added to the JSX returned by the `DeferredBody` function to display a loading state. 2. In `Get.ts`, the import statement was updated to include `useAsyncEffect` from `ahooks`. The `OrderGet` class was updated to use `useAsyncEffect` to handle the asynchronous operations previously handled in the `onSuccess` callback. The logic within the `onSuccess` callback was moved into the `useAsyncEffect` hook. 3. In `SignalR.ts`, the `update` function within the `SignalR` class was updated to include a `setCache` function that sets a cache with a `QueryExp` value 10 seconds in the future. The `setCache` function was also updated to delete the cache if the response is null. The condition to update the cache was changed from `find.QueryExp <= dayjs().unix()` to `find.QueryExp < dayjs().unix()`. The `setCache` function that was previously outside the `update` function was removed. The `useRequest` function was updated to have a `staleTime` of 5000 instead of 1000.
- Loading branch information