Refactoring Lenses Using Vue Composables (#1995)

This commit is contained in:
Rishabh Agarwal
2022-01-17 21:00:48 +05:30
committed by GitHub
parent ddff126aaa
commit 647c347eb1
10 changed files with 187 additions and 208 deletions

View File

@@ -0,0 +1,24 @@
import { Ref, ref } from "@nuxtjs/composition-api"
import { copyToClipboard } from "~/helpers/utils/clipboard"
import { useI18n, useToast } from "~/helpers/utils/composables"
export default function useCopyResponse(responseBodyText: Ref<any>): {
copyIcon: Ref<string>
copyResponse: () => void
} {
const toast = useToast()
const t = useI18n()
const copyIcon = ref("copy")
const copyResponse = () => {
copyToClipboard(responseBodyText.value)
copyIcon.value = "check"
toast.success(`${t("state.copied_to_clipboard")}`)
setTimeout(() => (copyIcon.value = "copy"), 1000)
}
return {
copyIcon,
copyResponse,
}
}