Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

[Front] Remove DefaultDataGrid - [Front] AdminProductRow - [Front | Hub] useMe with LiveQuery | Remove UserData #93

Merged
merged 7 commits into from
Jan 15, 2024

Conversation

Aloento
Copy link
Owner

@Aloento Aloento commented Jan 15, 2024

No description provided.

…unction across multiple files and the introduction of the `useEffect` hook in `Setting.tsx`. The `useMe` function no longer destructures `data` from the returned object, instead directly assigning `data` the return value of `useMe`. This change is reflected in `AvatarMenu.tsx`, `OrderInfo.tsx`, `Setting.tsx`, `Persona.tsx`, `index.tsx`, `Get.tsx`, and `Post.ts`. In `Setting.tsx`, the `useEffect` hook has been added to manage the setting of `Name`, `Phone`, and `Address` state variables based on the `data` returned from `useMe`.

Changes:

1. Refactored `useMe` function to directly assign `data` the return value of `useMe` in `AvatarMenu.tsx`, `OrderInfo.tsx`, `Setting.tsx`, `Persona.tsx`, `index.tsx`, `Get.tsx`, and `Post.ts`.
2. Added `useEffect` hook in `Setting.tsx` to handle the setting of `Name`, `Phone`, and `Address` state variables based on the `data` returned from `useMe`.
3. Updated `useState` import statement in `Setting.tsx` to also import `useEffect`.
4. Updated `version` in the author comments for `OrderInfo.tsx` and `Setting.tsx`.
5. Replaced `loading` check with a check for the existence of `data` in `index.tsx`.
6. Removed code related to `Subject`, `IPersona`, `IConcurrency`, `ShopNet`, and `UserData` from `Data.ts`.
7. Replaced `useRequest` import statement with `useLiveQuery` from `dexie-react-hooks` in `Get.tsx`. Refactored `useMe` function to use `useLiveQuery` instead of `useRequest`.
8. Updated `UserGet` and `UserPost` classes in `Get.tsx` and `Post.ts` to extend `ShopNet` instead of `UserData`.
9. Refactored `useUpdate` function in `Post.ts` to directly return the updated object instead of calling `this.SubMe.next(res)`.
…y` property in the `IProductItem` interface to be optional, the update of the version annotation for the `AdminProduct` function, and the alteration of the `record` object creation process.

1. The `Category` property in the `IProductItem` interface has been made optional. This change simplifies the process of creating an object of type `IProductItem` as it is no longer necessary to provide a value for `Category`. This could potentially streamline the code and reduce errors related to missing `Category` values.

2. The version annotation for the `AdminProduct` function has been updated from 1.1.0 to 1.1.1. This indicates that the changes made in this commit are considered a minor update or bug fix. This could be important for users or developers who are tracking the version history of this function.

3. The creation process for the `record` object has been changed. Instead of being an empty object, it is now created by reducing over the `rawList` array. Each item in `rawList` is used as a key in the `record` object, with the value being an object with properties `Id`, `Cover`, and `Name`. This change likely improves the efficiency of the code by reducing the need for subsequent mutations of the `record` object.

References to the code changes can be found in the commit history of the project.
…ataGrid` component from `Delegate.tsx` to `index.tsx`, and the subsequent updates to import statements in various files. The `DefaultDataGrid` component was also removed and replaced with `DelegateDataGrid` in all instances. Additionally, the `renderHeaderCell` and `renderCell` functions, as well as the `columns` array and `AdminUser` function in `index.tsx` were updated. Lastly, version numbers in author comments were updated.

1. The `DelegateDataGrid` component was moved from `Delegate.tsx` to `index.tsx`. This involved removing the component and its associated interface `IDataGrid` from `Delegate.tsx` and adding them to `index.tsx`.
2. Import statements in various files were updated to reflect the relocation of `DelegateDataGrid`, replacing `import { DelegateDataGrid } from "~/Components/DataGrid/Delegate"` with `import { DelegateDataGrid } from "~/Components/DataGrid"`.
3. The `DefaultDataGrid` component was removed from `index.tsx` and all instances of it were replaced with `DelegateDataGrid`.
4. The `renderHeaderCell` and `renderCell` functions in `index.tsx` were updated to return `DataGridHeaderCell` and `DataGridCell` components respectively.
5. The `columns` array in `index.tsx` was updated to map each column to an object with `renderHeaderCell` and `renderCell` functions that return `DataGridHeaderCell` and `DataGridCell` components respectively.
6. The `AdminUser` function in `index.tsx` was updated to use `DelegateDataGrid` instead of `DefaultDataGrid`.
7. Version numbers in the author comments were updated in several places.
…AdminProductRow` in `Row.tsx`, the update of import statements in `index.tsx`, and the replacement of the `DelegateDataGrid` component with a `DataGrid` component in the `AdminProduct` function. Additionally, the `rawList` variable was renamed to `idList`, and the `DataGridBody` component now uses the `AdminProductRow` component to render each row. A `SkeletonItem` component was also added to display a loading state when `idList` is not available.

1. A new function `AdminProductRow` was added in `Row.tsx` which takes `item` and `rowId` as parameters and returns a `DataGridRow` component with `renderCell` method.
2. The import statement in `index.tsx` was updated to include additional components from `@fluentui/react-components` and remove the `DelegateDataGrid` component. The `AdminProductRow` component was also added to the import statement.
3. The `renderHeaderCell` method in the `columns` constant was simplified to a single line for each column.
4. The `rawList` variable was renamed to `idList` in the `AdminProduct` function and all its occurrences were updated accordingly.
5. The `DelegateDataGrid` component in the return statement of `AdminProduct` function was replaced with a `DataGrid` component which includes `DataGridHeader`, `DataGridRow`, `DataGridBody` and `SkeletonItem` components.
6. The `DataGridBody` component now uses the `AdminProductRow` component to render each row.
7. The `SkeletonItem` component was added to display a loading state when `idList` is not available.
…ductRow` function in `Row.tsx` and the `AdminProduct` function in `index.tsx`. The `AdminProductRow` function has been updated to use local state and asynchronous fetching for product details, including the product's cover photo and count. It now also uses various services and hooks for fetching data, managing state, and logging. The `AdminProduct` function has been simplified and now uses the product list from a service, and it has been updated to use various components and services.

Changes:

1. Refactored `AdminProductRow` function in `Row.tsx` to use local state and asynchronous fetching for product details. [AdminProductRow]
2. Simplified `AdminProduct` function in `index.tsx` to use product list from a service. [AdminProduct]
3. Updated `IProductItem` interface in `index.tsx` to be exported. [IProductItem]
4. Updated `PhotoList` method in `Get.ts` to handle errors when fetching the photo list and individual photos. [PhotoList]
5. Updated `AdminProductRow` function in `Row.tsx` to use `id` from `item` prop. [AdminProductRow]
6. Updated `DataGridRow` component in `Row.tsx` to use `detail` state. [DataGridRow]
7. Updated `DataGrid` component in `index.tsx` to reverse the order of the `idList`. [DataGrid]
8. Updated `AdminProductRow` function in `Row.tsx` to use `useBoolean` hook to manage `block` state. [AdminProductRow]
9. Updated `AdminProductRow` function in `Row.tsx` to use `useAsyncEffect` hook to fetch product detail asynchronously. [AdminProductRow]
10. Updated `AdminProductRow` function in `Row.tsx` to use various services to fetch product detail. [AdminProductRow]
11. Updated `AdminProductRow` function in `Row.tsx` to use `Logger` service for logging. [AdminProductRow]
12. Updated `AdminProductRow` function in `Row.tsx` to use `useState` hook to manage `detail` state. [AdminProductRow]
13. Updated `AdminProductRow` function in `Row.tsx` to use `IProductItem` interface. [AdminProductRow]
14. Updated `AdminProductRow` function in `Row.tsx` to use a constant `log` for logging. [AdminProductRow]
15. Updated `AdminProduct` function in `index.tsx` to use a service to fetch the product list. [AdminProduct]
16. Updated `AdminProduct` function in `index.tsx` to use `DataGrid` component with reversed `idList` and `columns` props. [AdminProduct]
17. Updated `AdminProduct` function in `index.tsx` to use `DataGridHeader` and `DataGridRow` components with `renderHeaderCell` prop. [AdminProduct]
18. Updated `PhotoList` method in `Get.ts` to use `GetTimeCache` service with error handling. [PhotoList]
19. Updated `PhotoList` method in `Get.ts` to use `Photo` service with error handling. [PhotoList]
20. Updated `PhotoList` method in `Get.ts` to use `ids` or an empty array if `ids` is not available. [PhotoList]
21. Updated `PhotoList` method in `Get.ts` to use a constant `log` for logging. [PhotoList]
@Aloento Aloento self-assigned this Jan 15, 2024
@Aloento Aloento merged commit 00eeff2 into master Jan 15, 2024
1 check passed
@Aloento Aloento deleted the Dev branch January 15, 2024 22:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant