├── public
├── favicon.ico
├── logo192.png
├── logo512.png
├── robots.txt
├── manifest.json
└── index.html
├── postcss.config.js
├── src
├── utils
│ ├── context.js
│ └── redux
│ │ ├── actions
│ │ └── action.js
│ │ ├── store
│ │ └── store.js
│ │ └── reducers
│ │ └── reducer.js
├── index.js
├── components
│ ├── Layout.jsx
│ ├── CustomButton.jsx
│ ├── CustomInput.jsx
│ └── Header.jsx
├── styles
│ └── index.css
├── pages
│ ├── Profile.jsx
│ ├── auth
│ │ ├── Register.jsx
│ │ └── Login.jsx
│ └── index.jsx
└── routes
│ └── index.jsx
├── tailwind.config.js
├── .gitignore
├── package.json
└── README.md
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devanada/financial-planner/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devanada/financial-planner/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devanada/financial-planner/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/src/utils/context.js:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | export const ThemeContext = createContext("");
4 |
--------------------------------------------------------------------------------
/src/utils/redux/actions/action.js:
--------------------------------------------------------------------------------
1 | export function reduxAction(type, payload) {
2 | return { type, payload };
3 | }
4 |
--------------------------------------------------------------------------------
/src/utils/redux/store/store.js:
--------------------------------------------------------------------------------
1 | import { legacy_createStore as createStore } from "redux";
2 | import { reducer } from "../reducers/reducer";
3 |
4 | export const store = createStore(reducer);
5 |
--------------------------------------------------------------------------------
/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | module.exports = {
3 | darkMode: "class",
4 | content: ["./src/**/*.{js,jsx,ts,tsx}"],
5 | theme: {
6 | extend: {},
7 | },
8 | plugins: [],
9 | };
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom/client";
3 | import { Provider } from "react-redux";
4 | import { store } from "./utils/redux/store/store";
5 | import Routes from "./routes";
6 | import "./styles/index.css";
7 |
8 | const root = ReactDOM.createRoot(document.getElementById("root"));
9 | root.render(
10 |
11 |
12 |
13 | );
14 |
--------------------------------------------------------------------------------
/src/utils/redux/reducers/reducer.js:
--------------------------------------------------------------------------------
1 | const initialState = {
2 | isLoggedIn: false,
3 | user: {},
4 | };
5 |
6 | export const reducer = (state = initialState, action) => {
7 | switch (action.type) {
8 | case "IS_LOGGED_IN":
9 | return {
10 | ...state,
11 | isLoggedIn: action.payload.isLoggedIn,
12 | user: action.payload.user,
13 | };
14 | default:
15 | return state;
16 | }
17 | };
18 |
--------------------------------------------------------------------------------
/src/components/Layout.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import Header from "./Header";
4 |
5 | function Layout(props) {
6 | return (
7 |
8 |
9 |
10 | {props.children}
11 |
12 |
13 | );
14 | }
15 |
16 | export default Layout;
17 |
--------------------------------------------------------------------------------
/src/components/CustomButton.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | function CustomButton({ id, label, loading, onClick }) {
4 | return (
5 |
13 | {label}
14 |
15 | );
16 | }
17 |
18 | export default CustomButton;
19 |
--------------------------------------------------------------------------------
/src/styles/index.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | body {
6 | margin: 0;
7 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
8 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
9 | sans-serif;
10 | -webkit-font-smoothing: antialiased;
11 | -moz-osx-font-smoothing: grayscale;
12 | }
13 |
14 | code {
15 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
16 | monospace;
17 | }
18 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/src/components/CustomInput.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | function CustomInput({ id, type, placeholder, value, onChange, disabled }) {
4 | if (type === "select") {
5 | return (
6 |
14 |
15 | Type
16 |
17 | Income
18 | Expense
19 |
20 | );
21 | } else {
22 | return (
23 |
33 | );
34 | }
35 | }
36 |
37 | export default CustomInput;
38 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "financial-planner",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@mantine/core": "^4.2.12",
7 | "@mantine/form": "^4.2.12",
8 | "@mantine/hooks": "^4.2.12",
9 | "@mantine/notifications": "^4.2.12",
10 | "@testing-library/jest-dom": "^5.16.4",
11 | "@testing-library/react": "^13.3.0",
12 | "@testing-library/user-event": "^13.5.0",
13 | "axios": "^0.27.2",
14 | "dayjs": "^1.11.4",
15 | "react": "^18.2.0",
16 | "react-dom": "^18.2.0",
17 | "react-icons": "^4.4.0",
18 | "react-redux": "^8.0.2",
19 | "react-router-dom": "^6.3.0",
20 | "react-scripts": "5.0.1",
21 | "redux": "^4.2.0",
22 | "web-vitals": "^2.1.4"
23 | },
24 | "scripts": {
25 | "start": "react-scripts start",
26 | "build": "react-scripts build",
27 | "test": "react-scripts test",
28 | "eject": "react-scripts eject"
29 | },
30 | "eslintConfig": {
31 | "extends": [
32 | "react-app",
33 | "react-app/jest"
34 | ]
35 | },
36 | "browserslist": {
37 | "production": [
38 | ">0.2%",
39 | "not dead",
40 | "not op_mini all"
41 | ],
42 | "development": [
43 | "last 1 chrome version",
44 | "last 1 firefox version",
45 | "last 1 safari version"
46 | ]
47 | },
48 | "devDependencies": {
49 | "autoprefixer": "^10.4.7",
50 | "postcss": "^8.4.14",
51 | "tailwindcss": "^3.1.6"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 | You need to enable JavaScript to run this app.
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/components/Header.jsx:
--------------------------------------------------------------------------------
1 | import { showNotification } from "@mantine/notifications";
2 | import { useDispatch, useSelector } from "react-redux";
3 | import { Link, useNavigate } from "react-router-dom";
4 | import { FaSun, FaMoon } from "react-icons/fa";
5 | import { Menu, Divider } from "@mantine/core";
6 | import { useContext } from "react";
7 |
8 | import { reduxAction } from "../utils/redux/actions/action";
9 | import { ThemeContext } from "../utils/context";
10 |
11 | const Header = () => {
12 | const isLoggedIn = useSelector((state) => state.isLoggedIn);
13 | const navigate = useNavigate();
14 | const dispatch = useDispatch();
15 | const { theme, setTheme } = useContext(ThemeContext);
16 |
17 | const handleTheme = (mode) => {
18 | setTheme(mode);
19 | localStorage.setItem("theme", mode);
20 | };
21 |
22 | const handleLogout = async () => {
23 | localStorage.removeItem("UserData");
24 | localStorage.removeItem("auth");
25 | dispatch(reduxAction("IS_LOGGED_IN", { isLoggedIn: false, user: {} }));
26 | navigate("/login");
27 | showNotification({
28 | title: "Logout Successful",
29 | message: "You have been logged out",
30 | color: "green",
31 | autoClose: 3000,
32 | });
33 | };
34 |
35 | return (
36 |
37 |
42 | Financial Planner
43 |
44 |
45 | {isLoggedIn && (
46 | navigate("/profile")}>
47 | Profile
48 |
49 | )}
50 | handleTheme(theme === "dark" ? "light" : "dark")}
53 | rightSection={theme === "dark" ? : }
54 | >
55 | {theme.charAt(0).toUpperCase() + theme.slice(1)}
56 |
57 |
58 | {isLoggedIn && (
59 | <>
60 |
61 |
62 | handleLogout()}
66 | >
67 | Logout
68 |
69 | >
70 | )}
71 |
72 |
73 | );
74 | };
75 |
76 | export default Header;
77 |
--------------------------------------------------------------------------------
/src/pages/Profile.jsx:
--------------------------------------------------------------------------------
1 | import { showNotification } from "@mantine/notifications";
2 | import { useSelector } from "react-redux";
3 | import React, { useState } from "react";
4 | import axios from "axios";
5 |
6 | import Layout from "../components/Layout";
7 | import CustomInput from "../components/CustomInput";
8 | import CustomButton from "../components/CustomButton";
9 |
10 | export default function Profile() {
11 | const user = useSelector((state) => state.user);
12 | const [objSubmit, setObjSubmit] = useState({});
13 | const [email, setEmail] = useState(user.email);
14 | const [nama, setNama] = useState(user.nama);
15 | const [loading, setLoading] = useState(false);
16 |
17 | const handleSubmit = async (e) => {
18 | e.preventDefault();
19 | setLoading(true);
20 | await axios
21 | .put(`users/${user.ID}`)
22 | .then((res) => {
23 | const { message, data } = res.data;
24 | localStorage.setItem("UserData", JSON.stringify(data));
25 | showNotification({
26 | title: "Update Successful",
27 | message: message,
28 | color: "green",
29 | autoClose: 3000,
30 | });
31 | })
32 | .catch((err) => {
33 | const { message } = err;
34 | showNotification({
35 | title: "Update Failed",
36 | message: message,
37 | color: "red",
38 | autoClose: 3000,
39 | });
40 | })
41 | .finally(() => setLoading(false));
42 | };
43 |
44 | const handleChange = (value, key) => {
45 | let temp = { ...objSubmit };
46 | temp[key] = value;
47 | setObjSubmit(temp);
48 | };
49 |
50 | return (
51 |
52 |
53 |
79 |
80 |
81 | );
82 | }
83 |
--------------------------------------------------------------------------------
/src/routes/index.jsx:
--------------------------------------------------------------------------------
1 | /* eslint-disable react-hooks/exhaustive-deps */
2 | import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
3 | import { NotificationsProvider } from "@mantine/notifications";
4 | import { useSelector, useDispatch } from "react-redux";
5 | import { useState, useEffect, useMemo } from "react";
6 | import axios from "axios";
7 |
8 | import { reduxAction } from "../utils/redux/actions/action";
9 | import { ThemeContext } from "../utils/context";
10 | import Home from "../pages/";
11 | import Profile from "../pages/Profile";
12 | import Login from "../pages/auth/Login";
13 | import Register from "../pages/auth/Register";
14 |
15 | axios.defaults.baseURL = "https://immense-spire-81553.herokuapp.com/";
16 |
17 | export default function App() {
18 | const isLoggedIn = useSelector((state) => state.isLoggedIn);
19 | const dispatch = useDispatch();
20 | const [theme, setTheme] = useState(localStorage.getItem("theme") || "light");
21 | const background = useMemo(() => ({ theme, setTheme }), [theme]);
22 |
23 | useEffect(() => {
24 | if (theme === "dark") {
25 | document.documentElement.classList.add("dark");
26 | } else {
27 | document.documentElement.classList.remove("dark");
28 | }
29 | }, [theme]);
30 |
31 | useEffect(() => {
32 | const getData = localStorage.getItem("UserData");
33 | if (getData) {
34 | const getAuth = JSON.parse(localStorage.getItem("auth"));
35 | const parseData = JSON.parse(getData);
36 | axios.defaults.auth = {
37 | username: getAuth.email,
38 | password: getAuth.password,
39 | };
40 | dispatch(
41 | reduxAction("IS_LOGGED_IN", { isLoggedIn: true, user: parseData })
42 | );
43 | } else {
44 | axios.defaults.auth = {
45 | username: "",
46 | password: "",
47 | };
48 | dispatch(reduxAction("IS_LOGGED_IN", { isLoggedIn: false, user: {} }));
49 | }
50 | }, [isLoggedIn]);
51 |
52 | return (
53 |
54 |
55 |
56 |
57 | : }
60 | />
61 | : }
64 | />
65 | : }
68 | />
69 | : }
72 | />
73 |
74 |
75 |
76 |
77 | );
78 | }
79 |
--------------------------------------------------------------------------------
/src/pages/auth/Register.jsx:
--------------------------------------------------------------------------------
1 | import { showNotification } from "@mantine/notifications";
2 | import React, { useState, useEffect } from "react";
3 | import { useNavigate, Link } from "react-router-dom";
4 | import axios from "axios";
5 |
6 | import Layout from "../../components/Layout";
7 | import CustomInput from "../../components/CustomInput";
8 | import CustomButton from "../../components/CustomButton";
9 |
10 | export default function Register() {
11 | const navigate = useNavigate();
12 | const [email, setEmail] = useState("");
13 | const [password, setPassword] = useState("");
14 | const [nama, setNama] = useState("");
15 | const [loading, setLoading] = useState(false);
16 | const [disabled, setDisabled] = useState(true);
17 |
18 | useEffect(() => {
19 | document.title = "Financial Planner - Register";
20 | if (email && password && nama) {
21 | setDisabled(false);
22 | } else {
23 | setDisabled(true);
24 | }
25 | }, [email, password, nama]);
26 |
27 | const handleSubmit = async (e) => {
28 | setLoading(true);
29 | e.preventDefault();
30 | const body = {
31 | email,
32 | nama,
33 | password,
34 | };
35 | await axios
36 | .post("users", body)
37 | .then((res) => {
38 | const { message, data, status } = res.data;
39 | if (data) {
40 | navigate("/login");
41 | }
42 | showNotification({
43 | title: `Register ${status ? "Successfully" : "Failed"}`,
44 | message: message,
45 | color: "green",
46 | autoClose: 3000,
47 | });
48 | })
49 | .catch((err) => {
50 | const { message } = err;
51 | showNotification({
52 | title: "Register Failed",
53 | message: message,
54 | color: "red",
55 | autoClose: 3000,
56 | });
57 | })
58 | .finally(() => setLoading(false));
59 | };
60 |
61 | return (
62 |
63 |
102 |
103 | );
104 | }
105 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/src/pages/auth/Login.jsx:
--------------------------------------------------------------------------------
1 | import { showNotification } from "@mantine/notifications";
2 | import { useNavigate, Link } from "react-router-dom";
3 | import React, { useState, useEffect } from "react";
4 | import { useDispatch } from "react-redux";
5 | import axios from "axios";
6 |
7 | import { reduxAction } from "../../utils/redux/actions/action";
8 | import Layout from "../../components/Layout";
9 | import CustomInput from "../../components/CustomInput";
10 | import CustomButton from "../../components/CustomButton";
11 |
12 | export default function Login() {
13 | const navigate = useNavigate();
14 | const dispatch = useDispatch();
15 | const [email, setEmail] = useState("");
16 | const [password, setPassword] = useState("");
17 | const [loading, setLoading] = useState(false);
18 | const [disabled, setDisabled] = useState(true);
19 |
20 | useEffect(() => {
21 | document.title = "Financial Planner - Login";
22 | if (email && password) {
23 | setDisabled(false);
24 | } else {
25 | setDisabled(true);
26 | }
27 | }, [email, password]);
28 |
29 | const handleSubmit = async (e) => {
30 | setLoading(true);
31 | e.preventDefault();
32 | const body = {
33 | email,
34 | password,
35 | };
36 | await axios
37 | .post("login", body)
38 | .then((res) => {
39 | const { data } = res;
40 | if (typeof data === "string") {
41 | showNotification({
42 | title: "Login Failed",
43 | message: data,
44 | color: "red",
45 | autoClose: 3000,
46 | });
47 | } else {
48 | localStorage.setItem("UserData", JSON.stringify(data.data));
49 | localStorage.setItem("auth", JSON.stringify(body));
50 | dispatch(
51 | reduxAction("IS_LOGGED_IN", { isLoggedIn: true, user: data })
52 | );
53 | showNotification({
54 | title: "Login Successful",
55 | message: "Hey there! Welcome back to Financial Planner",
56 | color: "green",
57 | autoClose: 3000,
58 | });
59 | navigate("/");
60 | }
61 | })
62 | .catch((err) => {
63 | const { message } = err.response.data;
64 | showNotification({
65 | title: "Login Failed",
66 | message: message,
67 | color: "red",
68 | autoClose: 3000,
69 | });
70 | })
71 | .finally(() => setLoading(false));
72 | };
73 |
74 | return (
75 |
76 |
108 |
109 | );
110 | }
111 |
--------------------------------------------------------------------------------
/src/pages/index.jsx:
--------------------------------------------------------------------------------
1 | import { showNotification } from "@mantine/notifications";
2 | import React, { useState, useEffect } from "react";
3 | import { Loader } from "@mantine/core";
4 | import axios from "axios";
5 |
6 | import Layout from "../components/Layout";
7 | import CustomInput from "../components/CustomInput";
8 | import CustomButton from "../components/CustomButton";
9 |
10 | export default function App() {
11 | const [datas, setDatas] = useState([]);
12 | const [loading, setLoading] = useState(false);
13 | const [disabled, setDisabled] = useState(false);
14 | const [isReady, setIsReady] = useState(false);
15 | const [notes, setNotes] = useState("");
16 | const [amount, setAmount] = useState(0);
17 | const [type, setType] = useState("income");
18 |
19 | useEffect(() => {
20 | if (notes && amount && type) {
21 | setDisabled(false);
22 | } else {
23 | setDisabled(true);
24 | }
25 | }, [notes, amount, type]);
26 |
27 | useEffect(() => {
28 | document.title = "Financial Planner - Home";
29 | fetchData();
30 | }, []);
31 |
32 | const fetchData = async () => {
33 | setIsReady(true);
34 | await axios
35 | .get("balance")
36 | .then((res) => {
37 | const { data } = res.data;
38 | setDatas(data);
39 | })
40 | .catch((err) => {})
41 | .finally(() => setIsReady(false));
42 | };
43 |
44 | const handleSubmit = async (e) => {
45 | setLoading(true);
46 | e.preventDefault();
47 | const endpoint = type === "income" ? "income" : "expense";
48 | const body = {
49 | notes,
50 | amount,
51 | };
52 | await axios
53 | .post(endpoint, body)
54 | .then((res) => {
55 | const { message } = res.data;
56 | showNotification({
57 | title: "Submit Successful",
58 | message: message,
59 | color: "green",
60 | autoClose: 3000,
61 | });
62 | setNotes("");
63 | setAmount(0);
64 | })
65 | .catch((err) => {
66 | const { data } = err.response;
67 | showNotification({
68 | title: "Submit Failed",
69 | message: data,
70 | color: "red",
71 | autoClose: 3000,
72 | });
73 | })
74 | .finally(() => {
75 | setLoading(false);
76 | fetchData();
77 | });
78 | };
79 |
80 | const format = (amount) => {
81 | return Number(amount)
82 | .toFixed(2)
83 | .replace(/\d(?=(\d{3})+\.)/g, "$&,");
84 | };
85 |
86 | return (
87 |
88 |
89 |
90 |
120 |
121 |
122 |
123 | Balance History
124 |
125 | {isReady ? (
126 |
127 | ) : (
128 | datas.map((data) => (
129 |
133 |
{data.notes}
134 |
139 | Rp. {format(data.amount)}
140 |
141 |
142 | ))
143 | )}
144 |
145 |
146 |
147 | );
148 | }
149 |
--------------------------------------------------------------------------------