feat: convert json to interfaces (#3566)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
Rajdip Bhattacharya
2023-12-03 23:14:26 +05:30
committed by GitHub
parent 1cc845e17d
commit bb4b640e58
9 changed files with 283 additions and 64 deletions

View File

@@ -11,6 +11,29 @@ import { refAutoReset } from "@vueuse/core"
import { copyToClipboard } from "@helpers/utils/clipboard"
import { HoppRESTResponse } from "@helpers/types/HoppRESTResponse"
import { platform } from "~/platform"
import jsonToLanguage from "~/helpers/utils/json-to-language"
export function useCopyInterface(responseBodyText: Ref<string>) {
const toast = useToast()
const t = useI18n()
const copyInterfaceIcon = refAutoReset(IconCopy, 1000)
const copyInterface = async (targetLanguage: string) => {
jsonToLanguage(targetLanguage, responseBodyText.value).then((res) => {
copyToClipboard(res.lines.join("\n"))
copyInterfaceIcon.value = IconCheck
toast.success(
t("state.copied_interface_to_clipboard", { language: targetLanguage })
)
})
}
return {
copyInterfaceIcon,
copyInterface,
}
}
export function useCopyResponse(responseBodyText: Ref<any>) {
const toast = useToast()