Admin AI Tools page: unified design system styling, provider selector with OpenAI turd emoji, free-text model input with exact ID warning
This commit is contained in:
@@ -27,13 +27,10 @@ export async function getAdminUser(): Promise<AdminUser | null> {
|
||||
return buildDevAdmin("platform_admin");
|
||||
}
|
||||
|
||||
// ── Dev session bypass (enabled in all envs for demo) ──────────────
|
||||
// Allow dev cookies via: document.cookie = "dev_session=platform_admin; path=/"
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
const dev = cookieStore.get("dev_session")?.value;
|
||||
if (dev === "platform_admin" || dev === "brand_admin" || dev === "store_employee") {
|
||||
return buildDevAdmin(dev);
|
||||
}
|
||||
// ── Dev session bypass (enabled for testing on all envs) ──────────────
|
||||
const dev = cookieStore.get("dev_session")?.value;
|
||||
if (dev === "platform_admin" || dev === "brand_admin" || dev === "store_employee") {
|
||||
return buildDevAdmin(dev);
|
||||
}
|
||||
|
||||
// ── Main auth: rc_auth_uid (new) or rc_uid (legacy) cookie set by /api/login ─
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Route Trace data fetching utilities
|
||||
* Shared data fetching for all route-trace pages
|
||||
*/
|
||||
|
||||
import {
|
||||
getRouteTraceStats,
|
||||
getRouteTraceLots,
|
||||
getHarvestLotsReadyToHaul,
|
||||
getFieldYieldSummary,
|
||||
getInventoryByCrop,
|
||||
getRecentLotEvents,
|
||||
type RouteTraceStats,
|
||||
type HaulingLot,
|
||||
type FieldYieldSummary,
|
||||
type InventoryByCrop,
|
||||
type RecentLotEvent,
|
||||
} from "@/actions/route-trace/lots";
|
||||
|
||||
export type RouteTraceData = {
|
||||
stats: RouteTraceStats;
|
||||
lots: HaulingLot[];
|
||||
haulingLots: HaulingLot[];
|
||||
fieldYield: FieldYieldSummary[];
|
||||
inventoryByCrop: InventoryByCrop[];
|
||||
recentActivity: RecentLotEvent[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch all route-trace data for a brand
|
||||
*/
|
||||
export async function fetchRouteTraceData(
|
||||
brandId: string
|
||||
): Promise<RouteTraceData> {
|
||||
const [statsResult, lotsResult, haulingResult, yieldResult, invResult, eventsResult] = await Promise.all([
|
||||
getRouteTraceStats(brandId),
|
||||
getRouteTraceLots(brandId),
|
||||
getHarvestLotsReadyToHaul(brandId),
|
||||
getFieldYieldSummary(brandId),
|
||||
getInventoryByCrop(brandId),
|
||||
getRecentLotEvents(brandId, 10),
|
||||
]);
|
||||
|
||||
return {
|
||||
stats: statsResult.success ? statsResult.stats : {
|
||||
active_count: 0,
|
||||
in_transit_count: 0,
|
||||
at_shed_count: 0,
|
||||
total_lots_today: 0,
|
||||
total_harvested_today: 0,
|
||||
total_lots: 0,
|
||||
},
|
||||
lots: lotsResult.success ? lotsResult.lots : [],
|
||||
haulingLots: haulingResult.success ? haulingResult.lots : [],
|
||||
fieldYield: yieldResult.success ? yieldResult.summary : [],
|
||||
inventoryByCrop: invResult.success ? invResult.inventory : [],
|
||||
recentActivity: eventsResult.success ? eventsResult.events : [],
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user