import { gql, useQuery } from "@apollo/client"; import { Link, useRouter } from "@curi/react-dom"; import { List, ListItem, Typography, ListItemText, ListItemSecondaryAction, IconButton, } from "@material-ui/core"; import { FC, MouseEventHandler, useMemo } from "react"; import { Pipeline, Project } from "../generated/graphql"; import { CallMerge, Edit } from "@material-ui/icons"; import { clone } from "ramda"; import { useEffect } from "react"; interface Props { projectId: string; } const PIPELINES = gql` query Pipelines($projectId: String!) { pipelines(projectId: $projectId) { id name branch } project(id: $projectId) { id } } `; export const PipelineList: FC = ({ projectId }) => { const { data, loading } = useQuery< { pipelines: Pipeline[]; project: Project }, { projectId: string } >(PIPELINES, { variables: { projectId }, }); const pipelines = useMemo(() => { return data?.pipelines?.map((pipeline) => ({ ...pipeline, project: data?.project, })); }, [data]); return ( {pipelines?.map((pipeline) => ( ))} ); }; const Item = ({ pipeline }: { pipeline: Pipeline }) => { const { navigate, url } = useRouter(); const modify: MouseEventHandler = (ev) => { ev.preventDefault(); navigate({ url: url({ name: "edit-pipeline", params: { pipelineId: pipeline.id, projectId: pipeline.project.id }, }), }); }; return ( {pipeline.branch} } /> ); };