From 4b4c546aaaec3d9542f71b00df91ea9a4d33e604 Mon Sep 17 00:00:00 2001 From: Alihaghighattalab Date: Thu, 22 Aug 2024 17:07:33 +0330 Subject: [PATCH] complete installation device pagination --- package-lock.json | 40 ++++++++++++++++- package.json | 3 +- src/components/common/combo-box.tsx | 12 ++++- src/components/common/input.tsx | 8 ++-- src/components/common/table.tsx | 44 ++++++++++++++----- src/components/installation-reports/index.tsx | 34 ++++++++++---- src/services/api/auth.ts | 2 +- src/services/api/register-device.ts | 6 ++- src/store/params.ts | 23 ++++++++++ src/types/index.ts | 21 +++++---- src/utility/table-rows.ts | 24 ++++++++++ 11 files changed, 176 insertions(+), 41 deletions(-) create mode 100644 src/store/params.ts create mode 100644 src/utility/table-rows.ts diff --git a/package-lock.json b/package-lock.json index 3de3668..77dc5c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,8 @@ "react-scripts": "5.0.1", "typescript": "^4.9.5", "web-vitals": "^2.1.4", - "yup": "^1.4.0" + "yup": "^1.4.0", + "zustand": "^4.5.5" }, "devDependencies": { "@tanstack/eslint-plugin-query": "^5.51.15", @@ -19162,6 +19163,15 @@ "requires-port": "^1.0.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz", + "integrity": "sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -20275,6 +20285,34 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zustand": { + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.5.tgz", + "integrity": "sha512-+0PALYNJNgK6hldkgDq2vLrw5f6g/jCInz52n9RTpropGgeAf/ioFUCdtsjCqu4gNhW9D01rUQBROoRjdzyn2Q==", + "license": "MIT", + "dependencies": { + "use-sync-external-store": "1.2.2" + }, + "engines": { + "node": ">=12.7.0" + }, + "peerDependencies": { + "@types/react": ">=16.8", + "immer": ">=9.0.6", + "react": ">=16.8" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index 80b4f42..6da7e64 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "react-scripts": "5.0.1", "typescript": "^4.9.5", "web-vitals": "^2.1.4", - "yup": "^1.4.0" + "yup": "^1.4.0", + "zustand": "^4.5.5" }, "scripts": { "start": "react-scripts start", diff --git a/src/components/common/combo-box.tsx b/src/components/common/combo-box.tsx index 1b79ac1..7c89259 100644 --- a/src/components/common/combo-box.tsx +++ b/src/components/common/combo-box.tsx @@ -2,15 +2,18 @@ import { Combobox, ComboboxButton, ComboboxInput, ComboboxOption, ComboboxOption import { ArrowDown2 } from 'iconsax-react' import { FC, useState } from 'react' import { ComboBoxItems } from '../../types' +import { useParamsStore } from '../../store/params' type Props = { field?: any placeholder?: string className?: string, data?: ComboBoxItems[] | [] + mode?: "table" | "default" } -export const ComboBox: FC = ({ field, placeholder, className, data = [] }) => { +export const ComboBox: FC = ({ field, placeholder, className, data = [], mode = "default" }) => { + const { updateParams } = useParamsStore() const [query, setQuery] = useState('') const filteredValue = @@ -21,7 +24,12 @@ export const ComboBox: FC = ({ field, placeholder, className, data = [] } }) return ( - setQuery('')} disabled={data?.length <= 0}> + { + console.log(e) + updateParams({ + rows: e?.id + }) + }} onClose={() => setQuery('')} disabled={data?.length <= 0}>
void } -export const Input: FC = ({ placeholder, type = "text", icon, field, ref, className }) => { +export const Input: FC = ({ placeholder, type = "text", icon, field, ref, className, value, onChange }) => { const [hidden, setHidden] = useState(false) const handleHidden = () => setHidden(prev => !prev) return ( @@ -26,7 +28,7 @@ export const Input: FC = ({ placeholder, type = "text", icon, field, ref, : icon} {placeholder === "شماره کارت" && field.value && findBankByPAN(field.value).icon}
-