Skip to content

Commit

Permalink
fixed something
Browse files Browse the repository at this point in the history
  • Loading branch information
hashmib committed Oct 6, 2020
1 parent db97725 commit ed1ee91
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
17 changes: 3 additions & 14 deletions paysa-planner/src/components/dashboard/UpcomingTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import Divider from '@material-ui/core/Divider';
import Typography from '@material-ui/core/Typography';
import axios from 'axios';
import Transaction from './Transaction';
import { formatDate } from '../utils';
import { numberWithCommas } from '../utils';



const useStyles = makeStyles((theme) => ({
Expand All @@ -12,9 +15,6 @@ const useStyles = makeStyles((theme) => ({
}
}));

const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];

export default function UpcomingTransactions() {
const classes = useStyles();
const [transactions, setTransactions] = useState([]);
Expand All @@ -23,17 +23,6 @@ export default function UpcomingTransactions() {
axios.get('/upcomingtransactions', {params: {sortBy: '30days'}})
.then((response) => {setTransactions(response.data)})
}

function formatDate(date_string) {
var d = new Date(date_string)
let formattedDate = monthNames[d.getMonth()] + " " + d.getDate();

return formattedDate;
}

function numberWithCommas(x) {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}

useEffect(() => {
getTransactions()
Expand Down
15 changes: 15 additions & 0 deletions paysa-planner/src/components/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Helper Function Library for UI */

export function formatDate(date_string) {
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];

var d = new Date(date_string)
let formattedDate = monthNames[d.getMonth()] + " " + d.getDate();

return formattedDate;
}

export function numberWithCommas(x) {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}

0 comments on commit ed1ee91

Please sign in to comment.