mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-05 18:26:45 -05:00
fixes
This commit is contained in:
22
src/app/Products/sights/page.tsx
Normal file
22
src/app/Products/sights/page.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { getSights } from "@queries/PSA";
|
||||||
|
import styles from '../styles.module.css';
|
||||||
|
import PageHero from "@components/PageHero";
|
||||||
|
import SortTable from "@components/SortTable";
|
||||||
|
import {Suspense} from "react";
|
||||||
|
import Loading from "@/components/Loading-Green";
|
||||||
|
|
||||||
|
export default async function SightsPage() {
|
||||||
|
const data = await getSights();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<PageHero title="Sights" />
|
||||||
|
|
||||||
|
<div className="container mx-auto">
|
||||||
|
<Suspense fallback={<Loading/>}>
|
||||||
|
<SortTable data={data}></SortTable>
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
Bars3Icon,
|
Bars3Icon,
|
||||||
MagnifyingGlassIcon,
|
MagnifyingGlassIcon,
|
||||||
ShoppingBagIcon,
|
|
||||||
XMarkIcon,
|
XMarkIcon,
|
||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
import { validateRequest } from "@/lib/auth/validate-request";
|
import { validateRequest } from "@/lib/auth/validate-request";
|
||||||
@@ -25,7 +24,8 @@ import { User } from "lucia";
|
|||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
import { logoutSession } from "@/actions/userActions";
|
import { logoutSession } from "@/actions/userActions";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { lucia } from "@/lib/auth";
|
import Image from "next/image";
|
||||||
|
|
||||||
import { logout } from "@/lib/auth/actions";
|
import { logout } from "@/lib/auth/actions";
|
||||||
|
|
||||||
const navigation = {
|
const navigation = {
|
||||||
@@ -91,7 +91,13 @@ const navigation = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function PopNavDialog(props:any) {
|
interface PopNavDialogProps {
|
||||||
|
sessionCookie: {
|
||||||
|
user: User;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PopNavDialog(props: PopNavDialogProps) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [user, setUser] = useState<User | null>(null);
|
const [user, setUser] = useState<User | null>(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -153,22 +159,24 @@ export default function PopNavDialog(props:any) {
|
|||||||
>
|
>
|
||||||
<div className="grid grid-cols-2 gap-x-4">
|
<div className="grid grid-cols-2 gap-x-4">
|
||||||
{category.featured.map((item) => (
|
{category.featured.map((item) => (
|
||||||
<div key={item.name} className="group relative text-sm">
|
<Fragment key={item.name}>
|
||||||
<img alt={item.imageAlt} src={item.imageSrc} className="aspect-square w-full rounded-lg bg-gray-100 object-cover group-hover:opacity-75"/>
|
<Image alt={item.imageAlt} src={item.imageSrc} className="aspect-square w-full rounded-lg bg-gray-100 object-cover group-hover:opacity-75" width={500} height={500} />
|
||||||
<a
|
|
||||||
|
<a
|
||||||
href={item.href}
|
href={item.href}
|
||||||
className="mt-6 block font-medium text-gray-900"
|
className="mt-6 block font-medium text-gray-900"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className="absolute inset-0 z-10"
|
className="absolute inset-0 z-10"
|
||||||
/>
|
>
|
||||||
{item.name}
|
{item.name}
|
||||||
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<p aria-hidden="true" className="mt-1">
|
<p aria-hidden="true" className="mt-1">
|
||||||
See Build
|
See Build
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</Fragment>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{category.sections.map((section) => (
|
{category.sections.map((section) => (
|
||||||
@@ -236,10 +244,12 @@ export default function PopNavDialog(props:any) {
|
|||||||
|
|
||||||
<div className="border-t border-gray-200 px-4 py-6">
|
<div className="border-t border-gray-200 px-4 py-6">
|
||||||
<a href="#" className="-m-2 flex items-center p-2">
|
<a href="#" className="-m-2 flex items-center p-2">
|
||||||
<img
|
<Image
|
||||||
alt=""
|
alt=""
|
||||||
src="https://tailwindui.com/plus/img/flags/flag-canada.svg"
|
src="https://tailwindui.com/plus/img/flags/flag-canada.svg"
|
||||||
className="block h-auto w-5 shrink-0"
|
className="block h-auto w-5 shrink-0"
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
/>
|
/>
|
||||||
<span className="ml-3 block text-base font-medium text-gray-900">
|
<span className="ml-3 block text-base font-medium text-gray-900">
|
||||||
CAD
|
CAD
|
||||||
@@ -302,10 +312,12 @@ export default function PopNavDialog(props:any) {
|
|||||||
key={item.name}
|
key={item.name}
|
||||||
className="group relative text-base sm:text-sm"
|
className="group relative text-base sm:text-sm"
|
||||||
>
|
>
|
||||||
<img
|
<Image
|
||||||
alt={item.imageAlt}
|
alt={item.imageAlt}
|
||||||
src={item.imageSrc}
|
src={item.imageSrc}
|
||||||
className="aspect-square w-full rounded-lg bg-gray-100 object-cover group-hover:opacity-75"
|
className="aspect-square w-full rounded-lg bg-gray-100 object-cover group-hover:opacity-75"
|
||||||
|
width={500}
|
||||||
|
height={500}
|
||||||
/>
|
/>
|
||||||
<a
|
<a
|
||||||
href={item.href}
|
href={item.href}
|
||||||
@@ -373,7 +385,7 @@ export default function PopNavDialog(props:any) {
|
|||||||
<div className="ml-auto flex items-center">
|
<div className="ml-auto flex items-center">
|
||||||
<div className="hidden lg:flex lg:flex-1 lg:items-center lg:justify-end lg:space-x-6">
|
<div className="hidden lg:flex lg:flex-1 lg:items-center lg:justify-end lg:space-x-6">
|
||||||
<a
|
<a
|
||||||
href={linkPath} onClick={async (e) => {e.preventDefault(); console.log("in the onclick"); await logout()} } className="text-sm font-medium text-gray-700 hover:text-gray-800">
|
href={linkPath} onClick={async () => { console.log("in the onclick"); await logout()} } className="text-sm font-medium text-gray-700 hover:text-gray-800">
|
||||||
{user == null?"Sign In": "Log Out"}
|
{user == null?"Sign In": "Log Out"}
|
||||||
</a>
|
</a>
|
||||||
<span aria-hidden="true" className="h-6 w-px bg-gray-200" />
|
<span aria-hidden="true" className="h-6 w-px bg-gray-200" />
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const navigation = {
|
|||||||
{ name: 'Lowers', href: '/Products/lowers', role: "All" },
|
{ name: 'Lowers', href: '/Products/lowers', role: "All" },
|
||||||
{ name: 'Uppers', href: '/Products/uppers', role: "All" },
|
{ name: 'Uppers', href: '/Products/uppers', role: "All" },
|
||||||
{ name: 'Optics', href: '/Products/optics', role: "All" },
|
{ name: 'Optics', href: '/Products/optics', role: "All" },
|
||||||
|
{ name: 'Sights', href: '/Products/sights', role: "All" },
|
||||||
{ name: 'Accessories', href: '/Products/accessories', role: "All" },
|
{ name: 'Accessories', href: '/Products/accessories', role: "All" },
|
||||||
{ name: 'Suppressors', href: '/Products/suppressors', role: "All" },
|
{ name: 'Suppressors', href: '/Products/suppressors', role: "All" },
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { db } from '@db/index';
|
import { db } from '@db/index';
|
||||||
import { bb_products, psa } from '@schemas/schema';
|
import { bb_products, psa } from '@schemas/schema';
|
||||||
import { eq, lt, gte, ne, and, like } from 'drizzle-orm';
|
import { eq, and, like } from 'drizzle-orm';
|
||||||
import CATEGORY from '@src/data/parts_cats.json';
|
|
||||||
|
|
||||||
export async function getPSA(page = 1) {
|
export async function getPSA(page = 1) {
|
||||||
const limit = 20;
|
const limit = 20;
|
||||||
@@ -36,7 +35,11 @@ export async function getARCompleteLowers(page = 1) {
|
|||||||
.offset(offset);
|
.offset(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProductType(productType : any, page = 1) {
|
interface ProductType {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getProductType(productType: ProductType | string, page = 1) {
|
||||||
const limit = 40;
|
const limit = 40;
|
||||||
const offset = (page - 1) * limit;
|
const offset = (page - 1) * limit;
|
||||||
await new Promise((resolve) => setTimeout(resolve,1000));
|
await new Promise((resolve) => setTimeout(resolve,1000));
|
||||||
@@ -123,6 +126,16 @@ export async function getOptics(page = 1) {
|
|||||||
.where(and(like(psa.fineline, "%Optics%")))
|
.where(and(like(psa.fineline, "%Optics%")))
|
||||||
.offset(offset);
|
.offset(offset);
|
||||||
}
|
}
|
||||||
|
export async function getSights(page = 1) {
|
||||||
|
const limit = 40;
|
||||||
|
const offset = (page - 1) * limit;
|
||||||
|
|
||||||
|
return await db.select()
|
||||||
|
.from(bb_products)
|
||||||
|
.limit(limit)
|
||||||
|
.where(and(like(bb_products.subcategory, "%Sights")))
|
||||||
|
.offset(offset);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getStocksParts(page = 1) {
|
export async function getStocksParts(page = 1) {
|
||||||
const limit = 40;
|
const limit = 40;
|
||||||
|
|||||||
Reference in New Issue
Block a user