Add generateInviteLink util function
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { clsx, type ClassValue } from "clsx";
|
import { clsx, type ClassValue } from "clsx";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
import { BACKEND_API_URL } from "@/lib/constants";
|
import { APP_URL, BACKEND_API_URL } from "@/lib/constants";
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs));
|
||||||
@@ -70,3 +70,18 @@ export function formatTime(
|
|||||||
export const getServerFileUrl = (url?: string | null) => {
|
export const getServerFileUrl = (url?: string | null) => {
|
||||||
return url ? `${BACKEND_API_URL}/files/${url}` : undefined;
|
return url ? `${BACKEND_API_URL}/files/${url}` : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const generateInviteLink = (
|
||||||
|
eventSlug: string,
|
||||||
|
invitationCode: string,
|
||||||
|
): string => {
|
||||||
|
const baseUrl = APP_URL;
|
||||||
|
|
||||||
|
if (!baseUrl) {
|
||||||
|
console.warn("NEXT_PUBLIC_APP_URL is not defined in environment variables");
|
||||||
|
// Fallback for development
|
||||||
|
return `/invite/${eventSlug}?code=${invitationCode}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${baseUrl}/invite/${eventSlug}?code=${invitationCode}`;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user