diff --git a/src/people/WorkSpacePlanner/BountyCard/index.tsx b/src/people/WorkSpacePlanner/BountyCard/index.tsx new file mode 100644 index 00000000..403f60f7 --- /dev/null +++ b/src/people/WorkSpacePlanner/BountyCard/index.tsx @@ -0,0 +1,148 @@ +import React from 'react'; +import styled from 'styled-components'; +import PropTypes from 'prop-types'; +import { BountyCard } from '../../../store/interface'; +import { colors } from '../../../config'; + +const truncate = (str: string, n: number) => (str.length > n ? `${str.substr(0, n - 1)}...` : str); + +const CardContainer = styled.div` + width: 384px; + height: auto; + border-radius: 8px; + padding: 16px 16px 0 16px; + margin-bottom: 16px; + display: flex; + flex-direction: column; + background-color: ${colors.light.grayish.G950}; + cursor: pointer; +`; + +const CardHeader = styled.div` + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 16px; +`; + +const CardTitle = styled.h3` + font-size: 22px; + font-weight: 600; + margin: 0; + padding-right: 16px; + flex: 1; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + text-align: left; + cursor: pointer; + &:hover { + color: ${colors.light.primaryColor}; + } +`; + +const AssignerPic = styled.div` + width: 40px; + height: 40px; + border-radius: 50%; + overflow: hidden; + background-color: ${colors.light.red1}; + display: flex; + justify-content: center; + align-items: center; + font-size: 14px; + color: white; + + img { + width: 100%; + height: 100%; + object-fit: cover; + } +`; + +const RowT = styled.div` + display: flex; + justify-content: flex-start; + margin-bottom: 8px; + font-size: 14px; + color: ${colors.light.text2}; + gap: 1.5rem; + + .last-span { + margin-left: auto; + margin-right: 0; + } +`; + +const RowB = styled.div` + display: flex; + justify-content: flex-start; + margin-bottom: 8px; + font-size: 14px; + color: ${colors.light.text2}; + gap: 4rem; + + .last-span { + margin-left: auto; + margin-right: 0; + } +`; + +interface BountyCardProps extends BountyCard { + onclick: (bountyId: string) => void; +} + +const BountyCardComponent: React.FC = ({ + id, + title, + features, + phase, + assignee_img, + workspace, + onclick +}: BountyCardProps) => ( + onclick(id)}> + + ) => e.stopPropagation()} + > + {title} + + {assignee_img ? Assigner : 'Pic'} + + + + + {truncate(features?.name ?? 'No Feature', 10)} + + {truncate(phase?.name ?? 'No Phase', 20)} + + + {id} + + {truncate(workspace?.name ?? 'No Workspace', 20)} + + Paid? + + +); + +BountyCardComponent.propTypes = { + id: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + features: PropTypes.shape({ + name: PropTypes.string + }) as PropTypes.Validator, + phase: PropTypes.shape({ + name: PropTypes.string + }) as PropTypes.Validator, + assignee_img: PropTypes.string, + workspace: PropTypes.shape({ + name: PropTypes.string + }) as PropTypes.Validator, + onclick: PropTypes.func.isRequired +}; + +export default BountyCardComponent; diff --git a/src/people/WorkSpacePlanner/index.tsx b/src/people/WorkSpacePlanner/index.tsx index 5f91ecf2..d932f281 100644 --- a/src/people/WorkSpacePlanner/index.tsx +++ b/src/people/WorkSpacePlanner/index.tsx @@ -5,9 +5,11 @@ import { EuiLoadingSpinner } from '@elastic/eui'; import styled from 'styled-components'; import { useBountyCardStore } from 'store/bountyCard'; import { BountyCard } from 'store/interface'; +import history from 'config/history'; import { useStores } from '../../store'; import { colors } from '../../config'; import { WorkspacePlannerHeader } from './WorkspacePlannerHeader'; +import BountyCardComp from './BountyCard'; const PlannerContainer = styled.div` padding: 0; @@ -67,12 +69,15 @@ const WorkspacePlanner = () => { ); } + const onclick = (bountyId: string) => { + history.push(`/bounty/${bountyId}`); + }; + return (

Welcome to the new Workspace Planner

-

Bounty Cards

{bountyCardStore.loading ? ( ) : bountyCardStore.error ? ( @@ -80,9 +85,7 @@ const WorkspacePlanner = () => { ) : ( {bountyCardStore.bountyCards.map((card: BountyCard) => ( -
  • - {card.title} -
  • + ))}
    )} diff --git a/src/store/interface.ts b/src/store/interface.ts index 3702f13a..b5460c34 100644 --- a/src/store/interface.ts +++ b/src/store/interface.ts @@ -511,4 +511,5 @@ export interface BountyCard { features: Feature; phase: Phase; workspace: Workspace; + assignee_img?: string; }