feat(storage): MinIO object storage, Neon Auth, Supabase removal
Deploy to route.crispygoat.com / deploy (push) Failing after 3m1s
Deploy to route.crispygoat.com / deploy (push) Failing after 3m1s
- Add MinIO/S3-compatible storage client (src/lib/storage.ts) with uploadObject, deleteObject, presigned URL helpers, and BUCKETS constant - Wire product images, brand logos, and water log photos to MinIO via the new storage client - Migrate forgot-password to Neon Auth (remove Supabase /auth/v1/recover call) - Migrate send-scheduled cron to direct Postgres + Resend (remove Supabase Edge Function proxy) - Add logoUrl to email types (OrderReceipt, Welcome, PasswordReset) and pass brand_settings.logo_url from all call sites - Update email templates to use dynamic logoUrl instead of hardcoded Supabase bucket URLs - Remove hardcoded Supabase URLs from TuxedoVideoHero, TuxedoAboutPage, TimeTrackingFieldClient; use brand_settings props + local public/ fallback - Download brand logos (3) and tuxedo-hero.mp4 (36MB) from Supabase bucket to public/ for local development - Add MinIO env vars to .env.example (endpoint, access key, secret, buckets) - Fix TimeTrackingFieldClient to destructure logoUrl and brandAccent props - Fix admin/users.ts logoUrl type (null → undefined for optional string) - Remove stale sb- cookie from wholesale-auth - Migrate tuxedo/about page to remove supabase import and use pool query for wholesale_settings lookup
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { desc, eq } from "drizzle-orm";
|
||||
import { getAdminUser } from "@/lib/admin-permissions";
|
||||
import { withTenant, withPlatformAdmin } from "@/db/client";
|
||||
import { withBrand, withPlatformAdmin } from "@/db/client";
|
||||
import { campaigns } from "@/db/schema";
|
||||
import type { AudienceRules } from "@/actions/communications/campaigns";
|
||||
|
||||
@@ -57,7 +57,7 @@ export type CampaignAnalytics = {
|
||||
function rowToCampaign(row: typeof campaigns.$inferSelect): Campaign {
|
||||
return {
|
||||
id: row.id,
|
||||
brand_id: row.tenantId,
|
||||
brand_id: row.brandId,
|
||||
name: row.name,
|
||||
subject: null,
|
||||
body_text: null,
|
||||
@@ -84,7 +84,7 @@ export async function getHarvestReachCampaigns(
|
||||
}
|
||||
|
||||
try {
|
||||
const rows = await withTenant(brandId, (db) =>
|
||||
const rows = await withBrand(brandId, (db) =>
|
||||
db
|
||||
.select()
|
||||
.from(campaigns)
|
||||
@@ -118,13 +118,13 @@ export async function getCampaignAnalytics(
|
||||
|
||||
try {
|
||||
const rows = campaignId
|
||||
? await withTenant(brandId, (db) =>
|
||||
? await withBrand(brandId, (db) =>
|
||||
db
|
||||
.select()
|
||||
.from(campaigns)
|
||||
.where(eq(campaigns.id, campaignId)),
|
||||
)
|
||||
: await withTenant(brandId, (db) =>
|
||||
: await withBrand(brandId, (db) =>
|
||||
db
|
||||
.select()
|
||||
.from(campaigns)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { getAdminUser } from "@/lib/admin-permissions";
|
||||
import { withTenant } from "@/db/client";
|
||||
import { withBrand } from "@/db/client";
|
||||
import { products } from "@/db/schema";
|
||||
|
||||
export type ProductOption = {
|
||||
@@ -27,7 +27,7 @@ export async function getProductsForSegmentPicker(
|
||||
if (adminUser.role === "brand_admin" && adminUser.brand_id !== brandId) return [];
|
||||
|
||||
try {
|
||||
const rows = await withTenant(brandId, (db) =>
|
||||
const rows = await withBrand(brandId, (db) =>
|
||||
db
|
||||
.select({
|
||||
id: products.id,
|
||||
@@ -36,7 +36,7 @@ export async function getProductsForSegmentPicker(
|
||||
active: products.active,
|
||||
})
|
||||
.from(products)
|
||||
.where(and(eq(products.tenantId, brandId), eq(products.active, true))),
|
||||
.where(and(eq(products.brandId, brandId), eq(products.active, true))),
|
||||
);
|
||||
return rows.map((r) => ({
|
||||
id: r.id,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { and, eq, ilike, or, SQL, sql } from "drizzle-orm";
|
||||
import { getAdminUser } from "@/lib/admin-permissions";
|
||||
import { withTenant } from "@/db/client";
|
||||
import { withBrand } from "@/db/client";
|
||||
import { customers, brandSettings } from "@/db/schema";
|
||||
import type { AudienceRules } from "@/actions/communications/campaigns";
|
||||
|
||||
@@ -55,7 +55,7 @@ export type Segment = {
|
||||
export type CustomerSample = {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string;
|
||||
fullName: string | null;
|
||||
tags: string[];
|
||||
phone: string | null;
|
||||
};
|
||||
@@ -70,11 +70,11 @@ function isSegmentList(v: unknown): v is Segment[] {
|
||||
}
|
||||
|
||||
async function loadSegments(brandId: string): Promise<Segment[]> {
|
||||
const rows = await withTenant(brandId, (db) =>
|
||||
const rows = await withBrand(brandId, (db) =>
|
||||
db
|
||||
.select({ flags: brandSettings.featureFlags })
|
||||
.from(brandSettings)
|
||||
.where(eq(brandSettings.tenantId, brandId))
|
||||
.where(eq(brandSettings.brandId, brandId))
|
||||
.limit(1),
|
||||
);
|
||||
const raw = (rows[0]?.flags ?? {}) as Record<string, unknown>;
|
||||
@@ -83,11 +83,11 @@ async function loadSegments(brandId: string): Promise<Segment[]> {
|
||||
}
|
||||
|
||||
async function saveSegments(brandId: string, segments: Segment[]): Promise<void> {
|
||||
await withTenant(brandId, async (db) => {
|
||||
await withBrand(brandId, async (db) => {
|
||||
const existing = await db
|
||||
.select({ flags: brandSettings.featureFlags })
|
||||
.from(brandSettings)
|
||||
.where(eq(brandSettings.tenantId, brandId))
|
||||
.where(eq(brandSettings.brandId, brandId))
|
||||
.limit(1);
|
||||
const baseFlags = (existing[0]?.flags ?? {}) as Record<string, unknown>;
|
||||
const nextFlags: Record<string, unknown> = {
|
||||
@@ -97,7 +97,7 @@ async function saveSegments(brandId: string, segments: Segment[]): Promise<void>
|
||||
await db
|
||||
.update(brandSettings)
|
||||
.set({ featureFlags: nextFlags, updatedAt: new Date() })
|
||||
.where(eq(brandSettings.tenantId, brandId));
|
||||
.where(eq(brandSettings.brandId, brandId));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -221,15 +221,15 @@ export async function previewSegmentWithCustomers(
|
||||
}
|
||||
void rules;
|
||||
|
||||
const conds: SQL[] = [eq(customers.tenantId, brandId), eq(customers.emailOptIn, true)];
|
||||
const conds: SQL[] = [eq(customers.brandId, brandId), eq(customers.emailOptIn, true)];
|
||||
|
||||
try {
|
||||
const [samples, counts] = await withTenant(brandId, async (db) => {
|
||||
const [samples, counts] = await withBrand(brandId, async (db) => {
|
||||
const sample = await db
|
||||
.select({
|
||||
id: customers.id,
|
||||
email: customers.email,
|
||||
name: customers.name,
|
||||
fullName: customers.fullName,
|
||||
phone: customers.phone,
|
||||
})
|
||||
.from(customers)
|
||||
@@ -247,7 +247,7 @@ export async function previewSegmentWithCustomers(
|
||||
sample_customers: samples.map((s) => ({
|
||||
id: s.id,
|
||||
email: s.email ?? "",
|
||||
name: s.name,
|
||||
fullName: s.fullName,
|
||||
tags: [],
|
||||
phone: s.phone,
|
||||
})),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { getAdminUser } from "@/lib/admin-permissions";
|
||||
import { withTenant } from "@/db/client";
|
||||
import { withBrand } from "@/db/client";
|
||||
import { stops } from "@/db/schema";
|
||||
|
||||
export type StopOption = {
|
||||
@@ -51,29 +51,28 @@ export async function getStopsForSegmentPicker(
|
||||
if (adminUser.role === "brand_admin" && adminUser.brand_id !== brandId) return [];
|
||||
|
||||
try {
|
||||
const rows = await withTenant(brandId, (db) =>
|
||||
const rows = await withBrand(brandId, (db) =>
|
||||
db
|
||||
.select({
|
||||
id: stops.id,
|
||||
name: stops.name,
|
||||
address: stops.address,
|
||||
schedule: stops.schedule,
|
||||
date: stops.date,
|
||||
time: stops.time,
|
||||
})
|
||||
.from(stops)
|
||||
.where(
|
||||
stopId
|
||||
? and(eq(stops.tenantId, brandId), eq(stops.id, stopId))
|
||||
: eq(stops.tenantId, brandId),
|
||||
? and(eq(stops.brandId, brandId), eq(stops.id, stopId))
|
||||
: eq(stops.brandId, brandId),
|
||||
),
|
||||
);
|
||||
|
||||
const now = Date.now();
|
||||
return rows.map((r) => {
|
||||
const { city, state, zip } = parseAddress(r.address);
|
||||
const sched = Array.isArray(r.schedule) ? r.schedule : [];
|
||||
const first = sched[0] as { date?: string; time?: string } | undefined;
|
||||
const dateStr = first?.date ?? "";
|
||||
const timeStr = first?.time ?? "";
|
||||
const { city, state, zip } = parseAddress(r.address ?? "");
|
||||
const dateStr = r.date ?? "";
|
||||
const timeStr = r.time ?? "";
|
||||
const ts = dateStr ? new Date(dateStr).getTime() : NaN;
|
||||
const isUpcoming = Number.isFinite(ts) ? ts >= now : false;
|
||||
const isPast = Number.isFinite(ts) ? ts < now : false;
|
||||
|
||||
Reference in New Issue
Block a user