upp
This commit is contained in:
parent
b246410e11
commit
e5b7b5ddf5
|
@ -22,7 +22,7 @@ const Login = ({ setisLoggedIn }) => {
|
||||||
const Login = async () => {
|
const Login = async () => {
|
||||||
setisLoading(true);
|
setisLoading(true);
|
||||||
console.log(email, password);
|
console.log(email, password);
|
||||||
const url = "http://localhost:3000/api/auth/login";
|
const url = "http://localhost:3001/api/auth/login";
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -85,7 +85,7 @@ const Login = ({ setisLoggedIn }) => {
|
||||||
const Register = async () => {
|
const Register = async () => {
|
||||||
setisLoading(true);
|
setisLoading(true);
|
||||||
console.log(email, password);
|
console.log(email, password);
|
||||||
const url = "http://localhost:3000/api/auth/register";
|
const url = "http://localhost:3001/api/auth/register";
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -6,12 +6,18 @@ import JsonEditor from "./Editors";
|
||||||
import { FaPaperPlane } from "react-icons/fa6";
|
import { FaPaperPlane } from "react-icons/fa6";
|
||||||
import { IoMdDownload } from "react-icons/io";
|
import { IoMdDownload } from "react-icons/io";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
|
|
||||||
interface FormProps {
|
interface FormProps {
|
||||||
onSubmit: (data: any) => void;
|
onSubmit: (data: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Form: React.FC<FormProps> = ({ onSubmit, content, setisRefresh }) => {
|
const Form: React.FC<FormProps> = ({
|
||||||
|
onSubmit,
|
||||||
|
content,
|
||||||
|
setisRefresh,
|
||||||
|
isLoading,
|
||||||
|
}) => {
|
||||||
const [method, setMethod] = useState(content?.method ?? "GET");
|
const [method, setMethod] = useState(content?.method ?? "GET");
|
||||||
const [url, setUrl] = useState(content?.endpoint ?? "");
|
const [url, setUrl] = useState(content?.endpoint ?? "");
|
||||||
const [isSaved, setisSaved] = useState(false);
|
const [isSaved, setisSaved] = useState(false);
|
||||||
|
@ -21,7 +27,9 @@ const Form: React.FC<FormProps> = ({ onSubmit, content, setisRefresh }) => {
|
||||||
const [headers, setHeaders] = useState(
|
const [headers, setHeaders] = useState(
|
||||||
content?.header ?? [{ key: "", value: "" }]
|
content?.header ?? [{ key: "", value: "" }]
|
||||||
);
|
);
|
||||||
const [formData, setformData] = useState(content?.form_data ?? [{ key: "", value: "" }]);
|
const [formData, setformData] = useState(
|
||||||
|
content?.form_data ?? [{ key: "", value: "" }]
|
||||||
|
);
|
||||||
const [jsonBody, setJsonBody] = useState(content ?? {});
|
const [jsonBody, setJsonBody] = useState(content ?? {});
|
||||||
const [activeTab, setActiveTab] = useState("query-params");
|
const [activeTab, setActiveTab] = useState("query-params");
|
||||||
|
|
||||||
|
@ -108,7 +116,6 @@ const Form: React.FC<FormProps> = ({ onSubmit, content, setisRefresh }) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleRequestEditorChange = (value: string) => {
|
const handleRequestEditorChange = (value: string) => {
|
||||||
setJsonBody(value);
|
setJsonBody(value);
|
||||||
setisSaved(false);
|
setisSaved(false);
|
||||||
|
@ -127,7 +134,7 @@ const Form: React.FC<FormProps> = ({ onSubmit, content, setisRefresh }) => {
|
||||||
params: queryParams,
|
params: queryParams,
|
||||||
};
|
};
|
||||||
const response1 = await axios.patch(
|
const response1 = await axios.patch(
|
||||||
`http://localhost:3000/api/endpoints/update/${content?._id}`,
|
`http://localhost:3001/api/endpoints/update/${content?._id}`,
|
||||||
body1,
|
body1,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -179,7 +186,16 @@ const Form: React.FC<FormProps> = ({ onSubmit, content, setisRefresh }) => {
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-primary border-solid border-[blue] text-[blue] rounded-lg flex justify-center items-center hover:bg-[#abf9ff]"
|
className="btn btn-primary border-solid border-[blue] text-[blue] rounded-lg flex justify-center items-center hover:bg-[#abf9ff]"
|
||||||
>
|
>
|
||||||
<h1 className="mr-2">Send</h1>
|
{isLoading ? (
|
||||||
|
<div className="m-0 text-blue-500">
|
||||||
|
{/* <CircularProgress color="inherit" size={25} /> */}
|
||||||
|
<h1 className="mr-2">Sending</h1>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<h1 className="mr-2">Send</h1>
|
||||||
|
)}
|
||||||
|
|
||||||
<FaPaperPlane />
|
<FaPaperPlane />
|
||||||
</button>
|
</button>
|
||||||
{content?._id ? (
|
{content?._id ? (
|
||||||
|
|
|
@ -57,7 +57,7 @@ const FormGroup: React.FC = () => {
|
||||||
setIsDialogOpen1(false);
|
setIsDialogOpen1(false);
|
||||||
};
|
};
|
||||||
const getCollections = () => {
|
const getCollections = () => {
|
||||||
fetch("http://localhost:3000/api/collections/")
|
fetch("http://localhost:3001/api/collections/")
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
@ -89,7 +89,7 @@ const FormGroup: React.FC = () => {
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
"http://localhost:3000/api/collections/create",
|
"http://localhost:3001/api/collections/create",
|
||||||
body,
|
body,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -114,7 +114,7 @@ const FormGroup: React.FC = () => {
|
||||||
const deleteCollection = async (collectionId) => {
|
const deleteCollection = async (collectionId) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.delete(
|
const response = await axios.delete(
|
||||||
"http://localhost:3000/api/collections/" + collectionId + "/delete",
|
"http://localhost:3001/api/collections/" + collectionId + "/delete",
|
||||||
|
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -137,7 +137,7 @@ const FormGroup: React.FC = () => {
|
||||||
const deleteEndpoint = async (endpointId) => {
|
const deleteEndpoint = async (endpointId) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.delete(
|
const response = await axios.delete(
|
||||||
"http://localhost:3000/api/endpoints/" + endpointId + "/delete",
|
"http://localhost:3001/api/endpoints/" + endpointId + "/delete",
|
||||||
|
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -167,7 +167,7 @@ const FormGroup: React.FC = () => {
|
||||||
try {
|
try {
|
||||||
// Attempt to create the endpoint
|
// Attempt to create the endpoint
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
"http://localhost:3000/api/endpoints/create",
|
"http://localhost:3001/api/endpoints/create",
|
||||||
body,
|
body,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -182,7 +182,7 @@ const FormGroup: React.FC = () => {
|
||||||
endpoint_id: response.data._id,
|
endpoint_id: response.data._id,
|
||||||
};
|
};
|
||||||
const response1 = await axios.patch(
|
const response1 = await axios.patch(
|
||||||
`http://localhost:3000/api/collections/update/${collectionId}/endpoint`,
|
`http://localhost:3001/api/collections/update/${collectionId}/endpoint`,
|
||||||
body1,
|
body1,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -212,7 +212,7 @@ const FormGroup: React.FC = () => {
|
||||||
name: newCollectionName !== "" ? newCollectionName : name,
|
name: newCollectionName !== "" ? newCollectionName : name,
|
||||||
};
|
};
|
||||||
const response1 = await axios.patch(
|
const response1 = await axios.patch(
|
||||||
`http://localhost:3000/api/collections/update/${id}`,
|
`http://localhost:3001/api/collections/update/${id}`,
|
||||||
body1,
|
body1,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -238,7 +238,7 @@ const FormGroup: React.FC = () => {
|
||||||
name: newEndpointName !== "" ? newEndpointName : name,
|
name: newEndpointName !== "" ? newEndpointName : name,
|
||||||
};
|
};
|
||||||
const response1 = await axios.patch(
|
const response1 = await axios.patch(
|
||||||
`http://localhost:3000/api/endpoints/update/${id}`,
|
`http://localhost:3001/api/endpoints/update/${id}`,
|
||||||
body1,
|
body1,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -11,8 +11,10 @@ const FormSingle: React.FC = ({ content, setisRefresh }) => {
|
||||||
const [responseSize, setResponseSize] = useState("");
|
const [responseSize, setResponseSize] = useState("");
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [savedId, setsavedId] = useState(null);
|
const [savedId, setsavedId] = useState(null);
|
||||||
|
const [isLoading, setisLoading] = useState(false)
|
||||||
|
|
||||||
const handleFormSubmit = async (data: any) => {
|
const handleFormSubmit = async (data: any) => {
|
||||||
|
setisLoading(true)
|
||||||
try {
|
try {
|
||||||
const startTime = new Date().getTime();
|
const startTime = new Date().getTime();
|
||||||
const res = await axios(data);
|
const res = await axios(data);
|
||||||
|
@ -24,9 +26,11 @@ const FormSingle: React.FC = ({ content, setisRefresh }) => {
|
||||||
JSON.stringify(res.data).length + JSON.stringify(res.headers).length
|
JSON.stringify(res.data).length + JSON.stringify(res.headers).length
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
setisLoading(false);
|
||||||
setError(null); // Reset error if the request is successful
|
setError(null); // Reset error if the request is successful
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error);
|
setError(error);
|
||||||
|
setisLoading(false)
|
||||||
setResponse(null); // Clear the response if there is an error
|
setResponse(null); // Clear the response if there is an error
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +50,7 @@ const FormSingle: React.FC = ({ content, setisRefresh }) => {
|
||||||
setisRefresh={setisRefresh}
|
setisRefresh={setisRefresh}
|
||||||
content={content}
|
content={content}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
|
isLoading={isLoading}
|
||||||
/>
|
/>
|
||||||
{response && (
|
{response && (
|
||||||
<Response
|
<Response
|
||||||
|
|
|
@ -121,14 +121,17 @@ const KeyValuePair: React.FC<KeyValuePairProps> = ({
|
||||||
{Array.isArray(pair.value) && pair.value.length > 0 && (
|
{Array.isArray(pair.value) && pair.value.length > 0 && (
|
||||||
<div className="flex flex-wrap ml-2">
|
<div className="flex flex-wrap ml-2">
|
||||||
{pair.value.map((file, idx) => (
|
{pair.value.map((file, idx) => (
|
||||||
<div key={idx} className="flex items-center mb-1 border-[#eee] border px-1 rounded-md ">
|
<div
|
||||||
|
key={idx}
|
||||||
|
className="flex items-center mb-1 border-[#eee] border px-1 rounded-md "
|
||||||
|
>
|
||||||
<span className="mr-2 text-[13px]">{file.name}</span>
|
<span className="mr-2 text-[13px]">{file.name}</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-outline-danger text-red-400 border-none shadow-none p-1 "
|
className="btn btn-outline-danger text-red-400 border-none shadow-none p-1 "
|
||||||
onClick={() => handleRemoveFile(file)}
|
onClick={() => handleRemoveFile(file)}
|
||||||
>
|
>
|
||||||
<FaXmark/>
|
<FaXmark />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
Loading…
Reference in New Issue