feat: duplicate your own recipe
The fork endpoint already had no "isn't yours" check, so this is a
UI-only change: ForkRecipeButton takes a variant prop ("fork" for
others' recipes, "duplicate" for your own) that swaps icon/label/toast
copy, and now renders unconditionally instead of only for non-owners.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
All notable changes to Epicure are documented here. This file is mirrored in-app at `/changelog` (and in the admin dashboard) via `apps/web/lib/changelog.ts` — update both together.
|
||||
|
||||
## 0.20.0 — 2026-07-13 22:26
|
||||
|
||||
### Added
|
||||
- **Duplicate your own recipe** — same one-click copy used for forking others' recipes, now also on your own, for making variations without touching version history.
|
||||
|
||||
## 0.19.0 — 2026-07-13 22:21
|
||||
|
||||
### Added
|
||||
|
||||
@@ -222,7 +222,7 @@ export default async function RecipePage({ params }: Params) {
|
||||
order: s.order,
|
||||
}))}
|
||||
/>
|
||||
{!isOwner && <ForkRecipeButton recipeId={id} />}
|
||||
<ForkRecipeButton recipeId={id} variant={isOwner ? "duplicate" : "fork"} />
|
||||
<ShareRecipeButton recipeId={id} visibility={recipe.visibility} />
|
||||
<PrintButton recipeId={id} />
|
||||
<ExportMarkdownButton
|
||||
|
||||
@@ -3,15 +3,20 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { GitFork, Loader2 } from "lucide-react";
|
||||
import { GitFork, Copy, Loader2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export function ForkRecipeButton({ recipeId }: { recipeId: string }) {
|
||||
// Forking someone else's recipe and duplicating your own hit the exact same
|
||||
// endpoint (apps/web/app/api/v1/recipes/[id]/fork/route.ts has no
|
||||
// "isn't yours" check) — only the label/icon/toast copy differs, since
|
||||
// "fork" implies attribution that doesn't apply to your own recipe.
|
||||
export function ForkRecipeButton({ recipeId, variant = "fork" }: { recipeId: string; variant?: "fork" | "duplicate" }) {
|
||||
const t = useTranslations("recipe");
|
||||
const router = useRouter();
|
||||
const [forking, setForking] = useState(false);
|
||||
const isDuplicate = variant === "duplicate";
|
||||
|
||||
async function handleFork() {
|
||||
setForking(true);
|
||||
@@ -24,7 +29,7 @@ export function ForkRecipeButton({ recipeId }: { recipeId: string }) {
|
||||
);
|
||||
}
|
||||
const data = await res.json() as { id: string };
|
||||
toast.success(t("forked"));
|
||||
toast.success(isDuplicate ? t("duplicated") : t("forked"));
|
||||
router.push(`/recipes/${data.id}`);
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : t("forkFailed"));
|
||||
@@ -32,15 +37,17 @@ export function ForkRecipeButton({ recipeId }: { recipeId: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
const label = isDuplicate ? t("duplicateTooltip") : t("forkTooltip");
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={
|
||||
<Button variant="ghost" size="icon" onClick={() => { void handleFork(); }} disabled={forking} aria-label={t("forkTooltip")}>
|
||||
{forking ? <Loader2 className="h-4 w-4 animate-spin" /> : <GitFork className="h-4 w-4" />}
|
||||
<Button variant="ghost" size="icon" onClick={() => { void handleFork(); }} disabled={forking} aria-label={label}>
|
||||
{forking ? <Loader2 className="h-4 w-4 animate-spin" /> : isDuplicate ? <Copy className="h-4 w-4" /> : <GitFork className="h-4 w-4" />}
|
||||
</Button>
|
||||
} />
|
||||
<TooltipContent>{t("forkTooltip")}</TooltipContent>
|
||||
<TooltipContent>{label}</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mirrors CHANGELOG.md at the repo root — update both together.
|
||||
export const APP_VERSION = "0.19.0";
|
||||
export const APP_VERSION = "0.20.0";
|
||||
|
||||
export type ChangelogEntry = {
|
||||
version: string;
|
||||
@@ -11,6 +11,13 @@ export type ChangelogEntry = {
|
||||
};
|
||||
|
||||
export const CHANGELOG: ChangelogEntry[] = [
|
||||
{
|
||||
version: "0.20.0",
|
||||
date: "2026-07-13 22:26",
|
||||
added: [
|
||||
"**Duplicate your own recipe** — same one-click copy used for forking others' recipes, now also on your own, for making variations without touching version history.",
|
||||
],
|
||||
},
|
||||
{
|
||||
version: "0.19.0",
|
||||
date: "2026-07-13 22:21",
|
||||
|
||||
@@ -121,6 +121,8 @@
|
||||
"forked": "Recipe forked to your library",
|
||||
"forkFailed": "Failed to fork recipe",
|
||||
"forkLimitReached": "Recipe limit reached for your tier",
|
||||
"duplicateTooltip": "Duplicate this recipe",
|
||||
"duplicated": "Recipe duplicated",
|
||||
"forkedFrom": "Forked from {title}",
|
||||
"pairingFindingLabel": "Finding perfect pairings…",
|
||||
"pairingSuggestButton": "Suggest pairings",
|
||||
|
||||
@@ -122,6 +122,8 @@
|
||||
"forked": "Recette copiée dans votre bibliothèque",
|
||||
"forkFailed": "Échec de la copie de la recette",
|
||||
"forkLimitReached": "Limite de recettes atteinte pour votre offre",
|
||||
"duplicateTooltip": "Dupliquer cette recette",
|
||||
"duplicated": "Recette dupliquée",
|
||||
"forkedFrom": "Copiée depuis {title}",
|
||||
"pairingFindingLabel": "Recherche des meilleurs accords…",
|
||||
"pairingSuggestButton": "Suggérer des accompagnements",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@epicure/web",
|
||||
"version": "0.19.0",
|
||||
"version": "0.20.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "epicure",
|
||||
"version": "0.19.0",
|
||||
"version": "0.20.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "pnpm --filter web dev",
|
||||
|
||||
Reference in New Issue
Block a user