Skip to content

Commit

Permalink
feat: add cost recovery to program cards
Browse files Browse the repository at this point in the history
  • Loading branch information
IanFonzie committed Dec 23, 2024
1 parent df556c2 commit 9a2120d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 6 deletions.
38 changes: 33 additions & 5 deletions src/front-end/typescript/lib/pages/landing.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makePageMetadata, prefixPath } from "front-end/lib";
import { Route, SharedState } from "front-end/lib/app/types";
import { immutable, component as component_ } from "front-end/lib/framework";
import { component as component_ } from "front-end/lib/framework";
import * as api from "front-end/lib/http/api";
import { BulletPoint } from "front-end/lib/views/bullet-point";
import Icon from "front-end/lib/views/icon";
Expand All @@ -19,10 +19,21 @@ import * as cwu from "shared/lib/resources/opportunity/code-with-us";
import * as swu from "shared/lib/resources/opportunity/sprint-with-us";
import { adt, ADT } from "shared/lib/types";
import { OpportunityMetrics } from "shared/lib/resources/metrics";
import {
isPublicSectorEmployee,
User,
UserType
} from "shared/lib/resources/user";
import {
CWU_COST_RECOVERY_FIGURE,
SWU_COST_RECOVERY_FIGURE,
TWU_COST_RECOVERY_FIGURE
} from "front-end/config";

const IMG_MAX_WIDTH = "550px";

export interface State {
viewerUser?: User;
totalCount: number;
totalAwarded: number;
}
Expand All @@ -42,9 +53,10 @@ const init: component_.page.Init<
State,
InnerMsg,
Route
> = () => {
> = ({ shared }) => {
return [
{
viewerUser: shared.session?.user,
totalCount: 0,
totalAwarded: 0
},
Expand All @@ -61,7 +73,7 @@ const update: component_.page.Update<State, InnerMsg, Route> = ({
const response = msg.value;
if (api.isValid(response)) {
return [
immutable(response.value[0]),
state.merge(response.value[0]),
[component_.cmd.dispatch(component_.page.readyMsg())]
];
} else {
Expand Down Expand Up @@ -152,7 +164,10 @@ const Stat: component_.base.View<{
);
};

const Programs: component_.base.View = () => {
const Programs: component_.page.View<State, InnerMsg, Route> = ({ state }) => {
const userIsGov = isPublicSectorEmployee(
state.viewerUser ?? { type: UserType.Vendor }
);
return (
<div className="bg-c-landing-programs-bg py-7">
<Container>
Expand Down Expand Up @@ -180,6 +195,10 @@ const Programs: component_.base.View = () => {
symbol_: rightPlacement(iconLinkSymbol("arrow-right"))
}
]}
costRecoveryDetails={{
show: userIsGov,
amount: CWU_COST_RECOVERY_FIGURE
}}
/>
<ProgramCard
img={prefixPath("/images/illustrations/team_with_us.svg")}
Expand All @@ -203,10 +222,15 @@ const Programs: component_.base.View = () => {
symbol_: rightPlacement(iconLinkSymbol("arrow-right"))
}
]}
costRecoveryDetails={{
show: userIsGov,
amount: TWU_COST_RECOVERY_FIGURE
}}
/>
<ProgramCard
img={prefixPath("/images/illustrations/sprint_with_us.svg")}
title="Sprint With Us"
className="mb-4 mb-md-0"
description={
<div>
<div>
Expand All @@ -228,6 +252,10 @@ const Programs: component_.base.View = () => {
symbol_: rightPlacement(iconLinkSymbol("arrow-right"))
}
]}
costRecoveryDetails={{
show: userIsGov,
amount: SWU_COST_RECOVERY_FIGURE
}}
/>
</Row>
</Container>
Expand Down Expand Up @@ -465,7 +493,7 @@ const view: component_.page.View<State, InnerMsg, Route> = (props) => {
<div>
<Hero {...props} />
<Stats {...props} />
<Programs />
<Programs {...props} />
<AppInfo />
<VendorRoleInfo />
<GovRoleInfo />
Expand Down
9 changes: 9 additions & 0 deletions src/front-end/typescript/lib/pages/opportunity/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import * as swu from "shared/lib/resources/opportunity/sprint-with-us";
import { UserType } from "shared/lib/resources/user";
import { adt, ADT } from "shared/lib/types";
import { GUIDE_AUDIENCE } from "front-end/lib/pages/guide/view";
import {
CWU_COST_RECOVERY_FIGURE,
TWU_COST_RECOVERY_FIGURE,
SWU_COST_RECOVERY_FIGURE
} from "front-end/config";

export interface State {
empty: true;
Expand Down Expand Up @@ -100,6 +105,7 @@ const view: component_.page.View<State, InnerMsg, Route> = () => {
color: "primary" as TextColor
}
]}
costRecoveryDetails={{ show: true, amount: CWU_COST_RECOVERY_FIGURE }}
/>
<ProgramCard
img={prefixPath("/images/illustrations/team_with_us.svg")}
Expand Down Expand Up @@ -132,10 +138,12 @@ const view: component_.page.View<State, InnerMsg, Route> = () => {
color: "primary" as TextColor
}
]}
costRecoveryDetails={{ show: true, amount: TWU_COST_RECOVERY_FIGURE }}
/>
<ProgramCard
img={prefixPath("/images/illustrations/sprint_with_us.svg")}
title="Sprint With Us"
className="mb-4 mb-md-0"
description={
<span>
Use a <em>Sprint With Us</em> opportunity to procure an Agile
Expand Down Expand Up @@ -163,6 +171,7 @@ const view: component_.page.View<State, InnerMsg, Route> = () => {
color: "primary" as TextColor
}
]}
costRecoveryDetails={{ show: true, amount: SWU_COST_RECOVERY_FIGURE }}
/>
</Row>
</div>
Expand Down
23 changes: 22 additions & 1 deletion src/front-end/typescript/lib/views/program-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { component } from "front-end/lib/framework";
import Link, { ButtonProps } from "front-end/lib/views/link";
import React from "react";
import { Col } from "reactstrap";
import { formatAmount } from "shared/lib";

export interface Props {
img: string;
Expand All @@ -10,6 +11,10 @@ export interface Props {
className?: string;
links: ButtonProps[];
wideLinks?: boolean;
costRecoveryDetails: {
amount: number;
show: boolean;
};
}

/**
Expand All @@ -24,7 +29,8 @@ const ProgramCard: component.base.View<Props> = ({
description,
links,
wideLinks,
className
className,
costRecoveryDetails
}) => {
return (
<Col xs="12" md="4" className={className}>
Expand All @@ -41,6 +47,21 @@ const ProgramCard: component.base.View<Props> = ({
className={`mt-auto d-flex flex-column ${
wideLinks ? "align-self-stretch" : ""
} `}>
{costRecoveryDetails.show ? (
<div className="mx-auto mb-3">
Price:{" "}
<b className="font-size-large">
{formatAmount(costRecoveryDetails.amount, "$")} CAD
</b>
<br />
via Cost Recovery
<div>
<Link className="font-size-small no-wrap">
See Service Level Agreement for details
</Link>
</div>
</div>
) : null}
{links.map((link, index) => (
<Link
{...link}
Expand Down

0 comments on commit 9a2120d

Please sign in to comment.