From e0688a140600b6f118e04ac957836b43698a81bb Mon Sep 17 00:00:00 2001 From: Don Strawsburg Date: Sun, 19 Jan 2025 23:49:48 -0500 Subject: [PATCH] accounts table and many other fixes --- src/actions/accountActions.ts | 11 ++- src/actions/componentTypeActions.ts | 4 + src/actions/manufacturerActions.ts | 3 + src/actions/userActions.ts | 2 +- src/app/(siteInfo)/Blog/page.tsx | 1 - src/app/(siteInfo)/Disclosure/page.tsx | 1 - src/app/(siteInfo)/Footer/page.tsx | 1 - src/app/(siteInfo)/Jobs/page.tsx | 1 - src/app/(siteInfo)/Press/page.tsx | 1 - src/app/(siteInfo)/TOS/page.tsx | 1 - src/app/Accounts/page.tsx | 28 ++++-- src/app/Admin/Users/page.tsx | 2 +- src/app/Products/optics/page.tsx | 18 ++++ src/components/Account/index.tsx | 14 --- src/components/AccountsTable/index.tsx | 106 ++++++++++++++++++++++ src/components/HomeContent/index.tsx | 6 +- src/components/admin/UsersTable/index.tsx | 2 +- src/components/footer/index.tsx | 1 + src/db/queries/Accounts/index.ts | 7 +- src/db/queries/PSA/index.ts | 11 +++ src/drizzle/schema/schema.ts | 27 +++++- tsconfig.json | 3 + 22 files changed, 208 insertions(+), 43 deletions(-) create mode 100644 src/app/Products/optics/page.tsx delete mode 100644 src/components/Account/index.tsx create mode 100644 src/components/AccountsTable/index.tsx diff --git a/src/actions/accountActions.ts b/src/actions/accountActions.ts index 6d2cd5c..668d1d2 100644 --- a/src/actions/accountActions.ts +++ b/src/actions/accountActions.ts @@ -3,9 +3,18 @@ import { eq, not , asc} from "drizzle-orm"; import { revalidatePath } from "next/cache"; import { db } from "@db/index"; import { accounts } from "@schemas/schema"; +import { vw_accounts } from "@schemas/schema"; export const getData = async () => { - const data = await db.select().from(accounts).orderBy(asc(accounts.last_name)); + const data = await db.select().from(accounts).orderBy(asc(accounts.userId)); + return data; +}; +export const getAllAccounts = async () => { + return getData(); +}; + +export const getViewAccounts = async () => { + const data = await db.select().from(vw_accounts).orderBy(asc(vw_accounts.last_name)); return data; }; diff --git a/src/actions/componentTypeActions.ts b/src/actions/componentTypeActions.ts index 2c945a5..d2501bb 100644 --- a/src/actions/componentTypeActions.ts +++ b/src/actions/componentTypeActions.ts @@ -3,8 +3,12 @@ import { eq, not , asc} from "drizzle-orm"; import { revalidatePath } from "next/cache"; import { db } from "../db"; import { componentType } from "@schemas/schema"; + export const getData = async () => { const data = await db.select().from(componentType).orderBy(asc(componentType.name)); return data; }; +export const getComponentTypeName = async () => { + return getData(); +}; \ No newline at end of file diff --git a/src/actions/manufacturerActions.ts b/src/actions/manufacturerActions.ts index 0613264..0db555c 100644 --- a/src/actions/manufacturerActions.ts +++ b/src/actions/manufacturerActions.ts @@ -10,3 +10,6 @@ export const getData = async () => { return data; }; +export const getManufacturersName = async () => { + return getData(); +}; diff --git a/src/actions/userActions.ts b/src/actions/userActions.ts index 296d5bd..04a7b1b 100644 --- a/src/actions/userActions.ts +++ b/src/actions/userActions.ts @@ -8,7 +8,7 @@ export const getData = async () => { const data = await db.select().from(users).orderBy(asc(users.last_name)); return data; }; -export const getAllUsers = async () => { +export const getAllUsersOrdrByLastname = async () => { const data = await db.select().from(users).orderBy(asc(users.last_name)); return data; }; diff --git a/src/app/(siteInfo)/Blog/page.tsx b/src/app/(siteInfo)/Blog/page.tsx index ee7c612..850144c 100644 --- a/src/app/(siteInfo)/Blog/page.tsx +++ b/src/app/(siteInfo)/Blog/page.tsx @@ -13,7 +13,6 @@ export default function Blog() { and exploring firearm parts. Designed for enthusiasts by enthusiasts, we make firearm building easy and accessible.

- ) diff --git a/src/app/(siteInfo)/Disclosure/page.tsx b/src/app/(siteInfo)/Disclosure/page.tsx index c1f1611..ed43dd3 100644 --- a/src/app/(siteInfo)/Disclosure/page.tsx +++ b/src/app/(siteInfo)/Disclosure/page.tsx @@ -13,7 +13,6 @@ export default function Disclosure() { and exploring firearm parts. Designed for enthusiasts by enthusiasts, we make firearm building easy and accessible.

- ) diff --git a/src/app/(siteInfo)/Footer/page.tsx b/src/app/(siteInfo)/Footer/page.tsx index 44ff5ea..52c64a3 100644 --- a/src/app/(siteInfo)/Footer/page.tsx +++ b/src/app/(siteInfo)/Footer/page.tsx @@ -8,7 +8,6 @@ export default function Footer() {

© {new Date().getFullYear()} {constants.APP_NAME}. All rights reserved.

Built by Forward Group ⚡

-
) diff --git a/src/app/(siteInfo)/Jobs/page.tsx b/src/app/(siteInfo)/Jobs/page.tsx index 09a4ef3..2c6a5f5 100644 --- a/src/app/(siteInfo)/Jobs/page.tsx +++ b/src/app/(siteInfo)/Jobs/page.tsx @@ -13,7 +13,6 @@ export default function Jobs() { and exploring firearm parts. Designed for enthusiasts by enthusiasts, we make firearm building easy and accessible.

- ) diff --git a/src/app/(siteInfo)/Press/page.tsx b/src/app/(siteInfo)/Press/page.tsx index 6d3dc4e..6bbd2a2 100644 --- a/src/app/(siteInfo)/Press/page.tsx +++ b/src/app/(siteInfo)/Press/page.tsx @@ -13,7 +13,6 @@ export default function About() { and exploring firearm parts. Designed for enthusiasts by enthusiasts, we make firearm building easy and accessible.

- ) diff --git a/src/app/(siteInfo)/TOS/page.tsx b/src/app/(siteInfo)/TOS/page.tsx index 7357065..fcbd80b 100644 --- a/src/app/(siteInfo)/TOS/page.tsx +++ b/src/app/(siteInfo)/TOS/page.tsx @@ -13,7 +13,6 @@ export default function TOS() { and exploring firearm parts. Designed for enthusiasts by enthusiasts, we make firearm building easy and accessible.

- ) diff --git a/src/app/Accounts/page.tsx b/src/app/Accounts/page.tsx index e4a074c..fe76d6e 100644 --- a/src/app/Accounts/page.tsx +++ b/src/app/Accounts/page.tsx @@ -1,19 +1,29 @@ import { accounts } from "@schemas/schema"; -import { getData } from "@actions/accountActions"; -import Account from "@components/Account"; // Adjust the import path as necessary -import React from 'react'; +import { getViewAccounts } from "@actions/accountActions"; +import AccountsTable from "@src/components/AccountsTable"; // Adjust the import path as necessary +import React, { Suspense } from 'react'; +import { ColumnHeadings } from "@src/lib/utils"; +import PageHero from "@src/components/PageHero"; -export interface AccountProps { - account: any; // Adjust the type according to your data structure -} export default async function AccountsPage() { - const data = await getData(); + const columnHeadings = new ColumnHeadings([ + "First Name", + "Last Name", + "Actions", + ]); + const data = await getViewAccounts(); return ( -
- +
+ + +
+ + + +
); } diff --git a/src/app/Admin/Users/page.tsx b/src/app/Admin/Users/page.tsx index 6901184..04fedfe 100644 --- a/src/app/Admin/Users/page.tsx +++ b/src/app/Admin/Users/page.tsx @@ -10,7 +10,7 @@ export default async function UsersPage() { const data = await getData(); - const columnHeadings = new ColumnHeadings(['E-mail Address', 'First Name', 'Last Name', 'Blank']); + const columnHeadings = new ColumnHeadings(['E-mail Address', 'First Name', 'Last Name', 'User Name']); return (
diff --git a/src/app/Products/optics/page.tsx b/src/app/Products/optics/page.tsx new file mode 100644 index 0000000..638036e --- /dev/null +++ b/src/app/Products/optics/page.tsx @@ -0,0 +1,18 @@ +import { getOptics } from "@queries/PSA"; +import partTypes from 'src/data/parts_cats.json'; +import styles from '../styles.module.css'; +import PageHero from "@components/PageHero"; +import SortTable from "@components/SortTable"; + +export default async function OpticsPage() { + const psa = await getOptics(); + + return ( +
+ +
+ +
+
+ ); +} \ No newline at end of file diff --git a/src/components/Account/index.tsx b/src/components/Account/index.tsx deleted file mode 100644 index 3ac09a4..0000000 --- a/src/components/Account/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { AccountProps } from "@src/app/Accounts/page"; -import React from "react"; - - -export const Account: React.FC = ({ account }) => { - return ( -
-

{account.name}

-

{account.email}

- {/* Add more fields as necessary */} -
- ); -}; -export default Account; \ No newline at end of file diff --git a/src/components/AccountsTable/index.tsx b/src/components/AccountsTable/index.tsx new file mode 100644 index 0000000..c154cda --- /dev/null +++ b/src/components/AccountsTable/index.tsx @@ -0,0 +1,106 @@ +import React from "react"; +import { ChevronDownIcon } from "@heroicons/react/20/solid"; +import { PlusCircleIcon } from "@heroicons/react/20/solid"; +import { ColumnHeadings } from "@src/lib/utils"; +import styles from '../styles.module.css'; +import PageHero from "@components/PageHero"; + +import { Suspense } from "react"; +import Loading from "@src/app/components/Loading/loading"; +import Link from "next/link"; + +export default async function AccountsTable( props: any ) { + + return ( +
+ +
+
+
+ + + + + + + + + + + {props.data.map((item: any) => ( + + + + + + + + + ))} + +
+ + {props.newColumnHeadings.getHeading()} + + + + + + {props.newColumnHeadings.getHeading()} + + + + + + {props.newColumnHeadings.getHeading()} + + + +
+ + {item.first_name} + + {item.last_name} + + + + +
+ +
+
+
+
+ + ); +}; diff --git a/src/components/HomeContent/index.tsx b/src/components/HomeContent/index.tsx index 04d708e..24cbffe 100644 --- a/src/components/HomeContent/index.tsx +++ b/src/components/HomeContent/index.tsx @@ -1,9 +1,9 @@ import Header from "../Header"; import Hero from "../Hero"; import FeaturesSection from "../FeaturesSection"; -import About from "../../app/site/About/page"; -import Contact from "../../app/site/Contact/page"; -import Footer from "../../app/site/Footer/page"; +import About from "@siteInfo/About/page"; +import Contact from "@siteInfo/Contact/page"; +import Footer from "@siteInfo/Footer/page"; export default function HomeContent() { diff --git a/src/components/admin/UsersTable/index.tsx b/src/components/admin/UsersTable/index.tsx index 8b8e96a..ee61c10 100644 --- a/src/components/admin/UsersTable/index.tsx +++ b/src/components/admin/UsersTable/index.tsx @@ -101,7 +101,7 @@ export default async function UsersTable(props: any) { {item.last_name} - ${item.username} + {item.username}