Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_HOST=gtwfin.alkwr.mongodb.net
DB_USER=GTWFam
DB_PASS=AnotherWebApp101
SESSION_SECRET=verySecretVery
PORT=8080
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.env
.cache/
coverage/
dist/*
!dist/index.html
node_modules/
*.log

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
39 changes: 11 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
Assignment 4 - Components
===
# Assignment 4 - Components

Due: October 4th, by 11:59 AM.
_Due: October 4th, by 11:59 AM._

For this assignment you will re-implement the client side portion of *either* A2 or A3 using either React or Svelte components. If you choose A3 you only need to use components for the data display / updating; you can leave your login UI as is.
## GTWFin - React

[Svelte Tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/using_svelte.md)
[React Tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/using_react.md)
http://a4-gtwfam.glitch.me

This project can be implemented on any hosting service (Glitch, DigitalOcean, Heroku etc.), however, you must include all files in your GitHub repo so that the course staff can view them.
The project is a financial app that helps people to keep track of their money inflow and outflow.
In the app, the user can register, login, add and remove the money entries. The money entries with
negative sign would be colored red and the inflow would be colored green. All the money entries are
grouped by months.

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements.
3. Test your project to make sure that when someone goes to your main page on Glitch/Heroku/etc., it displays correctly.
4. Ensure that your project has the proper naming scheme `a4-firstname-lastname` so we can find it.
5. Fork this repository and modify the README to the specifications below. Be sure to add *all* project files.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a4-firstname-lastname`.

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your hosting link e.g. http://a4-charlieroberts.glitch.me

Include a very brief summary of your project here and what you changed / added to assignment #3. Briefly (3–4 sentences) answer the following question: did the new technology improve or hinder the development experience?

Unlike previous assignments, this assignment will be solely graded on whether or not you successfully complete it. Partial credit will be generously given.
Working with React made the development process much easier (less copy pasting same structure) and creates more freedome for creativity. Due to my workload, I wasn't able to add anything new to the project. I am
planning however to expand the application with D3 to create data visualization of the total inflow, outlfow
and more.
58 changes: 58 additions & 0 deletions build/AddForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from "./_snowpack/pkg/react.js";
import {Container, Form, Row, Button, Col} from "./_snowpack/pkg/react-bootstrap.js";
import {openAddForm} from "./public/editData.js";
class AddForm extends React.Component {
render() {
return /* @__PURE__ */ React.createElement(Container, {
className: "whole-page closed",
id: "addEntryOverlay"
}, /* @__PURE__ */ React.createElement(Row, {
className: "justify-content-md-center align-items-md-center h-100"
}, /* @__PURE__ */ React.createElement(Col, {
sm: 4
}, /* @__PURE__ */ React.createElement(Form, {
autoComplete: "off",
action: "/addEntry",
method: "POST"
}, /* @__PURE__ */ React.createElement(Form.Group, {
controlId: "id"
}, /* @__PURE__ */ React.createElement(Form.Label, null, "User ID"), /* @__PURE__ */ React.createElement(Form.Control, {
readOnly: true,
name: "id"
})), /* @__PURE__ */ React.createElement(Form.Group, {
controlId: "month"
}, /* @__PURE__ */ React.createElement(Form.Label, null, "Which month"), /* @__PURE__ */ React.createElement(Form.Control, {
readOnly: true,
name: "month"
})), /* @__PURE__ */ React.createElement(Form.Group, {
controlId: "from"
}, /* @__PURE__ */ React.createElement(Form.Label, null, "From where"), /* @__PURE__ */ React.createElement(Form.Control, {
name: "from"
})), /* @__PURE__ */ React.createElement(Form.Group, {
controlId: "amount"
}, /* @__PURE__ */ React.createElement(Form.Label, null, "How much"), /* @__PURE__ */ React.createElement(Form.Control, {
name: "amount"
})), /* @__PURE__ */ React.createElement(Form.Group, {
controlId: "category"
}, /* @__PURE__ */ React.createElement(Form.Label, null, "What category"), /* @__PURE__ */ React.createElement(Form.Control, {
name: "category"
})), /* @__PURE__ */ React.createElement(Row, {
className: "justify-content-md-start mt-3"
}, /* @__PURE__ */ React.createElement(Col, {
sm: 5
}, /* @__PURE__ */ React.createElement(Button, {
variant: "primary",
type: "submit"
}, "Add Transaction")), /* @__PURE__ */ React.createElement(Col, {
sm: 5
}, /* @__PURE__ */ React.createElement(Button, {
variant: "link",
href: "#",
onClick: () => {
openAddForm("January");
return false;
}
}, "Close Form")))))));
}
}
export default AddForm;
43 changes: 43 additions & 0 deletions build/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from "./_snowpack/pkg/react.js";
import {Col, Container, Form, Row, Button} from "./_snowpack/pkg/react-bootstrap.js";
import Months from "./Months.js";
import AddForm from "./AddForm.js";
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
username: "",
entries: []
};
this.load();
}
load() {
const queryString = new URLSearchParams(window.location.search);
const userID = queryString.get("userID");
fetch(`/getUserData?id=${userID}`, {method: "get", "no-cors": true}).then((res) => res.json()).then((json) => {
this.setState({
username: json["username"],
entries: json["entries"]
});
});
}
render() {
const {username, entries} = this.state;
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Container, {
className: "mt-5 md-3"
}, /* @__PURE__ */ React.createElement(Row, {
className: "justify-content-md-center text-center"
}, /* @__PURE__ */ React.createElement(Col, null, /* @__PURE__ */ React.createElement("h1", null, "Welcome to GTWFin, ", username)), /* @__PURE__ */ React.createElement(Col, null, /* @__PURE__ */ React.createElement(Form, {
action: "/logout?_method=DELETE",
method: "POST"
}, /* @__PURE__ */ React.createElement(Button, {
variant: "primary",
type: "submit"
}, "Logout")))), /* @__PURE__ */ React.createElement(Row, {
className: "justify-content-md-center text-center"
}, /* @__PURE__ */ React.createElement(Col, null, /* @__PURE__ */ React.createElement(Months, {
entries
})))), /* @__PURE__ */ React.createElement(AddForm, null));
}
}
export default App;
40 changes: 40 additions & 0 deletions build/MonthTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from "./_snowpack/pkg/react.js";
import {Table, Button} from "./_snowpack/pkg/react-bootstrap.js";
import {removeEntry, openAddForm} from "./public/editData.js";
class MonthTab extends React.Component {
render() {
const {month, data} = this.props;
return /* @__PURE__ */ React.createElement(Table, {
bordered: true,
size: "md"
}, /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", {
class: "table-primary align-middle",
height: "40px"
}, /* @__PURE__ */ React.createElement("th", null, "From"), /* @__PURE__ */ React.createElement("th", null, "Amount"), /* @__PURE__ */ React.createElement("th", null, "Category"), /* @__PURE__ */ React.createElement("th", {
width: "50"
}, /* @__PURE__ */ React.createElement(Button, {
type: "button",
onClick: () => openAddForm(month)
}, /* @__PURE__ */ React.createElement("span", {
class: "fas fa-plus-circle fa-lg",
"aria-hiddne": "true"
}))))), /* @__PURE__ */ React.createElement("tbody", null, data.map((entry) => {
let rowColor = "success";
if (entry.amount < 0) {
rowColor = "danger";
}
return /* @__PURE__ */ React.createElement("tr", {
className: `align-middle ${rowColor}`,
height: "40"
}, /* @__PURE__ */ React.createElement("td", null, entry.from), /* @__PURE__ */ React.createElement("td", null, entry.amount, "$"), /* @__PURE__ */ React.createElement("td", null, entry.category), /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement(Button, {
type: "button",
onClick: () => removeEntry(entry),
variant: "danger"
}, /* @__PURE__ */ React.createElement("span", {
class: "fas fa-times-circle fa-lg add-entry",
"aria-hiddne": "true"
}))));
})));
}
}
export default MonthTab;
38 changes: 38 additions & 0 deletions build/Months.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from "./_snowpack/pkg/react.js";
import {Tabs, Tab, Fade} from "./_snowpack/pkg/react-bootstrap.js";
import MonthTab from "./MonthTab.js";
class Months extends React.Component {
render() {
const {entries} = this.props;
let allMonths = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
return /* @__PURE__ */ React.createElement(Tabs, {
transition: Fade,
defaultActiveKey: "October",
id: "months",
className: "mb-3 justify-content-md-center text-center"
}, allMonths.map((month) => {
let monthEntries = entries.filter((entry) => entry.month == month);
return /* @__PURE__ */ React.createElement(Tab, {
eventKey: month,
title: month
}, /* @__PURE__ */ React.createElement(MonthTab, {
month,
data: monthEntries
}));
}));
}
}
export default Months;
129 changes: 129 additions & 0 deletions build/_snowpack/pkg/common/index-ae389540.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
function createCommonjsModule(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function (path, base) {
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}

function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
}

/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;

function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}

return Object(val);
}

function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}

// Detect buggy property enumeration order in older V8 versions.

// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}

// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}

// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}

return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}

var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;

for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);

for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}

if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}

return to;
};

var react_production_min = createCommonjsModule(function (module, exports) {
var n=60103,p=60106;exports.Fragment=60107;exports.StrictMode=60108;exports.Profiler=60114;var q=60109,r=60110,t=60112;exports.Suspense=60113;var u=60115,v=60116;
if("function"===typeof Symbol&&Symbol.for){var w=Symbol.for;n=w("react.element");p=w("react.portal");exports.Fragment=w("react.fragment");exports.StrictMode=w("react.strict_mode");exports.Profiler=w("react.profiler");q=w("react.provider");r=w("react.context");t=w("react.forward_ref");exports.Suspense=w("react.suspense");u=w("react.memo");v=w("react.lazy");}var x="function"===typeof Symbol&&Symbol.iterator;
function y(a){if(null===a||"object"!==typeof a)return null;a=x&&a[x]||a["@@iterator"];return "function"===typeof a?a:null}function z(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)b+="&args[]="+encodeURIComponent(arguments[c]);return "Minified React error #"+a+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}
var A={isMounted:function(){return !1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},B={};function C(a,b,c){this.props=a;this.context=b;this.refs=B;this.updater=c||A;}C.prototype.isReactComponent={};C.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error(z(85));this.updater.enqueueSetState(this,a,b,"setState");};C.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate");};
function D(){}D.prototype=C.prototype;function E(a,b,c){this.props=a;this.context=b;this.refs=B;this.updater=c||A;}var F=E.prototype=new D;F.constructor=E;objectAssign(F,C.prototype);F.isPureReactComponent=!0;var G={current:null},H=Object.prototype.hasOwnProperty,I={key:!0,ref:!0,__self:!0,__source:!0};
function J(a,b,c){var e,d={},k=null,h=null;if(null!=b)for(e in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=""+b.key),b)H.call(b,e)&&!I.hasOwnProperty(e)&&(d[e]=b[e]);var g=arguments.length-2;if(1===g)d.children=c;else if(1<g){for(var f=Array(g),m=0;m<g;m++)f[m]=arguments[m+2];d.children=f;}if(a&&a.defaultProps)for(e in g=a.defaultProps,g)void 0===d[e]&&(d[e]=g[e]);return {$$typeof:n,type:a,key:k,ref:h,props:d,_owner:G.current}}
function K(a,b){return {$$typeof:n,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function L(a){return "object"===typeof a&&null!==a&&a.$$typeof===n}function escape(a){var b={"=":"=0",":":"=2"};return "$"+a.replace(/[=:]/g,function(a){return b[a]})}var M=/\/+/g;function N(a,b){return "object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
function O(a,b,c,e,d){var k=typeof a;if("undefined"===k||"boolean"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case n:case p:h=!0;}}if(h)return h=a,d=d(h),a=""===e?"."+N(h,0):e,Array.isArray(d)?(c="",null!=a&&(c=a.replace(M,"$&/")+"/"),O(d,b,c,"",function(a){return a})):null!=d&&(L(d)&&(d=K(d,c+(!d.key||h&&h.key===d.key?"":(""+d.key).replace(M,"$&/")+"/")+a)),b.push(d)),1;h=0;e=""===e?".":e+":";if(Array.isArray(a))for(var g=
0;g<a.length;g++){k=a[g];var f=e+N(k,g);h+=O(k,b,c,f,d);}else if(f=y(a),"function"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=e+N(k,g++),h+=O(k,b,c,f,d);else if("object"===k)throw b=""+a,Error(z(31,"[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b));return h}function P(a,b,c){if(null==a)return a;var e=[],d=0;O(a,e,"","",function(a){return b.call(c,a,d++)});return e}
function Q(a){if(-1===a._status){var b=a._result;b=b();a._status=0;a._result=b;b.then(function(b){0===a._status&&(b=b.default,a._status=1,a._result=b);},function(b){0===a._status&&(a._status=2,a._result=b);});}if(1===a._status)return a._result;throw a._result;}var R={current:null};function S(){var a=R.current;if(null===a)throw Error(z(321));return a}var T={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:G,IsSomeRendererActing:{current:!1},assign:objectAssign};
exports.Children={map:P,forEach:function(a,b,c){P(a,function(){b.apply(this,arguments);},c);},count:function(a){var b=0;P(a,function(){b++;});return b},toArray:function(a){return P(a,function(a){return a})||[]},only:function(a){if(!L(a))throw Error(z(143));return a}};exports.Component=C;exports.PureComponent=E;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=T;
exports.cloneElement=function(a,b,c){if(null===a||void 0===a)throw Error(z(267,a));var e=objectAssign({},a.props),d=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=G.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)H.call(b,f)&&!I.hasOwnProperty(f)&&(e[f]=void 0===b[f]&&void 0!==g?g[f]:b[f]);}var f=arguments.length-2;if(1===f)e.children=c;else if(1<f){g=Array(f);for(var m=0;m<f;m++)g[m]=arguments[m+2];e.children=g;}return {$$typeof:n,type:a.type,
key:d,ref:k,props:e,_owner:h}};exports.createContext=function(a,b){void 0===b&&(b=null);a={$$typeof:r,_calculateChangedBits:b,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:q,_context:a};return a.Consumer=a};exports.createElement=J;exports.createFactory=function(a){var b=J.bind(null,a);b.type=a;return b};exports.createRef=function(){return {current:null}};exports.forwardRef=function(a){return {$$typeof:t,render:a}};exports.isValidElement=L;
exports.lazy=function(a){return {$$typeof:v,_payload:{_status:-1,_result:a},_init:Q}};exports.memo=function(a,b){return {$$typeof:u,type:a,compare:void 0===b?null:b}};exports.useCallback=function(a,b){return S().useCallback(a,b)};exports.useContext=function(a,b){return S().useContext(a,b)};exports.useDebugValue=function(){};exports.useEffect=function(a,b){return S().useEffect(a,b)};exports.useImperativeHandle=function(a,b,c){return S().useImperativeHandle(a,b,c)};
exports.useLayoutEffect=function(a,b){return S().useLayoutEffect(a,b)};exports.useMemo=function(a,b){return S().useMemo(a,b)};exports.useReducer=function(a,b,c){return S().useReducer(a,b,c)};exports.useRef=function(a){return S().useRef(a)};exports.useState=function(a){return S().useState(a)};exports.version="17.0.2";
});

var react = createCommonjsModule(function (module) {

{
module.exports = react_production_min;
}
});

export { createCommonjsModule as c, objectAssign as o, react as r };
Loading