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

MNTOR-1809 - Add chart into dashboard top banner #3232

Merged
merged 28 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2a6ae97
MNTOR-1809 - Add chart into dashboard top banner
codemist Jul 19, 2023
ee4c446
clean up flex values
codemist Jul 19, 2023
2115741
add about exposure num modal
codemist Jul 19, 2023
9cd205f
first pass
mansaj Jul 22, 2023
876bd1d
add summary metrics for dashboard
mansaj Jul 23, 2023
7c63c22
add types
mansaj Jul 24, 2023
2330cc5
todo comment
mansaj Jul 24, 2023
f6fadea
review comment
mansaj Jul 24, 2023
e8c6ca5
review comment
mansaj Jul 24, 2023
b1438b5
map for localized key
mansaj Jul 24, 2023
a90adc4
inject chart data into chart component
codemist Jul 25, 2023
4efb33c
use variable for num email addresses
codemist Jul 25, 2023
3b27dcc
fix storybook for dashboard
codemist Jul 25, 2023
30862d5
switch between pre-scan and post-scan views
codemist Jul 25, 2023
1d593d6
fix breaking test
codemist Jul 25, 2023
1215501
rm unused vars
codemist Jul 25, 2023
919f46b
fix l10n lint error and alphatetically organize vars
codemist Jul 25, 2023
014e567
add correct data in dashboard top banner desc
codemist Jul 25, 2023
f8afc68
rm console log
codemist Jul 25, 2023
04dd956
lint
codemist Jul 25, 2023
f7aac09
lint
codemist Jul 25, 2023
d7844bd
pluralize string
codemist Jul 25, 2023
58d16f5
fix stories
codemist Jul 25, 2023
d614a31
add total nums (#3252)
mansaj Jul 25, 2023
c7c4355
add special character for ×
codemist Jul 25, 2023
2dce8fc
arrange colours of chart by odd first, then even
codemist Jul 25, 2023
ebfcd2c
remove unused var
codemist Jul 26, 2023
e8704b5
Merge branch 'main' into mntor-1809-scan-banner
codemist Jul 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Shell } from "../../../Shell";
import { StateAbbr } from "../../../../../../utils/states";
import { getEnL10nSync } from "../../../../../functions/server/mockL10n";
import { createRandomScan } from "../../../../../../apiMocks/mockData";
import { DashboardSummary } from "../../../../../functions/server/dashboard";

const meta: Meta<typeof DashboardEl> = {
title: "Pages/Dashboard",
Expand All @@ -19,33 +20,6 @@ const meta: Meta<typeof DashboardEl> = {
export default meta;
type Story = StoryObj<typeof DashboardEl>;

const _ScanResultMockItem: ScanResult = {
id: 1,
profile_id: 1,
first_name: "John",
last_name: "Doe",
middle_name: "string",
age: `${30}`,
addresses: [
{
city: "123",
state: "State" as StateAbbr,
street: "Street",
zip: "123456",
},
],
phones: [""],
emails: [""],
data_broker: "Familytree.com",
created_at: "11/09/23",
updated_at: "11/09/23",
url: "",
link: "",
relatives: [],
status: "new",
data_broker_id: 0,
};

const BreachMockItem1: HibpLikeDbBreach = {
AddedDate: new Date("2018-11-07T14:48:00.000Z"),
BreachDate: "11/09/23",
Expand Down Expand Up @@ -138,13 +112,31 @@ const breachItemArraySample: HibpLikeDbBreach[] = [
BreachMockItem4,
];

const dashboardSummary: Record<string, number>[] = [
{ "physical-addresses": 90 },
{ "family-members-names": 29 },
{ "full-names": 98 },
{ "phone-numbers": 8 },
{ "other-data-class": 80 },
];
const dashboardSummary: DashboardSummary = {
dataBreachTotalNum: 0,
dataBrokerTotalNum: 0,
totalExposures: 0,
allExposures: {
emailAddresses: 0,
phoneNumbers: 0,
addresses: 0,
familyMembers: 0,
fullNames: 0,
socialSecurityNumbers: 0,
ipAddresses: 0,
passwords: 0,
creditCardNumbers: 0,
pinNumbers: 0,
securityQuestions: 0,
},
sanitizedExposures: [
{ "physical-addresses": 90 },
{ "family-members-names": 29 },
{ "full-names": 98 },
{ "phone-numbers": 8 },
{ "other-data-class": 80 },
],
};

export const DashboardWithScan: Story = {
render: () => (
Expand Down Expand Up @@ -173,7 +165,7 @@ export const DashboardWithScan: Story = {
}}
userScannedResults={scannedResultsArraySample}
locale={"en"}
chartData={dashboardSummary}
bannerData={dashboardSummary}
/>
</Shell>
),
Expand Down Expand Up @@ -206,7 +198,7 @@ export const DashboardWithoutScan: Story = {
}}
userScannedResults={[]}
locale={"en"}
chartData={dashboardSummary}
bannerData={dashboardSummary}
/>
</Shell>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { ReactElement } from "react";
import { Button } from "../../../../../components/server/Button";
import { useL10n } from "../../../../../hooks/l10n";
import { DoughnutChart as Chart } from "../../../../../components/client/Chart";
import {
DashboardSummary,
dashboardSummary,
} from "../../../../../functions/server/dashboard";

export type DashboardTopBannerProps = {
type:
Expand All @@ -15,33 +19,34 @@ export type DashboardTopBannerProps = {
| "NoExposuresFoundContent"
| "ResumeBreachResolutionContent"
| "YourDataIsProtectedContent";
chart: ReactElement;
chartData: Record<string, number>[];
bannerData: DashboardSummary;
};

export const DashboardTopBanner = (props: DashboardTopBannerProps) => {
const l10n = useL10n();

const chartData: [string, number][] = props.chartData.map((obj) => {
const [key, value] = Object.entries(obj)[0];
return [l10n.getString(key), value];
});
const chartData: [string, number][] = props.bannerData.sanitizedExposures.map(
(obj) => {
const [key, value] = Object.entries(obj)[0];
return [l10n.getString(key), value];
}
);

const contentData = {
LetsFixDataContent: {
headline: l10n.getString("dashboard-top-banner-protect-your-data-title"),
description: l10n.getString(
"dashboard-top-banner-protect-your-data-description",
{
// TODO: Replace all mocked exposure data
data_breach_total_num: 95,
data_broker_total_num: 15,
data_breach_total_num: props.bannerData.dataBreachTotalNum,
data_broker_total_num: props.bannerData.dataBrokerTotalNum,
mansaj marked this conversation as resolved.
Show resolved Hide resolved
}
),
cta: {
content: l10n.getString("dashboard-top-banner-protect-your-data-cta"),
onClick: () => {
window.location.href = "/redesign/user/dashboard/fix/data-broker-profiles/view-data-brokers";
window.location.href =
"/redesign/user/dashboard/fix/data-broker-profiles/view-data-brokers";
},
},
},
Expand Down Expand Up @@ -86,6 +91,7 @@ export const DashboardTopBanner = (props: DashboardTopBannerProps) => {
description: l10n.getString(
"dashboard-top-banner-lets-keep-protecting-description",
{
//TODO: Add remaining total exposures
remaining_exposures_total_num: 40,
}
),
Expand All @@ -105,6 +111,7 @@ export const DashboardTopBanner = (props: DashboardTopBannerProps) => {
description: l10n.getString(
"dashboard-top-banner-your-data-is-protected-description",
{
//TODO: Add original count of exposures
starting_exposure_total_num: 100,
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import { useState } from "react";
import { ScanResult } from "../../../../../functions/server/onerep";
import { HibpLikeDbBreach } from "../../../../../../utils/hibp";
import { BundledVerifiedEmails } from "../../../../../../utils/breaches";
import { DashboardSummary } from "../../../../../functions/server/dashboard";

export type Props = {
user: Session["user"];
userBreaches: UserBreaches;
isUserScannedResults: boolean;
userScannedResults: ScanResult[];
chartData: Record<string, number>[];
bannerData: DashboardSummary;
locale: string;
};

Expand Down Expand Up @@ -209,6 +209,8 @@ export const View = (props: Props) => {
}
);

console.log([props.bannerData]);

const isScanResultItemsEmpty = props.userScannedResults.length === 0;

return (
Expand All @@ -221,13 +223,12 @@ export const View = (props: Props) => {
</Toolbar>
<div className={styles.dashboardContent}>
<DashboardTopBanner
chartData={props.chartData}
bannerData={props.bannerData}
type={
isScanResultItemsEmpty
? "DataBrokerScanUpsellContent"
: "LetsFixDataContent"
}
chart={<></>}
/>
<section className={styles.exposuresArea}>
<h2 className={styles.exposuresAreaHeadline}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default async function DashboardPage() {
userScannedResults={scanResultItems}
userBreaches={breaches}
locale={locale}
chartData={summary.sanitizedExposures}
bannerData={summary}
/>
);
}