diff --git a/apps/web/Components/Admin/AdminRow/AdminRow.tsx b/apps/web/Components/Admin/AdminRow/AdminRow.tsx new file mode 100644 index 0000000..af9b85c --- /dev/null +++ b/apps/web/Components/Admin/AdminRow/AdminRow.tsx @@ -0,0 +1,39 @@ +import style from '../AdminTable/Admin.module.css'; +import type { CollapseProps } from 'antd'; +import { Button, Collapse } from 'antd'; +import styled from 'styled-components'; + +type IProps = { + readonly data: string; + readonly index: number; + readonly name: string; + readonly onClick: (name: string) => void; +}; + +const Wrapper = styled.div` + display: flex; + justify-content: space-between; +`; + +export default function AdminRow(props: IProps) { + const { data, index, name, onClick } = props; + + const handleClick = () => { + onClick(name); + }; + + const items: CollapseProps['items'] = [ + { + children:

{data}

, + key: index.toString(), + label: data, + }, + ]; + + return ( + + + + + ); +} diff --git a/apps/web/Components/Admin/AdminRows/AdminRows.tsx b/apps/web/Components/Admin/AdminRows/AdminRows.tsx new file mode 100644 index 0000000..a6b5787 --- /dev/null +++ b/apps/web/Components/Admin/AdminRows/AdminRows.tsx @@ -0,0 +1,35 @@ +import AdminRow from '../AdminRow/AdminRow'; +import type { CollapseProps } from 'antd'; +import { Collapse } from 'antd'; + +export default function AdminRows({ + index, + name, + onClick, + queries, +}: { + readonly index: number; + readonly name: string; + readonly onClick: (name: string) => void; + readonly queries: string[]; +}) { + if (queries.length === 0) { + const items2: CollapseProps['items'] = [ + { + children: null, + key: index.toString(), + label: name, + }, + ]; + + return ; + } + + const rows: CollapseProps['items'] = queries.map((x, ind) => ({ + children: , + key: index.toString(), + label: name, + })); + + return ; +} diff --git a/apps/web/Components/Admin/AdminTable/Admin.module.css b/apps/web/Components/Admin/AdminTable/Admin.module.css new file mode 100644 index 0000000..2305fa0 --- /dev/null +++ b/apps/web/Components/Admin/AdminTable/Admin.module.css @@ -0,0 +1,3 @@ +.collapse { + flex-grow: 1; +} diff --git a/apps/web/Components/Admin/AdminTable/AdminTable.tsx b/apps/web/Components/Admin/AdminTable/AdminTable.tsx new file mode 100644 index 0000000..5f6bff7 --- /dev/null +++ b/apps/web/Components/Admin/AdminTable/AdminTable.tsx @@ -0,0 +1,38 @@ +import AdminRows from '../AdminRows/AdminRows'; +import { deleteQuery, getQueries } from '@/api/cache/query'; +import type { ResponseQueries } from '@/api/cache/types'; +import { useEffect, useState } from 'react'; + +export default function AdminTable() { + const [data, setData] = useState({}); + + const handleClick = async (name: string) => { + await deleteQuery(name); + const queryList = await getQueries(); + setData(queryList); + }; + + useEffect(() => { + const getRows = async () => { + const queryList = await getQueries(); + // debugger; + setData(queryList); + }; + + getRows(); + }, []); + + return ( + <> + {Object.keys(data).map((key, index) => ( + + ))} + + ); +} diff --git a/apps/web/pages/admin.jsx b/apps/web/pages/admin.jsx new file mode 100644 index 0000000..f96c90d --- /dev/null +++ b/apps/web/pages/admin.jsx @@ -0,0 +1,56 @@ +import { makeGetServerSideProps } from '.'; +import AdminTable from '@/Components/Admin/AdminTable/AdminTable'; +import { Error } from '@/Components/Common/Error'; +import Background from '@/Components/Layout/Background'; +import { Grid } from '@/Components/Layout/Page'; +import { unlimitedRoles } from '@/config/users'; +import * as hooks from '@/process/hooks'; +import { useStore } from '@/stores/hooks'; +import { min } from '@/styles/mq'; +import Head from 'next/head'; +import styled from 'styled-components'; + +function Content() { + const store = useStore(); + store.$process.add('Unlimited'); + + hooks.useSentryScope(); + hooks.useMainData(); + hooks.useGetUsers(); + hooks.useInsuranceData(); + hooks.useReactions(); + + const Wrapper = styled(Background)` + padding: 4px 6px; + + ${min('tablet')} { + min-height: 790px; + } + + ${min('laptop')} { + padding: 4px 6px 10px; + } + `; + + return ( + + + Админка + + + + + + + ); +} + +export default function Admin(props) { + if (props.statusCode !== 200) return ; + + return ; +} + +export const getServerSideProps = makeGetServerSideProps({ + roles: unlimitedRoles, +});