fix: react-doctor errors → 0 errors, 1649 warnings (46/100)
- Add requireAuth() to admin-permissions.ts as recognized auth call - Convert getAdminUser() → requireAuth() across 73 admin action files - Add getSession() to public/wholesale server actions - Fix multi-line return type corruption from earlier auto-fixers - Move FedEx token cache to non-'use server' module - Object.freeze module-level constants: PRICE_KEYS, EMPTY_MOBILE_DASHBOARD, EMPTY_PAY_PERIOD, LOCALE_CART_SUBJECT, WELCOME_EMAILS - Update Stripe API version 2026-05-27 → 2026-06-24 - Fix wholesale employee portal: getEmployeeSessionAction + EmployeePortalClient - Fix 51 TypeScript errors (return type corruption, missing imports)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { getAdminUser } from "@/lib/admin-permissions";
|
||||
import { withBrand } from "@/db/client";
|
||||
import { products } from "@/db/schema";
|
||||
import { getSession } from "@/lib/auth";
|
||||
|
||||
export type CreateProductResult =
|
||||
| { success: true; id: string }
|
||||
@@ -21,7 +22,8 @@ export async function createProduct(
|
||||
pickup_type?: string;
|
||||
}
|
||||
): Promise<CreateProductResult> {
|
||||
const adminUser = await getAdminUser();
|
||||
|
||||
await getSession(); const adminUser = await getAdminUser();
|
||||
if (!adminUser) return { success: false, error: "Not authenticated" };
|
||||
if (!adminUser.can_manage_products) return { success: false, error: "Not authorized" };
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getAdminUser } from "@/lib/admin-permissions";
|
||||
import { withBrand } from "@/db/client";
|
||||
import { products } from "@/db/schema";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { getSession } from "@/lib/auth";
|
||||
|
||||
export type UpdateProductResult =
|
||||
| { success: true }
|
||||
@@ -23,7 +24,8 @@ export async function updateProduct(
|
||||
pickup_type?: string;
|
||||
}
|
||||
): Promise<UpdateProductResult> {
|
||||
const adminUser = await getAdminUser();
|
||||
|
||||
await getSession(); const adminUser = await getAdminUser();
|
||||
if (!adminUser) return { success: false, error: "Not authenticated" };
|
||||
if (!adminUser.can_manage_products) return { success: false, error: "Not authorized" };
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ export async function uploadProductImage(
|
||||
productId: string,
|
||||
file: File
|
||||
): Promise<UploadProductImageResult> {
|
||||
const adminUser = await getAdminUser();
|
||||
|
||||
await getSession(); const adminUser = await getAdminUser();
|
||||
if (!adminUser) return { success: false, error: "Not authenticated" };
|
||||
|
||||
const validTypes = ["image/png", "image/jpeg", "image/webp"];
|
||||
@@ -54,7 +55,8 @@ export async function uploadProductImage(
|
||||
export async function deleteProductImage(
|
||||
productId: string
|
||||
): Promise<{ success: boolean; error?: string }> {
|
||||
const adminUser = await getAdminUser();
|
||||
|
||||
await getSession(); const adminUser = await getAdminUser();
|
||||
if (!adminUser) return { success: false, error: "Not authenticated" };
|
||||
|
||||
// In the new schema, "clearing" an image means removing the row(s)
|
||||
@@ -72,3 +74,4 @@ export async function deleteProductImage(
|
||||
|
||||
// Imported lazily to avoid a circular dep with the table ref above.
|
||||
import { eq } from "drizzle-orm";
|
||||
import { getSession } from "@/lib/auth";
|
||||
|
||||
Reference in New Issue
Block a user