From e4e4ad1b08ba47ea2828985df8672ab7472222b7 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 12 Oct 2022 11:59:56 -0400 Subject: [PATCH] chore: ensures beforeDuplicate works on each locale --- .../components/elements/DuplicateDocument/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/admin/components/elements/DuplicateDocument/index.tsx b/src/admin/components/elements/DuplicateDocument/index.tsx index b49c34753e..93702bbde4 100644 --- a/src/admin/components/elements/DuplicateDocument/index.tsx +++ b/src/admin/components/elements/DuplicateDocument/index.tsx @@ -73,7 +73,15 @@ const Duplicate: React.FC = ({ slug, collection, id }) => { locale, depth: 0, }); - const localizedDoc = await res.json(); + let localizedDoc = await res.json(); + + if (typeof collection.admin.hooks?.beforeDuplicate === 'function') { + localizedDoc = await collection.admin.hooks.beforeDuplicate({ + data: localizedDoc, + locale, + }); + } + const patchResult = await requests.patch(`${serverURL}${api}/${slug}/${duplicateID}?locale=${locale}`, { headers: { 'Content-Type': 'application/json',