Skip to content

Add "Copy all snippets" button on task with multiple snippets 📋 #544

Description

@anoopcodehack

Add "Copy all snippets" button on task with multiple snippets 📋

File: client/src/components/Task/TaskModal.jsx

Tasks can have multiple snippets but
you can only copy one at a time 💀 fr!!

Fix: add copy all button when 2+ snippets exist:
const handleCopyAll = () => {
const allCode = task?.snippets
?.map((s, i) =>
// Snippet ${i+1} (${s.language})\n${s.code}
)
.join('\n\n---\n\n')
navigator.clipboard.writeText(allCode)
setCopiedAll(true)
setTimeout(() => setCopiedAll(false), 2000)
}

{task?.snippets?.length > 1 && (

{copiedAll ? '✅ Copied all!' : '📋 Copy all snippets'}

)}

~12 lines! No backend needed 🎯

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions