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:
committed by
GitHub
parent
1cc845e17d
commit
bb4b640e58
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user