diff --git a/frontend/src/components/Modals/DuplicateSnippetModal.jsx b/frontend/src/components/Modals/DuplicateSnippetModal.jsx index 0478dad9..a8a3d49f 100644 --- a/frontend/src/components/Modals/DuplicateSnippetModal.jsx +++ b/frontend/src/components/Modals/DuplicateSnippetModal.jsx @@ -21,7 +21,7 @@ const initialFormState = { state: 'initial', message: '' }; // duplicateSnippet function DuplicateSnippetModal({ handleClose, isOpen }) { - const { currSnippetName, code, ownerUsername } = useSelector( + const { currSnippetName, currSnippetLng, code, ownerUsername } = useSelector( ({ modal }) => modal.item, ); const navigate = useNavigate(); @@ -29,7 +29,7 @@ function DuplicateSnippetModal({ handleClose, isOpen }) { const { genViewSnippetLink } = useSnippets(); const { t } = useTranslation(); const username = useSelector((state) => state.user.userInfo.username); - const language = useSelector((state) => state.languages.currentLanguage); + const nameRef = useRef(null); const [formState, setFormState] = useState({ state: 'initial', message: '' }); @@ -49,7 +49,7 @@ function DuplicateSnippetModal({ handleClose, isOpen }) { const { slug } = await duplicateSnippet({ code, snippetName: preparedValues.snippetName, - language, + language: currSnippetLng, }); const url = new URL(genViewSnippetLink(username, slug)); diff --git a/frontend/src/pages/profile/SnippetCard.jsx b/frontend/src/pages/profile/SnippetCard.jsx index 67ad78f2..fd7c63d7 100644 --- a/frontend/src/pages/profile/SnippetCard.jsx +++ b/frontend/src/pages/profile/SnippetCard.jsx @@ -260,7 +260,7 @@ function CardFooter({ handleDelete, handleShare, handleDuplicate }) { } function SnippetCard({ data }) { - const { id, name, slug, code } = data; + const { id, name, slug, code, language } = data; const ownerUsername = data.user.username; const dispatch = useDispatch(); const [mode, setMode] = useState('viewing'); @@ -277,6 +277,7 @@ function SnippetCard({ data }) { type: 'duplicateSnippet', item: { currSnippetName: name, + currSnippetLng: language, ownerUsername, code, }, diff --git a/frontend/src/pages/snippet/ActionsToolbar.jsx b/frontend/src/pages/snippet/ActionsToolbar.jsx index e158f4b3..b04a556c 100644 --- a/frontend/src/pages/snippet/ActionsToolbar.jsx +++ b/frontend/src/pages/snippet/ActionsToolbar.jsx @@ -17,6 +17,7 @@ function ActionsToolbar({ snippet }) { const dispatch = useDispatch(); const { snippetData, code, isAllSaved } = snippet; const { name: snippetName, ownerUsername } = snippetData; + const { language } = snippetData; const { isLoggedIn } = useAuth(); const { direction } = useSelector((state) => state.editor); const handleShare = () => { @@ -35,6 +36,7 @@ function ActionsToolbar({ snippet }) { type: 'duplicateSnippet', item: { currSnippetName: snippetName, + currSnippetLng: language, ownerUsername, code, }, @@ -46,6 +48,7 @@ function ActionsToolbar({ snippet }) { type: 'attemptDuplicateSnippet', item: { currSnippetName: snippetName, + currSnippetLng: language, code, }, }),