Compare commits

..

No commits in common. "339a3ca5af4f2bc1ae33aebdb5848deec22dc3f9" and "bb85873d3dd0f5c5a506bd977a93b670a2f8ba8f" have entirely different histories.

View File

@ -1,14 +1,15 @@
import { useState } from "react"; import { useState } from "react";
import { EngagementShareRecipe } from "../../services/EngagementService"; import { EngagementShareRecipe } from "../../services/EngagementService";
import { isApiError } from "../../types/api/error"; import { isApiError } from "../../types/api/error";
import { GetBackendUrl } from "../../services/environment";
import ROUTE_CONSTANTS from "../../types/routes";
interface ShareButtonProps { interface ShareButtonProps {
id: number; id: number;
} }
// TODO: Abstract this somehow, this needs to be loaded from the env
const DOMAIN = "http://localhost:5173/";
export default function ShareButton({ id }: ShareButtonProps) { export default function ShareButton({ id }: ShareButtonProps) {
const [clicked, setClicked] = useState<boolean>(false); const [clicked, setClicked] = useState<boolean>(false);
@ -16,8 +17,7 @@ export default function ShareButton({ id }: ShareButtonProps) {
if (clicked) return; if (clicked) return;
// Copy first, so it feels fast // Copy first, so it feels fast
const url = `${GetBackendUrl()}${ROUTE_CONSTANTS.Recipe(id)}`; await navigator.clipboard.writeText(`${DOMAIN}/v2/web/recipe/${id}`)
await navigator.clipboard.writeText(url);
const result = await EngagementShareRecipe(id); const result = await EngagementShareRecipe(id);
if (isApiError(result)) { if (isApiError(result)) {