-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KRAKEN-76: standard API mapping (#18)
* KRAKEN-76: standard API mapping
- Loading branch information
1 parent
380b984
commit f4c98b6
Showing
4 changed files
with
156 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import RenderList from "@/pages/StandardAPIMapping/components/RenderList"; | ||
|
||
test("RenderList component", async () => { | ||
render( | ||
<RenderList | ||
data={[ | ||
{ | ||
path: "/a/b/c/d", | ||
method: "POST", | ||
}, | ||
]} | ||
/> | ||
); | ||
const methodEle = await screen.findByText("POST"); | ||
const pathEle = await screen.findByText("/a/b/c/d"); | ||
expect(methodEle).toBeInTheDocument(); | ||
expect(pathEle).toBeInTheDocument(); | ||
}); |
7 changes: 7 additions & 0 deletions
7
src/pages/StandardAPIMapping/components/RenderList/index.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.collapse { | ||
> :global(.ant-collapse-item) { | ||
> :global(.ant-collapse-header) { | ||
padding: 0; | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/pages/StandardAPIMapping/components/RenderList/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import LogMethodTag from "@/components/LogMethodTag"; | ||
import Text from "@/components/Text"; | ||
import { Button, Collapse, Flex } from "antd"; | ||
import { useCallback } from "react"; | ||
import styles from "./index.module.scss"; | ||
|
||
export interface IMapProductAndType { | ||
path: string; | ||
method: string; | ||
actionTypes?: string[]; | ||
productTypes?: string[]; | ||
} | ||
|
||
const RenderList = ({ data }: { data?: IMapProductAndType[] }) => { | ||
const hasAction = useCallback( | ||
(s: IMapProductAndType) => (s.actionTypes?.length ?? 0) > 0, | ||
[] | ||
); | ||
if (!data) return null | ||
return ( | ||
<Flex vertical gap={12}> | ||
{data.map((s: IMapProductAndType) => ( | ||
<Flex | ||
vertical | ||
align="stretch" | ||
justify="space-between" | ||
gap={14} | ||
key={`${s.method} - ${s.path}`} | ||
className={styles.mappingWrapper} | ||
> | ||
<Flex align="center" justify="space-between"> | ||
<Flex align="center" gap={16}> | ||
<LogMethodTag method={s.method.toUpperCase()} /> | ||
<Text.NormalMedium>{s.path}</Text.NormalMedium> | ||
<Text.NormalMedium color="rgba(0,0,0,0.45)"> | ||
Description?? | ||
</Text.NormalMedium> | ||
</Flex> | ||
<Flex align="center" gap={8}> | ||
<Button style={{ marginRight: hasAction(s) ? 96 : 0 }}> | ||
View | ||
</Button> | ||
{!hasAction(s) ? <Button type="primary">Mapping</Button> : null} | ||
</Flex> | ||
</Flex> | ||
{hasAction(s) && ( | ||
<Collapse | ||
ghost | ||
items={s.actionTypes?.map((type) => ({ | ||
key: type, | ||
label: ( | ||
<Flex align="center" justify="space-between"> | ||
<Flex align="center" gap={12}> | ||
<Text.NormalLarge>{type}</Text.NormalLarge> | ||
<Text.NormalMedium color="rgba(0, 0, 0, 0.45)"> | ||
Description?? | ||
</Text.NormalMedium> | ||
</Flex> | ||
<Button type="primary">Mapping</Button> | ||
</Flex> | ||
), | ||
}))} | ||
className={styles.collapse} | ||
/> | ||
)} | ||
</Flex> | ||
))} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default RenderList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters