@@ -21,9 +21,7 @@ import { CopyToClipboard } from "react-copy-to-clipboard"
2121import formatXml from "xml-formatter"
2222import { saveAs } from "file-saver"
2323
24- const BreadCrumb = ( { stub } ) => {
25- const [ project ] = useQuery ( getProject , { id : stub . projectId } )
26-
24+ const BreadCrumb = ( { stub, project } ) => {
2725 return (
2826 < Suspense fallback = { < > </ > } >
2927 < Breadcrumb m = "2" color = "#666" >
@@ -46,8 +44,7 @@ const BreadCrumb = ({ stub }) => {
4644 </ Suspense >
4745 )
4846}
49- const CopyUrlButton = ( { stub } ) => {
50- const [ project ] = useQuery ( getProject , { id : stub . projectId } )
47+ const CopyUrlButton = ( { stub, project } ) => {
5148 return (
5249 < Suspense fallback = { < > </ > } >
5350 < CopyToClipboard
@@ -72,17 +69,18 @@ export const Stub = () => {
7269 const stubId = useParam ( "stubId" , "number" )
7370 const [ deleteStubMutation ] = useMutation ( deleteStub )
7471 const [ stub ] = useQuery ( getStub , { id : stubId } )
72+ const [ project ] = useQuery ( getProject , { id : stub . projectId } )
7573
7674 return (
7775 < Box >
78- < BreadCrumb stub = { stub } />
76+ < BreadCrumb stub = { stub } project = { project } />
7977 < Flex align = "center" justify = "center" m = { 5 } >
8078 < Box w = "80%" >
8179 < Heading size = "lg" as = "h1" >
8280 Stub
8381 </ Heading >
8482 < Flex justify = "flex-end" >
85- < CopyUrlButton stub = { stub } />
83+ < CopyUrlButton stub = { stub } project = { project } />
8684 < Link href = { Routes . EditStubPage ( { stubId : stub . id } ) } >
8785 < Button
8886 mr = "2"
@@ -103,7 +101,20 @@ export const Stub = () => {
103101 onClick = { async ( ) => {
104102 const { path, method, contentType, statusCode, response, sleep } = stub
105103 const blob = new Blob (
106- [ JSON . stringify ( { path, method, contentType, statusCode, response, sleep } ) ] ,
104+ [
105+ JSON . stringify (
106+ {
107+ path : `/api${ project . basePath } ${ path } ` ,
108+ method,
109+ contentType,
110+ statusCode,
111+ response,
112+ sleep : sleep * 1000 ,
113+ } ,
114+ null ,
115+ 2
116+ ) ,
117+ ] ,
107118 {
108119 type : "application/json; charset=utf-8" ,
109120 }
0 commit comments