fix(misc): changes to several files for formatting

This commit is contained in:
2025-10-16 14:38:17 -05:00
parent 282eab01e1
commit b102112228
9 changed files with 243 additions and 214 deletions

View File

@@ -50,7 +50,7 @@ export const schedulerManager = async () => {
//console.log(data); //console.log(data);
if (orderData.length === 0) { if (orderData.length === 0) {
log.info({}, "There are no new orders or incoming to be updated"); log.debug({}, "There are no new orders or incoming to be updated");
return; return;
} }

View File

@@ -0,0 +1,27 @@
import {
jsonb,
pgTable,
text,
timestamp,
uniqueIndex,
uuid,
} from "drizzle-orm/pg-core";
export const prodPermissions = pgTable(
"prodPermissions",
{
prodPerm_id: uuid("prodPerm_id").defaultRandom().primaryKey(),
name: text("name").notNull(),
description: text("description").notNull(),
roles: jsonb("roles").default([]),
rolesLegacy: jsonb("rolesLegacy").default([]),
add_User: text("add_User").default("LST_System").notNull(),
add_Date: timestamp("add_Date").defaultNow(),
upd_user: text("upd_User").default("LST_System").notNull(),
upd_date: timestamp("upd_date").defaultNow(),
},
(table) => [
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
uniqueIndex("prodPermName").on(table.name),
],
);

View File

@@ -1,8 +1,8 @@
import type { Request, Response, NextFunction } from "express";
import { auth } from "../auth/auth.js";
import { userRoles, type UserRole } from "../db/schema/user_roles.js";
import { db } from "../db/db.js";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import type { NextFunction, Request, Response } from "express";
import { auth } from "../auth/auth.js";
import { db } from "../db/db.js";
import { type UserRole, userRoles } from "../db/schema/user_roles.js";
declare global { declare global {
namespace Express { namespace Express {
@@ -11,6 +11,7 @@ declare global {
id: string; id: string;
email?: string; email?: string;
roles: Record<string, string[]>; roles: Record<string, string[]>;
username?: string | null;
}; };
} }
} }
@@ -61,6 +62,7 @@ export const requireAuth = (moduleName?: string, requiredRoles?: string[]) => {
id: userId, id: userId,
email: session.user.email, email: session.user.email,
roles: rolesByModule, roles: rolesByModule,
username: session.user.username,
}; };
// SystemAdmin override // SystemAdmin override
@@ -71,10 +73,10 @@ export const requireAuth = (moduleName?: string, requiredRoles?: string[]) => {
// Role check (skip if systemAdmin) // Role check (skip if systemAdmin)
if (requiredRoles?.length && !hasSystemAdmin) { if (requiredRoles?.length && !hasSystemAdmin) {
const moduleRoles = moduleName const moduleRoles = moduleName
? rolesByModule[moduleName] ?? [] ? (rolesByModule[moduleName] ?? [])
: Object.values(rolesByModule).flat(); : Object.values(rolesByModule).flat();
const hasAccess = moduleRoles.some((role) => const hasAccess = moduleRoles.some((role) =>
requiredRoles.includes(role) requiredRoles.includes(role),
); );
if (!hasAccess) { if (!hasAccess) {
return res.status(403).json({ error: "Forbidden" }); return res.status(403).json({ error: "Forbidden" });

View File

@@ -1,7 +1,6 @@
import * as React from "react" import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area" import * as React from "react";
import { cn } from "../../lib/utils";
import { cn } from "@/lib/utils"
function ScrollArea({ function ScrollArea({
className, className,
@@ -23,7 +22,7 @@ function ScrollArea({
<ScrollBar /> <ScrollBar />
<ScrollAreaPrimitive.Corner /> <ScrollAreaPrimitive.Corner />
</ScrollAreaPrimitive.Root> </ScrollAreaPrimitive.Root>
) );
} }
function ScrollBar({ function ScrollBar({
@@ -41,7 +40,7 @@ function ScrollBar({
"h-full w-2.5 border-l border-l-transparent", "h-full w-2.5 border-l border-l-transparent",
orientation === "horizontal" && orientation === "horizontal" &&
"h-2.5 flex-col border-t border-t-transparent", "h-2.5 flex-col border-t border-t-transparent",
className className,
)} )}
{...props} {...props}
> >
@@ -50,7 +49,7 @@ function ScrollBar({
className="bg-border relative flex-1 rounded-full" className="bg-border relative flex-1 rounded-full"
/> />
</ScrollAreaPrimitive.ScrollAreaScrollbar> </ScrollAreaPrimitive.ScrollAreaScrollbar>
) );
} }
export { ScrollArea, ScrollBar } export { ScrollArea, ScrollBar };

View File

@@ -1,6 +1,5 @@
import * as React from "react" import * as React from "react";
import { cn } from "../../lib/utils";
import { cn } from "@/lib/utils"
function Table({ className, ...props }: React.ComponentProps<"table">) { function Table({ className, ...props }: React.ComponentProps<"table">) {
return ( return (
@@ -14,7 +13,7 @@ function Table({ className, ...props }: React.ComponentProps<"table">) {
{...props} {...props}
/> />
</div> </div>
) );
} }
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) { function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
@@ -24,7 +23,7 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
className={cn("[&_tr]:border-b", className)} className={cn("[&_tr]:border-b", className)}
{...props} {...props}
/> />
) );
} }
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) { function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
@@ -34,7 +33,7 @@ function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
className={cn("[&_tr:last-child]:border-0", className)} className={cn("[&_tr:last-child]:border-0", className)}
{...props} {...props}
/> />
) );
} }
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) { function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
@@ -43,11 +42,11 @@ function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
data-slot="table-footer" data-slot="table-footer"
className={cn( className={cn(
"bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", "bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
className className,
)} )}
{...props} {...props}
/> />
) );
} }
function TableRow({ className, ...props }: React.ComponentProps<"tr">) { function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
@@ -56,11 +55,11 @@ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
data-slot="table-row" data-slot="table-row"
className={cn( className={cn(
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
className className,
)} )}
{...props} {...props}
/> />
) );
} }
function TableHead({ className, ...props }: React.ComponentProps<"th">) { function TableHead({ className, ...props }: React.ComponentProps<"th">) {
@@ -69,11 +68,11 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
data-slot="table-head" data-slot="table-head"
className={cn( className={cn(
"text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", "text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
className className,
)} )}
{...props} {...props}
/> />
) );
} }
function TableCell({ className, ...props }: React.ComponentProps<"td">) { function TableCell({ className, ...props }: React.ComponentProps<"td">) {
@@ -82,11 +81,11 @@ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
data-slot="table-cell" data-slot="table-cell"
className={cn( className={cn(
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
className className,
)} )}
{...props} {...props}
/> />
) );
} }
function TableCaption({ function TableCaption({
@@ -99,7 +98,7 @@ function TableCaption({
className={cn("text-muted-foreground mt-4 text-sm", className)} className={cn("text-muted-foreground mt-4 text-sm", className)}
{...props} {...props}
/> />
) );
} }
export { export {
@@ -111,4 +110,4 @@ export {
TableRow, TableRow,
TableCell, TableCell,
TableCaption, TableCaption,
} };

View File

@@ -10,7 +10,7 @@ interface ShipmentItemProps {
export function ShipmentItem({ export function ShipmentItem({
shipment, shipment,
index = 0, index = 0,
perm = true, //perm = true,
}: ShipmentItemProps) { }: ShipmentItemProps) {
const { setNodeRef, listeners, attributes, transform } = useDraggable({ const { setNodeRef, listeners, attributes, transform } = useDraggable({
id: shipment.orderNumber, id: shipment.orderNumber,

View File

@@ -1,9 +1,7 @@
import { createFileRoute } from "@tanstack/react-router"; import { createFileRoute } from "@tanstack/react-router";
import { useEffect, useState } from "react";
import { coreSocket } from "../../../lib/socket.io/socket"; import { coreSocket } from "../../../lib/socket.io/socket";
import "../-components/style.css"; import "../-components/style.css";
import moment from "moment";
import Timeline from "react-calendar-timeline";
export const Route = createFileRoute("/(logistics)/logistics/deliverySchedule")( export const Route = createFileRoute("/(logistics)/logistics/deliverySchedule")(
{ {
@@ -19,9 +17,9 @@ export const Route = createFileRoute("/(logistics)/logistics/deliverySchedule")(
function RouteComponent() { function RouteComponent() {
// connect to the channel // connect to the channel
const [shipments, setShipments] = useState([]) as any; //const [shipments, setShipments] = useState([]) as any;
//const [perm] = useState(true); // will check this for sure with a user permissions //const [perm] = useState(true); // will check this for sure with a user permissions
const [loaded, setLoaded] = useState(false); //const [loaded, setLoaded] = useState(false);
// useEffect(() => { // useEffect(() => {
// const handleConnect = () => { // const handleConnect = () => {

View File

@@ -11,7 +11,7 @@ import { useEffect } from "react";
import { Toaster } from "sonner"; import { Toaster } from "sonner";
import Nav from "../components/navBar/Nav"; import Nav from "../components/navBar/Nav";
import SideBarNav from "../components/navBar/SideBarNav"; import SideBarNav from "../components/navBar/SideBarNav";
import { SidebarProvider, SidebarTrigger } from "../components/ui/sidebar"; import { SidebarProvider } from "../components/ui/sidebar";
import { userAccess } from "../lib/authClient"; import { userAccess } from "../lib/authClient";
import { SessionGuard } from "../lib/providers/SessionProvider"; import { SessionGuard } from "../lib/providers/SessionProvider";
import { ThemeProvider } from "../lib/providers/theme-provider"; import { ThemeProvider } from "../lib/providers/theme-provider";

View File

@@ -91,6 +91,10 @@ function RouteComponent() {
); );
}, },
}), }),
// password reset will do the email flow
// change password an input for this one so well need inline editing for this dope one
// trash can to delete user
// last login -- need to get working on the server side as well.
columnHelper.accessor("roles", { columnHelper.accessor("roles", {
header: () => <span>Roles</span>, header: () => <span>Roles</span>,
cell: ({ row }) => { cell: ({ row }) => {