diff --git a/README.md b/README.md index f9d4703..deac768 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,22 @@ CNAMEs need to be created for the various services. Create the CNAMEs below with After doing this, you should have the following domains: api.domain.com, account.domain.com, media.domain.com, admin.domain.compose -openmhz.test:3000 + +### Debugging React Apps using Hot Reloading +If you are trying to make changes to any of react frontends, it is a huge pain to have to compile to site and rebuild the container each time you make a change. Instead, simply run the react app in development mode. This will work for the frontends for the: +- admin frontend +- account frontend +- frontend... frontend + +First, start up all of the containers as described above. You will still the backend APIs they provide. + +Now go into the respective sub directory for the component you are interested in and run: +```` +source ../test.env +yarn start +```` + +This should build the frontend and open a browser. In order to have all the cookies work correctly, you have to use the same domain name. Make sure you have setup the local domains as described above. Then goto the base domain, for me that is openmhz.test, at port 3000 `openmhz.test:3000` ### Mailjet diff --git a/account-old/src/client/Billing/Billing.js b/account-old/src/client/Billing/Billing.js deleted file mode 100644 index 82c83fb..0000000 --- a/account-old/src/client/Billing/Billing.js +++ /dev/null @@ -1,86 +0,0 @@ -import React, { Component } from "react"; -import { Elements, StripeProvider} from 'react-stripe-elements'; -import { Container, Header, Segment, Icon, Divider, Button, Message } from 'semantic-ui-react' -import PaymentSource from "./PaymentSource" -import InvoiceList from "./InvoiceList" -// ---------------------------------------------------- -class Billing extends Component { - constructor(props) { - super(props); - this.handleShowAddSource = this.handleShowAddSource.bind(this); - this.handleNewSource = this.handleNewSource.bind(this); - this.state = {showAddSource: false}; - } - - - componentDidMount() { - this.props.fetchBilling(); - this.props.fetchInvoices(); - } - handleShowAddSource() { - this.setState({ - showAddSource: !this.state.showAddSource - }); - } - handleNewSource(newSource) { - this.setState({ - showAddSource: false - }); - this.props.updateCard(newSource); - } - //https://stackoverflow.com/questions/36559661/how-can-i-dispatch-from-child-components-in-react-redux - //https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter - render() { - var name = this.props.user.firstName + " " + this.props.user.lastName; - var section=
; - if (!this.props.billing || this.state.showAddSource) { - section = (
- - - - - -
) - } else { - section = ( - -
- - Card on File -
-
-
- - {this.props.billing.source.name} xxxx-{this.props.billing.source.last4} - Expires {this.props.billing.source.exp_month} / {this.props.billing.source.exp_year} - -
- -
) - } - - return ( - -
- Payment Method
-

It is free to use OpenMHz. Add payment in order to upgrade features.

- {section} -
- Payment History
- {this.props.billing.invoices.length > 0 ? ( - - ) : ( - - Changes in Service -

- We updated our privacy policy here to better service our customers. We recommend reviewing the - changes. -

-
- )} -
- ); - } -} - -export default Billing; \ No newline at end of file diff --git a/account-old/src/client/Billing/BillingContainer.js b/account-old/src/client/Billing/BillingContainer.js deleted file mode 100644 index e5e308b..0000000 --- a/account-old/src/client/Billing/BillingContainer.js +++ /dev/null @@ -1,17 +0,0 @@ -import { connect } from "react-redux" -import * as billingActions from "./billing-actions" -import Billing from "./Billing" - -function mapStateToProps(state) { - return { - user: state.user, - billing: state.billing - } -} - - - -export default connect( - mapStateToProps, - billingActions -)(Billing) diff --git a/account-old/src/client/Billing/InvoiceList.js b/account-old/src/client/Billing/InvoiceList.js deleted file mode 100644 index 2c64405..0000000 --- a/account-old/src/client/Billing/InvoiceList.js +++ /dev/null @@ -1,43 +0,0 @@ -import React, { Component } from "react"; - -import { - Container, - Table -} from "semantic-ui-react"; - -class InvoiceList extends Component { - - - - - constructor(props) { - super(props); - } - - render() { - const DATE_OPTIONS = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' }; - return ( - - - - Date - Amount - Status - - - - - {this.props.invoices.map((invoice, index) => { - return( - {(new Date(invoice.date*1000)).toLocaleDateString('en-US', DATE_OPTIONS)} - ${invoice.amount_due/100} - {invoice.status} - View Invoice - ) - } )} - -
- ) - } -} -export default InvoiceList; diff --git a/account-old/src/client/Billing/PaymentSource.js b/account-old/src/client/Billing/PaymentSource.js deleted file mode 100644 index 811caf9..0000000 --- a/account-old/src/client/Billing/PaymentSource.js +++ /dev/null @@ -1,52 +0,0 @@ -import React, {Component} from 'react'; -import { Header, Button, Segment, Form, Icon, Divider } from 'semantic-ui-react' -import {CardElement, injectStripe} from 'react-stripe-elements'; - -class PaymentSource extends Component { - constructor(props) { - super(props); - this.submit = this.submit.bind(this); - this.handleInputChange = this.handleInputChange.bind(this); - this.state = {name: this.props.name ? this.props.name : ""}; - } - handleInputChange = (e, { name, value }) => this.setState({ [name]: value }); - async submit(ev) { - console.log("here"); - this.props.stripe.createSource({type: 'card', owner: { - name: this.state.name, email: this.props.email - }}).then(({source}) => { - this.props.onSubmit({sourceId: source.id }) - console.log('Received Stripe token:', source); - }); - - } - - render() { - return ( -
- -
- -
- - Credit or Debit Card -
-
- - - - -
-
- ); - } -} - -export default injectStripe(PaymentSource); diff --git a/account-old/src/client/Billing/billing-actions.js b/account-old/src/client/Billing/billing-actions.js deleted file mode 100644 index f921daf..0000000 --- a/account-old/src/client/Billing/billing-actions.js +++ /dev/null @@ -1,145 +0,0 @@ -import axios from "axios"; -import * as types from "./billing-constants"; -import { push } from 'connected-react-router'; - - -function beginUpdateCard() { - return { type: types.UPDATE_CARD }; -} - -function updateCardSuccess(data) { - return { type: types.UPDATE_CARD_SUCCESS, data }; -} - -function updateCardError(data) { - return { type: types.UPDATE_CARD_ERROR, data }; -} - - -function beginFetchBilling() { - return { type: types.FETCH_BILLING }; -} - -function fetchBillingSuccess(data) { - return { type: types.FETCH_BILLING_SUCCESS, - data }; -} - - -function fetchBillingError(data) { - return { type: types.FETCH_BILLING_ERROR, - data }; -} - -function beginFetchInvoice() { - return { type: types.FETCH_INVOICE }; -} - -function fetchInvoiceSuccess(data) { - return { type: types.FETCH_INVOICE_SUCCESS, - data }; -} - - -function fetchInvoiceError(data) { - return { type: types.FETCH_INVOICE_ERROR, - data }; -} - -function makeUserRequest(method, data, api = "/login") { - // returns a Promise - return axios({ - method: method, - url: api, - data: data - }); -} - -export function changeUrl(url) { - return dispatch => { - dispatch(push(url)); - }; -} - -// Example of an Async Action Creator -// http://redux.js.org/docs/advanced/AsyncActions.html - -export function updateCard(data) { - return dispatch => { - dispatch(beginUpdateCard()); - - return makeUserRequest("post", data, "/api/customer/", {withCredentials: true}) - .then(response => { - if (response.data.success) { - - - dispatch(updateCardSuccess(response.data)); - } else { - dispatch(updateCardError()); - let registerMessage = response.data.message; - return registerMessage; - } - }) - .catch(response => { - if (response instanceof Error) { - // Something happened in setting up the request that triggered an Error - console.log("Error", response.message); - } - }); - }; -} - - - - -export function fetchBilling() { - return (dispatch, getState) => { - - dispatch(beginFetchBilling()); - - return axios - .get("/api/billing", {withCredentials: true}) - .then(response => { - if (response.data.success) { - dispatch(fetchBillingSuccess(response.data)); - } else { - dispatch(fetchBillingError()); - let registerMessage = response.data.message; - return registerMessage; - } - }) - .catch(response => { - if (response instanceof Error) { - // Something happened in setting up the request that triggered an Error - console.log("Error", response.message); - } - }); - -}; -} - -export function fetchInvoices() { - return (dispatch, getState) => { - - dispatch(beginFetchInvoice()); - - return axios - .get("/api/invoices", {withCredentials: true}) - .then(response => { - if (response.data.success) { - dispatch(fetchInvoiceSuccess(response.data)); - } else { - dispatch(fetchInvoiceError()); - let registerMessage = response.data.message; - return registerMessage; - } - }) - .catch(response => { - if (response instanceof Error) { - // Something happened in setting up the request that triggered an Error - console.log("Error", response.message); - } - }); - -}; -} diff --git a/account-old/src/client/Billing/billing-constants.js b/account-old/src/client/Billing/billing-constants.js deleted file mode 100644 index 93cf4a4..0000000 --- a/account-old/src/client/Billing/billing-constants.js +++ /dev/null @@ -1,11 +0,0 @@ - -export const UPDATE_CARD = "UPDATE_CARD" -export const UPDATE_CARD_SUCCESS = "UPDATE_CARD_SUCCESS" -export const UPDATE_CARD_ERROR = "UPDATE_CARD_ERROR" -export const FETCH_BILLING = "FETCH_BILLING" -export const FETCH_BILLING_SUCCESS = "FETCH_BILLING_SUCCESS" -export const FETCH_BILLING_ERROR = "FETCH_BILLING_ERROR" -export const FETCH_INVOICE = "FETCH_INVOICE" -export const FETCH_INVOICE_SUCCESS = "FETCH_INVOICE_SUCCESS" -export const FETCH_INVOICE_ERROR = "FETCH_INVOICE_ERROR" - diff --git a/account-old/src/client/Billing/billing-reducer.js b/account-old/src/client/Billing/billing-reducer.js deleted file mode 100644 index 430158a..0000000 --- a/account-old/src/client/Billing/billing-reducer.js +++ /dev/null @@ -1,71 +0,0 @@ -import { - UPDATE_CARD, - UPDATE_CARD_SUCCESS, - UPDATE_CARD_ERROR, - FETCH_BILLING, - FETCH_BILLING_SUCCESS, - FETCH_BILLING_ERROR, - FETCH_INVOICE, - FETCH_INVOICE_SUCCESS, - FETCH_INVOICE_ERROR -} from "./billing-constants"; - -function updateObject(oldObject, newValues) { - // Encapsulate the idea of passing a new object as the first parameter - // to Object.assign to ensure we correctly copy data instead of mutating - return Object.assign({}, oldObject, newValues); -} - -function updateObjectInArray(array, shortName, updatedItem) { - return array.map( item => { - if(item.shortName !== shortName) { - // This isn't the item we care about - keep it as-is - return item; - } - - // Otherwise, this is the one we want - return an updated value - return { - ...item, - ...updatedItem - }; - }); -} - - -const billing = ( - state = { - isWaiting: false, - source: false, - invoices: []}, - action -) => { - switch (action.type) { - - case UPDATE_CARD: - case FETCH_BILLING: - case FETCH_INVOICE: - return Object.assign({}, state, { isWaiting: true}); - - - case UPDATE_CARD_SUCCESS: - return Object.assign({}, state, { source: action.data.source, isWaiting: false}); - - case FETCH_BILLING_SUCCESS: - return Object.assign({}, state, { source: action.data.source, isWaiting: false}); - - case FETCH_INVOICE_SUCCESS: - return Object.assign({}, state, { invoices: action.data.invoices, isWaiting: false}); - - case UPDATE_CARD_ERROR: - case FETCH_BILLING_ERROR: - case FETCH_INVOICE_ERROR: - return Object.assign({}, state, { - isWaiting: false - }); - - default: - return state; - } -}; - -export default billing; diff --git a/account/.eslintcache b/account/.eslintcache index 732a49e..ee4ae71 100644 --- a/account/.eslintcache +++ b/account/.eslintcache @@ -1 +1 @@ -[{"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/index.js":"1","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/reducers.js":"2","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/NavigationContainer.js":"3","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-actions.js":"4","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Navigation.js":"5","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/configureStore.js":"6","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-reducer.js":"7","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Login.js":"8","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/query-string.js":"9","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/LoginContainer.js":"10","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/UserForm.js":"11","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/RegisterContainer.js":"12","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPasswordContainer.js":"13","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPassword.js":"14","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmail.js":"15","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmailContainer.js":"16","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmailContainer.js":"17","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmail.js":"18","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ProfileContainer.js":"19","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Restricted.js":"20","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/App.js":"21","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmailContainer.js":"22","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPasswordContainer.js":"23","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/TermsContainer.js":"24","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Register.js":"25","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Profile.js":"26","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmail.js":"27","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-constants.js":"28","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPassword.js":"29","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Terms.js":"30"},{"size":2128,"mtime":1610891944991,"results":"31","hashOfConfig":"32"},{"size":333,"mtime":1609904150827,"results":"33","hashOfConfig":"32"},{"size":570,"mtime":1609902896319,"results":"34","hashOfConfig":"32"},{"size":10455,"mtime":1610977327935,"results":"35","hashOfConfig":"32"},{"size":1489,"mtime":1609987532309,"results":"36","hashOfConfig":"32"},{"size":759,"mtime":1609902457124,"results":"37","hashOfConfig":"32"},{"size":3424,"mtime":1609902858959,"results":"38","hashOfConfig":"32"},{"size":5806,"mtime":1609987528328,"results":"39","hashOfConfig":"32"},{"size":362,"mtime":1609987504726,"results":"40","hashOfConfig":"32"},{"size":942,"mtime":1609985062605,"results":"41","hashOfConfig":"32"},{"size":8461,"mtime":1609987520749,"results":"42","hashOfConfig":"32"},{"size":273,"mtime":1609902858948,"results":"43","hashOfConfig":"32"},{"size":285,"mtime":1609902858952,"results":"44","hashOfConfig":"32"},{"size":2861,"mtime":1609986763111,"results":"45","hashOfConfig":"32"},{"size":1813,"mtime":1609987539627,"results":"46","hashOfConfig":"32"},{"size":270,"mtime":1609902858943,"results":"47","hashOfConfig":"32"},{"size":282,"mtime":1609902858956,"results":"48","hashOfConfig":"32"},{"size":692,"mtime":1609987522924,"results":"49","hashOfConfig":"32"},{"size":290,"mtime":1609902858946,"results":"50","hashOfConfig":"32"},{"size":1911,"mtime":1609987530612,"results":"51","hashOfConfig":"32"},{"size":253,"mtime":1609987534146,"results":"52","hashOfConfig":"32"},{"size":282,"mtime":1609902858953,"results":"53","hashOfConfig":"32"},{"size":273,"mtime":1609902858951,"results":"54","hashOfConfig":"32"},{"size":250,"mtime":1609902858954,"results":"55","hashOfConfig":"32"},{"size":1598,"mtime":1609987526511,"results":"56","hashOfConfig":"32"},{"size":1204,"mtime":1609902858945,"results":"57","hashOfConfig":"32"},{"size":1390,"mtime":1609987518565,"results":"58","hashOfConfig":"32"},{"size":1839,"mtime":1609902858958,"results":"59","hashOfConfig":"32"},{"size":2802,"mtime":1609987524544,"results":"60","hashOfConfig":"32"},{"size":3381,"mtime":1609986995536,"results":"61","hashOfConfig":"32"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},"3sdj67",{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"73","messages":"74","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"75","messages":"76","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"79","messages":"80","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"81","usedDeprecatedRules":"64"},{"filePath":"82","messages":"83","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"84","messages":"85","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"86","messages":"87","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"88","messages":"89","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"90","messages":"91","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"92","messages":"93","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"94","messages":"95","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"96","messages":"97","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"98","messages":"99","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"100","messages":"101","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"102","messages":"103","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"104","messages":"105","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"106","messages":"107","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"108","messages":"109","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"110","messages":"111","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"112","messages":"113","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"114","messages":"115","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"116","messages":"117","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"118","messages":"119","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"120","messages":"121","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"122","messages":"123","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/index.js",[],["124","125"],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/reducers.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/NavigationContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-actions.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Navigation.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/configureStore.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-reducer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Login.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/query-string.js",["126"],"export default {\n parse: function parse(queryString) {\n var query = {};\n var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');\n for (var i = 0; i < pairs.length; i++) {\n var pair = pairs[i].split('=');\n query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');\n }\n return query;\n }\n}\n","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/LoginContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/UserForm.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/RegisterContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPasswordContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPassword.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmail.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmailContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmailContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmail.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ProfileContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Restricted.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/App.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmailContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPasswordContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/TermsContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Register.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Profile.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmail.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-constants.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPassword.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Terms.js",[],{"ruleId":"127","replacedBy":"128"},{"ruleId":"129","replacedBy":"130"},{"ruleId":"131","severity":1,"message":"132","line":1,"column":1,"nodeType":"133","endLine":11,"endColumn":2},"no-native-reassign",["134"],"no-negated-in-lhs",["135"],"import/no-anonymous-default-export","Assign object to a variable before exporting as module default","ExportDefaultDeclaration","no-global-assign","no-unsafe-negation"] \ No newline at end of file +[{"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/index.js":"1","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/reducers.js":"2","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/NavigationContainer.js":"3","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-actions.js":"4","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Navigation.js":"5","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/configureStore.js":"6","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-reducer.js":"7","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Login.js":"8","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/query-string.js":"9","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/LoginContainer.js":"10","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/UserForm.js":"11","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/RegisterContainer.js":"12","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPasswordContainer.js":"13","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPassword.js":"14","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmail.js":"15","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmailContainer.js":"16","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmailContainer.js":"17","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmail.js":"18","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ProfileContainer.js":"19","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Restricted.js":"20","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/App.js":"21","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmailContainer.js":"22","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPasswordContainer.js":"23","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/TermsContainer.js":"24","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Register.js":"25","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Profile.js":"26","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmail.js":"27","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-constants.js":"28","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPassword.js":"29","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Terms.js":"30"},{"size":2202,"mtime":1611714677235,"results":"31","hashOfConfig":"32"},{"size":333,"mtime":1609904150827,"results":"33","hashOfConfig":"32"},{"size":570,"mtime":1609902896319,"results":"34","hashOfConfig":"32"},{"size":10522,"mtime":1610993078414,"results":"35","hashOfConfig":"32"},{"size":1513,"mtime":1611437621987,"results":"36","hashOfConfig":"32"},{"size":759,"mtime":1609902457124,"results":"37","hashOfConfig":"32"},{"size":3424,"mtime":1609902858959,"results":"38","hashOfConfig":"32"},{"size":5807,"mtime":1611715556011,"results":"39","hashOfConfig":"32"},{"size":362,"mtime":1609987504726,"results":"40","hashOfConfig":"32"},{"size":942,"mtime":1609985062605,"results":"41","hashOfConfig":"32"},{"size":8461,"mtime":1609987520749,"results":"42","hashOfConfig":"32"},{"size":273,"mtime":1609902858948,"results":"43","hashOfConfig":"32"},{"size":285,"mtime":1609902858952,"results":"44","hashOfConfig":"32"},{"size":2861,"mtime":1609986763111,"results":"45","hashOfConfig":"32"},{"size":1813,"mtime":1609987539627,"results":"46","hashOfConfig":"32"},{"size":270,"mtime":1609902858943,"results":"47","hashOfConfig":"32"},{"size":282,"mtime":1609902858956,"results":"48","hashOfConfig":"32"},{"size":692,"mtime":1609987522924,"results":"49","hashOfConfig":"32"},{"size":290,"mtime":1609902858946,"results":"50","hashOfConfig":"32"},{"size":1911,"mtime":1609987530612,"results":"51","hashOfConfig":"32"},{"size":253,"mtime":1609987534146,"results":"52","hashOfConfig":"32"},{"size":282,"mtime":1609902858953,"results":"53","hashOfConfig":"32"},{"size":273,"mtime":1609902858951,"results":"54","hashOfConfig":"32"},{"size":250,"mtime":1609902858954,"results":"55","hashOfConfig":"32"},{"size":1598,"mtime":1609987526511,"results":"56","hashOfConfig":"32"},{"size":1204,"mtime":1609902858945,"results":"57","hashOfConfig":"32"},{"size":1390,"mtime":1609987518565,"results":"58","hashOfConfig":"32"},{"size":1839,"mtime":1609902858958,"results":"59","hashOfConfig":"32"},{"size":2802,"mtime":1609987524544,"results":"60","hashOfConfig":"32"},{"size":3381,"mtime":1609986995536,"results":"61","hashOfConfig":"32"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},"3sdj67",{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"73","messages":"74","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"75","messages":"76","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"81","usedDeprecatedRules":"64"},{"filePath":"82","messages":"83","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"84","messages":"85","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"86","messages":"87","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"88","messages":"89","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"90","messages":"91","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"92","messages":"93","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"94","messages":"95","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"96","messages":"97","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"98","messages":"99","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"100","messages":"101","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"102","messages":"103","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"104","messages":"105","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"106","messages":"107","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"108","messages":"109","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"110","messages":"111","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"112","messages":"113","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"114","messages":"115","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"116","messages":"117","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"118","messages":"119","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"120","messages":"121","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},{"filePath":"122","messages":"123","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"64"},"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/index.js",[],["124","125"],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/reducers.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/NavigationContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-actions.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Navigation.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/redux-router/configureStore.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-reducer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Login.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/query-string.js",["126"],"export default {\n parse: function parse(queryString) {\n var query = {};\n var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');\n for (var i = 0; i < pairs.length; i++) {\n var pair = pairs[i].split('=');\n query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');\n }\n return query;\n }\n}\n","/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/LoginContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/UserForm.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/RegisterContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPasswordContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SendResetPassword.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmail.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ConfirmEmailContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmailContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmail.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ProfileContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/Restricted.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/App/App.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/SentConfirmEmailContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPasswordContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/TermsContainer.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Register.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Profile.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/WaitConfirmEmail.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/user-constants.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/ResetPassword.js",[],"/Users/luke/Projects/OpenMHz/trunk-server-public/account/src/User/Terms.js",[],{"ruleId":"127","replacedBy":"128"},{"ruleId":"129","replacedBy":"130"},{"ruleId":"131","severity":1,"message":"132","line":1,"column":1,"nodeType":"133","endLine":11,"endColumn":2},"no-native-reassign",["134"],"no-negated-in-lhs",["135"],"import/no-anonymous-default-export","Assign object to a variable before exporting as module default","ExportDefaultDeclaration","no-global-assign","no-unsafe-negation"] \ No newline at end of file diff --git a/account/README.md b/account/README.md deleted file mode 100644 index d85e9e3..0000000 --- a/account/README.md +++ /dev/null @@ -1,68 +0,0 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app), using the [Redux](https://redux.js.org/) and [Redux Toolkit](https://redux-toolkit.js.org/) template. - -## Available Scripts - -In the project directory, you can run: - -### `yarn start` - -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -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. - -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. - -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. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `yarn build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify diff --git a/account/server/controllers/plans.js b/account/server/controllers/plans.js deleted file mode 100644 index 7b943c6..0000000 --- a/account/server/controllers/plans.js +++ /dev/null @@ -1,272 +0,0 @@ -const mongoose = require("mongoose"); -const Plan = require("../models/plan"); -const System = require("../models/system"); - -const stripeKeyPublishable = process.env.STRIPE_PUBLISHABLE_KEY; -const stripeKeySecret = process.env.STRIPE_SECRET_KEY; - -const stripe = require("stripe")(stripeKeySecret); - -var admin_email = process.env['REACT_APP_ADMIN_EMAIL'] != null ? process.env['REACT_ADMIN_ADMIN_EMAIL'] : "luke@openmhz.com"; -var site_name = process.env['REACT_APP_SITE_NAME'] != null ? process.env['REACT_APP_SITE_NAME'] : "OpenMHz"; -var account_server = process.env['REACT_APP_ACCOUNT_SERVER'] != null ? process.env['REACT_APP_ACCOUNT_SERVER'] : "https://account.openmhz.com"; -var cookie_domain = process.env['REACT_APP_COOKIE_DOMAIN'] != null ? process.env['REACT_APP_COOKIE_DOMAIN'] : '.openmhz.com'; //'https://s3.amazonaws.com/robotastic'; - -exports.isLoggedIn = function (req, res, next) { - if (req.isAuthenticated()) return next(); - res.redirect("/login"); -}; - - -function makeSystemsResponse(systems) { - var returnSys = systems.map(obj => { - var rObj = (({ - name, - shortName, - description, - systemType, - city, - state, - county, - country, - userId, - key, - planType, - showScreenName - }) => ({ - name, - shortName, - description, - systemType, - city, - state, - county, - country, - userId, - key, - planType, - showScreenName - }))(obj); - rObj.id = obj._id; - return rObj; - }); - return returnSys; -} - -function findSubscriptionItem(subscription, planId) { - var items = subscription.items.data; - - var subscriptionItem = items.find(function (element) { - return element.plan.id == planId; - }); - return subscriptionItem; -}; - -// ------------------------------------------- - -// makes sure the plans a user is trying to update actually belong to them. -function validatePlans(systems, updatedPlans) { - var validatedPlans = []; - systems.forEach(function (system) { - - // Find the updated plan for that system. - const updatedPlan = updatedPlans.find(function (element) { - return element.shortName == system.shortName; - }) - if (!updatedPlan) { - console.log("ERROR: updated plan not found for ShortName"); - } - - // Update that systems plan type - // TODO: add validation of plantype - system.planType = updatedPlan.planType; - validatedPlans.push({ shortName: system.shortName, planType: updatedPlan.planType }); - }); - return validatedPlans; -} -exports.updatePlans = async function (req, res, next) { - const userId = mongoose.Types.ObjectId(req.user._id); - - if (!req.user.customerId) { - console.log("ERROR: user does not have billing setup"); - res.json({ - success: false, - message: "ERROR: user does not have billing setup" - }); - return; - } - - const updatedPlans = req.body.updatePlans; - console.log(updatedPlans); - - try { - var plan = await Plan.findOne({ userId: userId }); - - // looks like the User does not have a plan yet - - if (!plan) { - plan = new Plan({ userId: userId }); - } - - - // Find all of the Users Systems - var systems = await System.find({ userId: mongoose.Types.ObjectId(req.user._id) }) - - - } catch (err) { - - console.log("Error upate plans: " + err); - res.json({ - success: false, - message: err - }); - return; - } - - // For each of the User's Systems - var validatedPlans = validatePlans(systems, updatedPlans); - - // Create the subscription object - console.log("---------Validated Plans--------"); - console.log(validatedPlans); - var proPlans = { plan: "plan_EQoJeqkAw6FCgy", quantity: 0 }; - var proPlanSystems = []; - var proPlanQuantity = 0; - validatedPlans.forEach(function (plan) { - if (plan.planType == 10) { - proPlanQuantity++; - proPlans.quantity++; - proPlanSystems.push(plan.shortName); - } - }); - - if (!plan.subscriptionId) { - //proPlans.metadata = proPlanSystems.join(); - var items = []; - items.push(proPlans); - //Subscribe the User - - console.log(subscription); - try { - var subscription = await stripe.subscriptions.create({ - customer: req.user.customerId, - items: items - }); - console.log(subscription); - - const subscriptionItem = findSubscriptionItem(subscription, "plan_EQoJeqkAw6FCgy"); - if (subscriptionItem) { - plan.proSystemSubscription = { subscriptionItemId: subscriptionItem.id, quantity: proPlanQuantity, systems: proPlanSystems }; - plan.subscriptionId = subscription.id; - await plan.save(); - systems.forEach(async function (system) { await system.save(); }); - // Save the updated Systems - const returnSystems = makeSystemsResponse(systems); - res.json({ - success: true, - systems: returnSystems - }); - return; - } - } catch (err) { - console.log("Error upate plans: " + err); - res.json({ - success: false, - message: err - }); - return; - } - } else { - // we alreay have a Subscription for the User - try { - var subscriptionItem=null; - // Check if the user has a Pro Plan subscription Item setup yet. - if (plan.proSystemSubscription) { - subscriptionItem = await stripe.subscriptionItems.update(plan.proSystemSubscription.subscriptionItemId, - { - quantity: proPlanQuantity, - }); - } else { - // Create one if they don't - subscriptionItem = await stripe.subscriptionItems.create( - { - subscription: plan.subscriptionId, - plan: "plan_EQoJeqkAw6FCgy", - quantity: proPlanQuantity, - }); - } - - if (subscriptionItem) { - plan.proSystemSubscription = { subscriptionItemId: subscriptionItem.id, quantity: proPlanQuantity, systems: proPlanSystems }; - await plan.save(); - systems.forEach(async function (system) { await system.save(); }); - // Save the updated Systems - const returnSystems = makeSystemsResponse(systems); - res.json({ - success: true, - systems: returnSystems - }); - return; - } - - } catch (err) { - console.log("Error upate plans: " + err); - res.json({ - success: false, - message: err - }); - return; - } - - } - -} - -exports.getInvoices = async function (req, res, next) { - if (!req.user.customerId) { - console.log("ERROR: user does not have billing setup"); - res.json({ - success: false, - message: "ERROR: user does not have billing setup" - }); - return; - } - - try { - console.log("Trying to fetch invoices for: " + req.user.customerId); - var invoices = await stripe.invoices.list( { limit: 12, customer: req.user.customerId }); - console.log(invoices); - var obj = invoices.data.map(obj => { - var rObj = (({ - amount_due, - amount_paid, - date, - invoice_pdf, - paid, - status, - description - }) => ({ - amount_due, - amount_paid, - date, - invoice_pdf, - paid, - status, - description - }))(obj); - rObj.id = obj._id; - return rObj; - }); - return res.json({ - success: true, - invoices: obj - }); - } catch (err) { - console.log("Error retrieving licesnes: " + err); - res.json({ - success: false, - message: err - }); - return; - } -} diff --git a/account/server/models/plan.js b/account/server/models/plan.js deleted file mode 100644 index 2dc4f78..0000000 --- a/account/server/models/plan.js +++ /dev/null @@ -1,23 +0,0 @@ -// Defining a User Model in mongoose -// Code modified from https://github.com/sahat/hackathon-starter - -const mongoose = require("mongoose"); - - -var SubscriptionSchema = mongoose.Schema({ subscriptionItemId: String, quantity: {type: Number, default: 0}, systems: [String] }); -const PlanSchema = new mongoose.Schema({ - - userId: mongoose.Schema.Types.ObjectId, - userPlan: { - type: Number, - default: 0 - }, - subscriptionId: String, - proSystemSubscription: SubscriptionSchema -}) - - - - - -module.exports = mongoose.model("Plan", PlanSchema) diff --git a/account/server/models/user.js b/account/server/models/user.js index 08ebad7..24193db 100644 --- a/account/server/models/user.js +++ b/account/server/models/user.js @@ -33,10 +33,6 @@ const UserSchema = new mongoose.Schema({ type: Boolean, default: false }, - customerId: { - type: String, - default: "" - }, confirmEmailToken: String, confirmEmailTTL: Date, admin: { diff --git a/account/src/App.css b/account/src/App.css deleted file mode 100644 index 355c49b..0000000 --- a/account/src/App.css +++ /dev/null @@ -1,39 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-float infinite 3s ease-in-out; - } -} - -.App-header { - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); -} - -.App-link { - color: rgb(112, 76, 182); -} - -@keyframes App-logo-float { - 0% { - transform: translateY(0); - } - 50% { - transform: translateY(10px) - } - 100% { - transform: translateY(0px) - } -} diff --git a/account/src/App.js b/account/src/App.js deleted file mode 100644 index 7825dd2..0000000 --- a/account/src/App.js +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react'; -import logo from './logo.svg'; -import { Counter } from './features/counter/Counter'; -import './App.css'; - -function App() { - return ( -
-
- logo - -

- Edit src/App.js and save to reload. -

- - Learn - - React - - , - - Redux - - , - - Redux Toolkit - - , and - - React Redux - - -
-
- ); -} - -export default App; diff --git a/account/src/App.test.js b/account/src/App.test.js deleted file mode 100644 index cf703a4..0000000 --- a/account/src/App.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import { Provider } from 'react-redux'; -import store from './app/store'; -import App from './App'; - -test('renders learn react link', () => { - const { getByText } = render( - - - - ); - - expect(getByText(/learn/i)).toBeInTheDocument(); -}); diff --git a/account/src/User/Login.js b/account/src/User/Login.js index 3be6278..c37e590 100644 --- a/account/src/User/Login.js +++ b/account/src/User/Login.js @@ -123,7 +123,7 @@ class Login extends Component { features over time, but right now it can:

diff --git a/account/src/index.css b/account/src/index.css deleted file mode 100644 index bd5bd6d..0000000 --- a/account/src/index.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/account/src/index.js b/account/src/index.js index e382bc9..97ab905 100644 --- a/account/src/index.js +++ b/account/src/index.js @@ -28,16 +28,17 @@ ReactDOM.render( <> - - - + + + + - (

Miss
)} /> + diff --git a/account/src/logo.svg b/account/src/logo.svg deleted file mode 100644 index 9e96334..0000000 --- a/account/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/account/src/serviceWorker.js b/account/src/serviceWorker.js deleted file mode 100644 index dbd1383..0000000 --- a/account/src/serviceWorker.js +++ /dev/null @@ -1,137 +0,0 @@ -// This optional code is used to register a service worker. -// register() is not called by default. - -// This lets the app load faster on subsequent visits in production, and gives -// it offline capabilities. However, it also means that developers (and users) -// will only see deployed updates on subsequent visits to a page, after all the -// existing tabs open on the page have been closed, since previously cached -// resources are updated in the background. - -// To learn more about the benefits of this model and instructions on how to -// opt-in, read https://bit.ly/CRA-PWA - -const isLocalhost = Boolean( - window.location.hostname === 'localhost' || - // [::1] is the IPv6 localhost address. - window.location.hostname === '[::1]' || - // 127.0.0.0/8 are considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); - -export function register(config) { - if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { - // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); - if (publicUrl.origin !== window.location.origin) { - // Our service worker won't work if PUBLIC_URL is on a different origin - // from what our page is served on. This might happen if a CDN is used to - // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; - } - - window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; - - if (isLocalhost) { - // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); - - // Add some additional logging to localhost, pointing developers to the - // service worker/PWA documentation. - navigator.serviceWorker.ready.then(() => { - console.log( - 'This web app is being served cache-first by a service ' + - 'worker. To learn more, visit https://bit.ly/CRA-PWA' - ); - }); - } else { - // Is not localhost. Just register service worker - registerValidSW(swUrl, config); - } - }); - } -} - -function registerValidSW(swUrl, config) { - navigator.serviceWorker - .register(swUrl) - .then(registration => { - registration.onupdatefound = () => { - const installingWorker = registration.installing; - if (installingWorker == null) { - return; - } - installingWorker.onstatechange = () => { - if (installingWorker.state === 'installed') { - if (navigator.serviceWorker.controller) { - // At this point, the updated precached content has been fetched, - // but the previous service worker will still serve the older - // content until all client tabs are closed. - console.log( - 'New content is available and will be used when all ' + - 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' - ); - - // Execute callback - if (config && config.onUpdate) { - config.onUpdate(registration); - } - } else { - // At this point, everything has been precached. - // It's the perfect time to display a - // "Content is cached for offline use." message. - console.log('Content is cached for offline use.'); - - // Execute callback - if (config && config.onSuccess) { - config.onSuccess(registration); - } - } - } - }; - }; - }) - .catch(error => { - console.error('Error during service worker registration:', error); - }); -} - -function checkValidServiceWorker(swUrl, config) { - // Check if the service worker can be found. If it can't reload the page. - fetch(swUrl, { - headers: { 'Service-Worker': 'script' }, - }) - .then(response => { - // Ensure service worker exists, and that we really are getting a JS file. - const contentType = response.headers.get('content-type'); - if ( - response.status === 404 || - (contentType != null && contentType.indexOf('javascript') === -1) - ) { - // No service worker found. Probably a different app. Reload the page. - navigator.serviceWorker.ready.then(registration => { - registration.unregister().then(() => { - window.location.reload(); - }); - }); - } else { - // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); - } - }) - .catch(() => { - console.log( - 'No internet connection found. App is running in offline mode.' - ); - }); -} - -export function unregister() { - if ('serviceWorker' in navigator) { - navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); - } -} diff --git a/account/src/setupTests.js b/account/src/setupTests.js deleted file mode 100644 index 35417dc..0000000 --- a/account/src/setupTests.js +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom/extend-expect'; diff --git a/admin/README.md b/admin/README.md deleted file mode 100644 index d85e9e3..0000000 --- a/admin/README.md +++ /dev/null @@ -1,68 +0,0 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app), using the [Redux](https://redux.js.org/) and [Redux Toolkit](https://redux-toolkit.js.org/) template. - -## Available Scripts - -In the project directory, you can run: - -### `yarn start` - -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -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. - -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. - -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. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `yarn build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify diff --git a/admin/notes.md b/admin/notes.md index 172f3de..5ea5ed9 100644 --- a/admin/notes.md +++ b/admin/notes.md @@ -1,6 +1,6 @@ ## Base -start using `npx create-react-app admin --template redux` +started development using `npx create-react-app admin --template redux` ## Packages used: - [connected-react-router](https://github.com/supasate/connected-react-router): Synchronize router state with redux store through diff --git a/admin/server/config/passport.js b/admin/server/config/passport.js index 18235a7..44674ca 100644 --- a/admin/server/config/passport.js +++ b/admin/server/config/passport.js @@ -11,15 +11,11 @@ module.exports = function (app, passport) { // serializing, and querying the user record by ID from the database when // deserializing. passport.serializeUser((user, done) => { - console.log("passport.serializeUser() - Serializing the user: " + user.id); done(null, user.id) }) passport.deserializeUser((id, done) => { - console.log("passport.deserializeUser() - Trying to deSerialize the user: " + id); User.findById(id, (err, user) => { - console.log("passport.deserializeUser() - Found the user: " + user); - console.log("passport.deserializeUser() - Err: " + err); done(err, user) }) }) diff --git a/admin/server/controllers/systems.js b/admin/server/controllers/systems.js index ee57dd7..c344d56 100644 --- a/admin/server/controllers/systems.js +++ b/admin/server/controllers/systems.js @@ -50,7 +50,6 @@ exports.listSystems = function (req, res, next) { country, userId, key, - planType, showScreenName }) => ({ name, @@ -63,7 +62,6 @@ exports.listSystems = function (req, res, next) { country, userId, key, - planType, showScreenName }))(obj); if (obj.showScreenName) { diff --git a/admin/server/index.js b/admin/server/index.js index 4fd9c92..17c4aa0 100644 --- a/admin/server/index.js +++ b/admin/server/index.js @@ -134,7 +134,6 @@ function isAdmin(req, res, next) { } function isLoggedIn(req, res, next) { - console.log(req) if (req.isAuthenticated()) return next(); res.status(401).send({ success: false, diff --git a/admin/server/models/system.js b/admin/server/models/system.js index 33a7e54..917a89d 100644 --- a/admin/server/models/system.js +++ b/admin/server/models/system.js @@ -11,7 +11,6 @@ var systemSchema = mongoose.Schema({ state: String, description: String, showScreenName: Boolean, - planType: {type: Number, default: 0}, userId: mongoose.Schema.Types.ObjectId, key: String }); diff --git a/admin/server/models/user.js b/admin/server/models/user.js index c37355a..6f9fe3c 100644 --- a/admin/server/models/user.js +++ b/admin/server/models/user.js @@ -32,10 +32,6 @@ const UserSchema = new mongoose.Schema({ type: Boolean, default: false }, - customerId: { - type: String, - default: "" - }, confirmEmailToken: String, confirmEmailTTL: Date, admin: { diff --git a/admin/src/App.css b/admin/src/App.css deleted file mode 100644 index 355c49b..0000000 --- a/admin/src/App.css +++ /dev/null @@ -1,39 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-float infinite 3s ease-in-out; - } -} - -.App-header { - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); -} - -.App-link { - color: rgb(112, 76, 182); -} - -@keyframes App-logo-float { - 0% { - transform: translateY(0); - } - 50% { - transform: translateY(10px) - } - 100% { - transform: translateY(0px) - } -} diff --git a/admin/src/App.js b/admin/src/App.js deleted file mode 100644 index 7825dd2..0000000 --- a/admin/src/App.js +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react'; -import logo from './logo.svg'; -import { Counter } from './features/counter/Counter'; -import './App.css'; - -function App() { - return ( -
-
- logo - -

- Edit src/App.js and save to reload. -

- - Learn - - React - - , - - Redux - - , - - Redux Toolkit - - , and - - React Redux - - -
-
- ); -} - -export default App; diff --git a/admin/src/App.test.js b/admin/src/App.test.js deleted file mode 100644 index cf703a4..0000000 --- a/admin/src/App.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import { Provider } from 'react-redux'; -import store from './app/store'; -import App from './App'; - -test('renders learn react link', () => { - const { getByText } = render( - - - - ); - - expect(getByText(/learn/i)).toBeInTheDocument(); -}); diff --git a/admin/src/System/SystemForm.js b/admin/src/System/SystemForm.js index 70cac4f..7d21ce5 100644 --- a/admin/src/System/SystemForm.js +++ b/admin/src/System/SystemForm.js @@ -393,6 +393,7 @@ class SystemForm extends Component { error={this.state.stateError} value={this.state.state} options={stateOptions} + scrolling label="State" placeholder="Select State..." /> diff --git a/admin/src/System/system-reducer.js b/admin/src/System/system-reducer.js index 7bd796f..e90884c 100644 --- a/admin/src/System/system-reducer.js +++ b/admin/src/System/system-reducer.js @@ -68,6 +68,7 @@ const system = ( state: action.data.state, county: action.data.county, country: action.data.country, + key: action.data.key, userId: action.data.userId, id: action.data.id, showScreenName: action.data.showScreenName diff --git a/admin/src/index.css b/admin/src/index.css deleted file mode 100644 index bd5bd6d..0000000 --- a/admin/src/index.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/admin/src/logo.svg b/admin/src/logo.svg deleted file mode 100644 index 9e96334..0000000 --- a/admin/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/src/serviceWorker.js b/admin/src/serviceWorker.js deleted file mode 100644 index dbd1383..0000000 --- a/admin/src/serviceWorker.js +++ /dev/null @@ -1,137 +0,0 @@ -// This optional code is used to register a service worker. -// register() is not called by default. - -// This lets the app load faster on subsequent visits in production, and gives -// it offline capabilities. However, it also means that developers (and users) -// will only see deployed updates on subsequent visits to a page, after all the -// existing tabs open on the page have been closed, since previously cached -// resources are updated in the background. - -// To learn more about the benefits of this model and instructions on how to -// opt-in, read https://bit.ly/CRA-PWA - -const isLocalhost = Boolean( - window.location.hostname === 'localhost' || - // [::1] is the IPv6 localhost address. - window.location.hostname === '[::1]' || - // 127.0.0.0/8 are considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); - -export function register(config) { - if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { - // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); - if (publicUrl.origin !== window.location.origin) { - // Our service worker won't work if PUBLIC_URL is on a different origin - // from what our page is served on. This might happen if a CDN is used to - // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; - } - - window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; - - if (isLocalhost) { - // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); - - // Add some additional logging to localhost, pointing developers to the - // service worker/PWA documentation. - navigator.serviceWorker.ready.then(() => { - console.log( - 'This web app is being served cache-first by a service ' + - 'worker. To learn more, visit https://bit.ly/CRA-PWA' - ); - }); - } else { - // Is not localhost. Just register service worker - registerValidSW(swUrl, config); - } - }); - } -} - -function registerValidSW(swUrl, config) { - navigator.serviceWorker - .register(swUrl) - .then(registration => { - registration.onupdatefound = () => { - const installingWorker = registration.installing; - if (installingWorker == null) { - return; - } - installingWorker.onstatechange = () => { - if (installingWorker.state === 'installed') { - if (navigator.serviceWorker.controller) { - // At this point, the updated precached content has been fetched, - // but the previous service worker will still serve the older - // content until all client tabs are closed. - console.log( - 'New content is available and will be used when all ' + - 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' - ); - - // Execute callback - if (config && config.onUpdate) { - config.onUpdate(registration); - } - } else { - // At this point, everything has been precached. - // It's the perfect time to display a - // "Content is cached for offline use." message. - console.log('Content is cached for offline use.'); - - // Execute callback - if (config && config.onSuccess) { - config.onSuccess(registration); - } - } - } - }; - }; - }) - .catch(error => { - console.error('Error during service worker registration:', error); - }); -} - -function checkValidServiceWorker(swUrl, config) { - // Check if the service worker can be found. If it can't reload the page. - fetch(swUrl, { - headers: { 'Service-Worker': 'script' }, - }) - .then(response => { - // Ensure service worker exists, and that we really are getting a JS file. - const contentType = response.headers.get('content-type'); - if ( - response.status === 404 || - (contentType != null && contentType.indexOf('javascript') === -1) - ) { - // No service worker found. Probably a different app. Reload the page. - navigator.serviceWorker.ready.then(registration => { - registration.unregister().then(() => { - window.location.reload(); - }); - }); - } else { - // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); - } - }) - .catch(() => { - console.log( - 'No internet connection found. App is running in offline mode.' - ); - }); -} - -export function unregister() { - if ('serviceWorker' in navigator) { - navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); - } -} diff --git a/admin/src/setupTests.js b/admin/src/setupTests.js deleted file mode 100644 index 35417dc..0000000 --- a/admin/src/setupTests.js +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom/extend-expect'; diff --git a/frontend/README.md b/frontend/README.md deleted file mode 100644 index d85e9e3..0000000 --- a/frontend/README.md +++ /dev/null @@ -1,68 +0,0 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app), using the [Redux](https://redux.js.org/) and [Redux Toolkit](https://redux-toolkit.js.org/) template. - -## Available Scripts - -In the project directory, you can run: - -### `yarn start` - -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -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. - -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. - -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. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `yarn build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify diff --git a/frontend/env-example b/frontend/env-example index 5569321..c98b592 100644 --- a/frontend/env-example +++ b/frontend/env-example @@ -3,7 +3,4 @@ REACT_APP_FRONTEND_SERVER=https://openmhz.com REACT_APP_SOCKET_SERVER=wss://api.openmhz.com REACT_APP_SITE_NAME=OpenMHz REACT_APP_ARCHIVE_DAYS=30 -REACT_APP_PRO_PLAN=1 -REACT_APP_FREE_PLAN=0 -REACT_APP_PRO_PLAN_ARCHIVE=30 -REACT_APP_FREE_PLAN_ARCHIVE=7 + diff --git a/frontend/src/index.css b/frontend/src/index.css deleted file mode 100644 index bd5bd6d..0000000 --- a/frontend/src/index.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/frontend/src/logo.svg b/frontend/src/logo.svg deleted file mode 100644 index 9e96334..0000000 --- a/frontend/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/frontend/src/serviceWorker.js b/frontend/src/serviceWorker.js deleted file mode 100644 index dbd1383..0000000 --- a/frontend/src/serviceWorker.js +++ /dev/null @@ -1,137 +0,0 @@ -// This optional code is used to register a service worker. -// register() is not called by default. - -// This lets the app load faster on subsequent visits in production, and gives -// it offline capabilities. However, it also means that developers (and users) -// will only see deployed updates on subsequent visits to a page, after all the -// existing tabs open on the page have been closed, since previously cached -// resources are updated in the background. - -// To learn more about the benefits of this model and instructions on how to -// opt-in, read https://bit.ly/CRA-PWA - -const isLocalhost = Boolean( - window.location.hostname === 'localhost' || - // [::1] is the IPv6 localhost address. - window.location.hostname === '[::1]' || - // 127.0.0.0/8 are considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); - -export function register(config) { - if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { - // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); - if (publicUrl.origin !== window.location.origin) { - // Our service worker won't work if PUBLIC_URL is on a different origin - // from what our page is served on. This might happen if a CDN is used to - // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; - } - - window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; - - if (isLocalhost) { - // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); - - // Add some additional logging to localhost, pointing developers to the - // service worker/PWA documentation. - navigator.serviceWorker.ready.then(() => { - console.log( - 'This web app is being served cache-first by a service ' + - 'worker. To learn more, visit https://bit.ly/CRA-PWA' - ); - }); - } else { - // Is not localhost. Just register service worker - registerValidSW(swUrl, config); - } - }); - } -} - -function registerValidSW(swUrl, config) { - navigator.serviceWorker - .register(swUrl) - .then(registration => { - registration.onupdatefound = () => { - const installingWorker = registration.installing; - if (installingWorker == null) { - return; - } - installingWorker.onstatechange = () => { - if (installingWorker.state === 'installed') { - if (navigator.serviceWorker.controller) { - // At this point, the updated precached content has been fetched, - // but the previous service worker will still serve the older - // content until all client tabs are closed. - console.log( - 'New content is available and will be used when all ' + - 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' - ); - - // Execute callback - if (config && config.onUpdate) { - config.onUpdate(registration); - } - } else { - // At this point, everything has been precached. - // It's the perfect time to display a - // "Content is cached for offline use." message. - console.log('Content is cached for offline use.'); - - // Execute callback - if (config && config.onSuccess) { - config.onSuccess(registration); - } - } - } - }; - }; - }) - .catch(error => { - console.error('Error during service worker registration:', error); - }); -} - -function checkValidServiceWorker(swUrl, config) { - // Check if the service worker can be found. If it can't reload the page. - fetch(swUrl, { - headers: { 'Service-Worker': 'script' }, - }) - .then(response => { - // Ensure service worker exists, and that we really are getting a JS file. - const contentType = response.headers.get('content-type'); - if ( - response.status === 404 || - (contentType != null && contentType.indexOf('javascript') === -1) - ) { - // No service worker found. Probably a different app. Reload the page. - navigator.serviceWorker.ready.then(registration => { - registration.unregister().then(() => { - window.location.reload(); - }); - }); - } else { - // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); - } - }) - .catch(() => { - console.log( - 'No internet connection found. App is running in offline mode.' - ); - }); -} - -export function unregister() { - if ('serviceWorker' in navigator) { - navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); - } -} diff --git a/frontend/src/setupTests.js b/frontend/src/setupTests.js deleted file mode 100644 index 35417dc..0000000 --- a/frontend/src/setupTests.js +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom/extend-expect';