Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
View and modify notification filters (fixes #420)
Browse files Browse the repository at this point in the history
  • Loading branch information
Crecket committed Dec 18, 2018
1 parent 001a4e8 commit 78909a1
Show file tree
Hide file tree
Showing 5 changed files with 393 additions and 98 deletions.
2 changes: 1 addition & 1 deletion config/Webpack/plugins.js
@@ -1,7 +1,7 @@
const webpack = require("webpack");
const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

const packageInfo = require("../../package.json");
Expand Down
6 changes: 6 additions & 0 deletions src/react/Locales/en.json
Expand Up @@ -78,6 +78,7 @@
"Cards update sent": "Cards update sent",
"Categories": "Categories",
"Categories that will be added": "Categories that will be added",
"Category": "Category",
"Category Editor": "Category Editor",
"Category count": "Category count",
"Category count history": "Category count history",
Expand Down Expand Up @@ -155,6 +156,7 @@
"Delete": "Delete",
"Delivered to customer": "Delivered to customer",
"Delivered virtually": "Delivered virtually",
"Delivery method": "Delivery method",
"Description": "Description",
"Device Name": "Device Name",
"Disabled": "Disabled",
Expand Down Expand Up @@ -288,6 +290,7 @@
"Maximum allowed length is": "Maximum allowed length is",
"Maximum events per type": "Maximum events per type",
"Merchant reference": "Merchant reference",
"Method": "Method",
"Minimize to tray": "Minimize to tray",
"Minimum required length is": "Minimum required length is",
"Minute": "Minute",
Expand Down Expand Up @@ -320,6 +323,7 @@
"No stored keys found": "No stored keys found",
"None": "None",
"Not Found": "Not Found",
"Notification filters": "Notification filters",
"Number of payments": "Number of payments",
"Number of requests": "Number of requests",
"OAuth": "OAuth",
Expand Down Expand Up @@ -372,6 +376,7 @@
"Production key": "Production key",
"Profile": "Profile",
"Public nick name": "Public nick name",
"Push notifications": "Push notifications",
"Queue is empty": "Queue is empty",
"Reason": "Reason",
"Received": "Received",
Expand Down Expand Up @@ -531,6 +536,7 @@
"Use account balances": "Use account balances",
"Use no password": "Use no password",
"Use the native frame": "Use the native frame",
"Value": "Value",
"Value rule with": "Value rule with",
"Version": "Version",
"View CVC Codes": "View CVC Codes",
Expand Down
100 changes: 100 additions & 0 deletions src/react/Pages/Profile/BusinessInfo.jsx
@@ -0,0 +1,100 @@
import React from "react";
import Grid from "@material-ui/core/Grid";
import Paper from "@material-ui/core/Paper";
import Table from "@material-ui/core/Table";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow";
import TextField from "@material-ui/core/TextField";

import { formatMoney } from "../../Functions/Utils";

import TranslateTypography from "../../Components/TranslationHelpers/Typography";

const styles = {
paper: {
padding: 16,
marginTop: 16
}
};

const BusinessInfo = ({ t, userType, totalBalance, ...props }) => {
if (userType !== "UserCompany") return null;

const safeKeepingValue = totalBalance - 100000;
const hasSafeKeepingFee = safeKeepingValue > 0;

let costsTable = null;
if (hasSafeKeepingFee) {
costsTable = (
<Table>
<TableHead>
<TableRow>
<TableCell>{t("Days")}</TableCell>
<TableCell numeric>{t("Estimated total cost")}</TableCell>
<TableCell numeric>{t("Balance after payments")}</TableCell>
</TableRow>
</TableHead>
<TableBody>
{[1, 7, 30, 90, 365].map(days => {
// to keep track of the amount across the dates
let accountBalance = safeKeepingValue;
let totalPayment = 0;

// go through the days to calculate historic change
for (let day = 0; day < days; day++) {
const thousands = accountBalance / 1000;
let nextPayment = (thousands * 2.4) / 100;

// update balance
accountBalance = accountBalance - nextPayment;
totalPayment = totalPayment + nextPayment;
}

return (
<TableRow key={`days${days}`}>
<TableCell component="th" scope="row">
{days}
</TableCell>
<TableCell numeric>{formatMoney(totalPayment)}</TableCell>
<TableCell numeric>{formatMoney(accountBalance)}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
);
}

return (
<Paper style={styles.paper}>
<Grid container spacing={16} justify="center">
<Grid item xs={12}>
<TranslateTypography variant="subtitle1">Safekeeping fee calculator</TranslateTypography>
</Grid>

<Grid item xs={12}>
<TextField
min={0}
step={0.01}
type="number"
label="Total account balance"
value={parseFloat(totalBalance ? totalBalance : 0).toFixed(2)}
onChange={props.onChange("totalBalance")}
/>
</Grid>

<Grid item xs={12}>
{hasSafeKeepingFee ? (
costsTable
) : (
<TranslateTypography variant="subtitle1">No safekeeping fee</TranslateTypography>
)}
</Grid>
</Grid>
</Paper>
);
};

export default BusinessInfo;

1 comment on commit 78909a1

@hendrer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Crecket thanks for implementing this so quickly! I tried out your nightly build and it works perfectly! I have my notifications coming into my Azure app, sweet!!

Please sign in to comment.