Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert changes #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 11 additions & 28 deletions frontend/src/components/flow-testing/flow-page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import { FormInput } from "../ui/forms/form-input";
import FormSelect from "../ui/forms/form-select";
import GenericForm from "../ui/forms/generic-form";
import axios from "axios";
import { Flow } from "../../types/flow-types";
import { FetchFlowsResponse } from "../../types/flow-types";
import RenderFlows from "./render-flows";
import Stepper from "../ui/mini-components/stepper";
import { MdOutlineDomainVerification } from "react-icons/md";
Expand All @@ -18,7 +18,7 @@ export default function FlowContent() {
const [step, setStep] = useState(0);
const [session, setSession] = useState<string>("");
const [subUrl, setSubUrl] = useState<string>("");
const [flows, setFlows] = useState<Flow[] | null>(null);
const [flows, setFlows] = useState<FetchFlowsResponse | null>(null);
const [report, setReport] = useState("");

const onSubmit = async (data: any) => {
Expand Down Expand Up @@ -56,33 +56,22 @@ export default function FlowContent() {
console.error("error while sending response", e);
}
};
const fetchFlows = async (data: any) => {
const fetchFlows = async () => {
try {
const response = await axios.get(
`${import.meta.env.VITE_BACKEND_URL}/config/flows`,
{
params: {
domain: data.domain,
version: data.version,
usecase: data.usecase
}
}
`${import.meta.env.VITE_BACKEND_URL}/flow`,
{}
);
setFlows(response.data.data.flows);
setFlows(response.data);
console.log("flows", response.data);
} catch (e) {
console.log("error while fetching flows", e);
}
};

const onSubmitHandler = async (data: any) => {
await fetchFlows(data)
await onSubmit(data)
}

// useEffect(() => {
// fetchFlows();
// }, []);
useEffect(() => {
fetchFlows();
}, []);

const Body = () => {
switch (step) {
Expand All @@ -93,7 +82,7 @@ export default function FlowContent() {
<Heading size=" text-xl" className="mb-2">
Details
</Heading>
<GenericForm onSubmit={onSubmitHandler}>
<GenericForm onSubmit={onSubmit}>
<FormInput
label="Enter Subscriber Url"
name="subscriberUrl"
Expand All @@ -118,12 +107,6 @@ export default function FlowContent() {
required={true}
options={["2.0.0"]}
/>
<FormSelect
label="Enter Usecase"
name="usecase"
required={true}
options={["Metro"]}
/>
{/* <FormInput
label="Enter City Code"
name="city"
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/flow-testing/render-flows.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from "react";
import { Flow } from "../../types/flow-types";
import { FetchFlowsResponse } from "../../types/flow-types";
import InfoCard from "../ui/info-card";
import DifficultyCards from "../ui/difficulty-cards";
import axios from "axios";
Expand All @@ -25,7 +25,7 @@ function RenderFlows({
setStep,
setReport,
}: {
flows: Flow[];
flows: FetchFlowsResponse;
subUrl: string;
sessionId: string;
setStep: React.Dispatch<React.SetStateAction<number>>;
Expand Down Expand Up @@ -218,9 +218,9 @@ function RenderFlows({
<div className="flex flex-1 w-full">
{/* Left Column - Main Content */}
<div className="w-full sm:w-[60%] overflow-y-auto p-4">
{/* {flows.domain.map((domain) => ( */}
<div className="mb-8">
{flows.map((flow) => (
{flows.domain.map((domain) => (
<div key={domain.name} className="mb-8">
{domain.flows.map((flow) => (
<Accordion
key={flow.id}
flow={flow}
Expand All @@ -235,7 +235,7 @@ function RenderFlows({
/>
))}
</div>
{/* ))} */}
))}
</div>

{/* Right Column - Sticky Request & Response */}
Expand Down