// * Packages import { usePage } from "@inertiajs/react"; import { ExternalLinkIcon } from "lucide-react"; // * Components shadcn import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; // * Other import { AppEnv } from "@/types/global"; import useTrans from "@/hooks/use-translations"; import str from "@/hooks/use-string"; import { cn, GetTranslation } from "@/lib/utils"; interface GoToFrontViewProps { /** Model Name used to translate the helper */ modelName: string; /** Field data to build path */ pathField: string; /** Additionnal segment used in the url */ additionalGroupPath?: string | null; /** Does the actual page status available in front */ isAvailable?: boolean; /** Set visually in column */ isColumn?: boolean; } export default function GoToFrontView({ modelName, pathField, additionalGroupPath = null, isAvailable = false, isColumn = false, }: GoToFrontViewProps) { const { url } = usePage().props.appEnv as AppEnv; const anchorAccessPage = useTrans("uwil-backend::back.access_model", { params: { model: modelName, }, }); const cleanUrl = url.endsWith("/") ? url.slice(0, -1) : url; const definitivePath = [cleanUrl, additionalGroupPath, pathField] .filter(Boolean) .join("/"); return ( {isAvailable ? ( <> {str( GetTranslation("uwil-backend::back.access_to_front_page", { params: { model: modelName, }, }), ) .ucFirst() .value()}

{definitivePath}

{anchorAccessPage}
) : ( <> {str( GetTranslation( "uwil-backend::back.access_to_front_page_when_published", { params: { model: modelName, }, }, ), ) .ucFirst() .value()} :{definitivePath} )}
); }