Skip to content

Commit

Permalink
scoring setup
Browse files Browse the repository at this point in the history
  • Loading branch information
daxaxelrod committed Oct 29, 2023
1 parent 09c4595 commit 2f8f3ba
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 13 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/components/users/PublicProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function PublicProfile({}) {
<Col span={8}>
<UserHeader user={user} />
</Col>
<Col span={8}>
<Col span={11}>
<UserOpenInsureRating user={user} />
</Col>
</Row>
Expand Down
18 changes: 14 additions & 4 deletions frontend/src/app/components/users/profile/UserHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@ const { Title, Paragraph } = Typography;
export default function UserHeader({ user }: { user: User }) {
return (
<div>
<Title>
<Title style={{ marginBottom: ".25rem" }}>
{user?.first_name} {user?.last_name}
</Title>
<Flex gap={10}>
{user?.linkedin_url && <LinkedinOutlined />}
{user?.twitter_url && <TwitterOutlined />}
<Flex
gap={10}
style={{
backgroundColor: colors.gray1,
marginBottom: ".25rem",
}}
>
{user?.linkedin_url && (
<LinkedinOutlined style={{ color: colors.linkColor }} />
)}
{user?.twitter_url && (
<TwitterOutlined style={{ color: colors.linkColor }} />
)}
</Flex>
<Paragraph
style={{
Expand Down
69 changes: 61 additions & 8 deletions frontend/src/app/components/users/profile/UserOpenInsureRating.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,82 @@
import React from "react";
import React, { useMemo } from "react";
import { Col, Flex, Progress, Row } from "antd";
import { User } from "../../../../redux/reducers/types/commonTypes";
import colors from "../../../constants/colors";
import { Typography } from "antd";
import { ReloadOutlined } from "@ant-design/icons";

const { Title } = Typography;
const { Title, Paragraph } = Typography;

export default function UserOpenInsureRating({ user }: { user: User }) {
const trustworthinessScore = 99;
const { trustworthiness } = user;

const hasScore = !!trustworthiness?.total_score;

const scoreLeaderText = useMemo(() => {
if (trustworthiness?.total_score) {
if (trustworthiness?.total_score >= 80) {
return "Excellent";
} else if (trustworthiness?.total_score >= 60) {
return "Good";
} else if (trustworthiness?.total_score >= 40) {
return "Fair";
} else if (trustworthiness?.total_score >= 20) {
return "Poor";
} else {
return "Very Poor";
}
}
return "No score yet";
}, [trustworthiness?.total_score]);

return (
<>
<Flex>
<div
style={{
position: "absolute",
top: 0,
right: 0,
zIndex: 1,
display: "flex",
}}
>
<ReloadOutlined
style={{ marginRight: 4, color: colors.gray7 }}
/>
<Paragraph style={{ marginBottom: 0 }}>Refresh</Paragraph>
</div>
<Progress
type="dashboard"
percent={99}
percent={trustworthiness?.total_score || 0}
strokeColor={{
"0%": colors.good,
"100%": colors.lightGood,
}}
format={(percent) => (
<div>
{percent}
<div
style={{
color: colors.gray8,
fontSize: 12,
marginTop: 4,
}}
>
Score
</div>
</div>
)}
/>
</Flex>
<Flex>
<Col>
<Title level={4}>trustworthy score</Title>
<Col sm={{ offset: 2 }}>
<Title level={4}>{scoreLeaderText}</Title>
{hasScore ? (
<Paragraph style={{ color: colors.gray8 }}></Paragraph>
) : (
<Paragraph style={{ color: colors.gray8 }}>
Seems like you dont have a score yet
</Paragraph>
)}
</Col>
</Flex>
</>
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/redux/reducers/types/commonTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
export interface TrustworthinessDetails {
calculated_on: string;
next_refresh_available: string;
total_score: number;
components: {
payments: number;
claims: number;
background: number;
activity: number;
lifestyle: number;
};
}

export interface User {
id: number;
first_name: string;
Expand All @@ -10,6 +23,7 @@ export interface User {

linkedin_url?: string;
twitter_url?: string;
trustworthiness?: TrustworthinessDetails;
}

export interface Premium {
Expand Down
2 changes: 2 additions & 0 deletions pods/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class Meta:
"updated_at",
"verified_email",
"pods",
"linkedin_url",
"twitter_url",
]


Expand Down

0 comments on commit 2f8f3ba

Please sign in to comment.