Merge pull request '(FIX): Fixing the issue with the localhost share button' (#66) from refactor/react into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 58s
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 58s
Reviewed-on: #66
This commit is contained in:
commit
a0acd0fd46
@ -1,15 +1,14 @@
|
|||||||
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);
|
||||||
|
|
||||||
@ -17,7 +16,8 @@ export default function ShareButton({ id }: ShareButtonProps) {
|
|||||||
if (clicked) return;
|
if (clicked) return;
|
||||||
|
|
||||||
// Copy first, so it feels fast
|
// Copy first, so it feels fast
|
||||||
await navigator.clipboard.writeText(`${DOMAIN}/v2/web/recipe/${id}`)
|
const url = `${GetBackendUrl()}${ROUTE_CONSTANTS.Recipe(id)}`;
|
||||||
|
await navigator.clipboard.writeText(url);
|
||||||
|
|
||||||
const result = await EngagementShareRecipe(id);
|
const result = await EngagementShareRecipe(id);
|
||||||
if (isApiError(result)) {
|
if (isApiError(result)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user