@@ -11,12 +11,13 @@ import {
1111 Toast ,
1212 useNavigation ,
1313} from "@raycast/api" ;
14- import { FormValidation , getFavicon , useCachedPromise , useForm } from "@raycast/utils" ;
14+ import { FormValidation , getFavicon , useCachedPromise , useCachedState , useForm , usePromise } from "@raycast/utils" ;
1515import { mxroute } from "./mxroute" ;
1616import EmailAccounts from "./email-accounts" ;
1717import EmailForwarders from "./email-forwarders" ;
1818import Advanced from "./advanced" ;
1919import DNSInfo from "./dns-info" ;
20+ import { DomainVerificationKey } from "./types" ;
2021
2122export default function ManageDomains ( ) {
2223 const {
@@ -78,6 +79,11 @@ export default function ManageDomains() {
7879
7980function AddDomain ( { firstDomainName } : { firstDomainName : string } ) {
8081 const { pop, push } = useNavigation ( ) ;
82+ const [ data , setData ] = useCachedState < DomainVerificationKey > ( "domain-verification-key" ) ;
83+ const { isLoading } = usePromise ( mxroute . getDomainVerificationKey , [ ] , {
84+ onData : setData ,
85+ execute : ! data ,
86+ } ) ;
8187 const { handleSubmit, itemProps } = useForm < { domain : string } > ( {
8288 async onSubmit ( values ) {
8389 const { domain } = values ;
@@ -111,9 +117,24 @@ function AddDomain({ firstDomainName }: { firstDomainName: string }) {
111117 } ) ;
112118 return (
113119 < Form
120+ isLoading = { isLoading }
114121 actions = {
115122 < ActionPanel >
116123 < Action . SubmitForm icon = { Icon . Plus } title = "Add Domain" onSubmit = { handleSubmit } />
124+ { data && (
125+ < ActionPanel . Section >
126+ < Action . CopyToClipboard
127+ title = "Copy Name to Clipboard"
128+ content = { data . record . name }
129+ shortcut = { Keyboard . Shortcut . Common . CopyName }
130+ />
131+ < Action . CopyToClipboard
132+ title = "Copy Value to Clipboard"
133+ content = { data . record . value }
134+ shortcut = { Keyboard . Shortcut . Common . Copy }
135+ />
136+ </ ActionPanel . Section >
137+ ) }
117138 </ ActionPanel >
118139 }
119140 >
@@ -123,6 +144,15 @@ function AddDomain({ firstDomainName }: { firstDomainName: string }) {
123144 info = "Enter the domain without www (e.g., example.com)"
124145 { ...itemProps . domain }
125146 />
147+ < Form . Separator />
148+ { data && (
149+ < >
150+ < Form . Description text = { data . description } />
151+ < Form . Description title = "Type" text = { data . record . type } />
152+ < Form . Description title = "Name" text = { data . record . name } />
153+ < Form . Description title = "Value" text = { data . record . value } />
154+ </ >
155+ ) }
126156 </ Form >
127157 ) ;
128158}
0 commit comments