Initial commit: Hoomat storefront with Meshkee API and static-image slots.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import {
|
||||
BUSINESS_APP_URL,
|
||||
CUSTOMER_APP_URL,
|
||||
} from "@/lib/meshkee/config";
|
||||
import {
|
||||
encodeGuestCartForUrl,
|
||||
GUEST_CART_URL_PARAM,
|
||||
} from "@/lib/meshkee/guest-cart";
|
||||
import { slugifyFa } from "@/lib/meshkee/format";
|
||||
import type { GuestCartLine } from "@/lib/meshkee/types";
|
||||
|
||||
export function customerLoginUrl(redirectPath = "/"): string {
|
||||
const url = new URL("/login", CUSTOMER_APP_URL);
|
||||
url.searchParams.set("redirect", redirectPath.startsWith("/") ? redirectPath : `/${redirectPath}`);
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
export function customerProfileUrl(): string {
|
||||
return `${CUSTOMER_APP_URL}/`;
|
||||
}
|
||||
|
||||
export function businessDashboardUrl(): string {
|
||||
return `${BUSINESS_APP_URL}/`;
|
||||
}
|
||||
|
||||
export function customerContinueCheckoutUrl(
|
||||
isAuthenticated: boolean,
|
||||
guestItems: GuestCartLine[] = [],
|
||||
): string {
|
||||
if (isAuthenticated) {
|
||||
const url = new URL("/checkout/cart", CUSTOMER_APP_URL);
|
||||
if (guestItems.length > 0) {
|
||||
url.hash = `${GUEST_CART_URL_PARAM}=${encodeGuestCartForUrl(guestItems)}`;
|
||||
}
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
let redirect = "/checkout/cart";
|
||||
if (guestItems.length > 0) {
|
||||
redirect = `${redirect}#${GUEST_CART_URL_PARAM}=${encodeGuestCartForUrl(guestItems)}`;
|
||||
}
|
||||
return customerLoginUrl(redirect);
|
||||
}
|
||||
|
||||
export function storeItemHref(variantId: string, name?: string | null): string {
|
||||
return `/store/${encodeURIComponent(variantId)}/${slugifyFa(name)}`;
|
||||
}
|
||||
|
||||
export function storeCategoryHref(categoryId: string, name?: string | null): string {
|
||||
return `/store?categoryId=${encodeURIComponent(categoryId)}&name=${encodeURIComponent(slugifyFa(name))}`;
|
||||
}
|
||||
|
||||
export function blogHref(id: string, title?: string | null): string {
|
||||
return `/blog/${encodeURIComponent(id)}/${slugifyFa(title)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user