diff --git a/webclient/package.json b/webclient/package.json index 57e544c..3440d6b 100644 --- a/webclient/package.json +++ b/webclient/package.json @@ -8,7 +8,8 @@ "@testing-library/user-event": "^7.1.2", "react": "^16.12.0", "react-dom": "^16.12.0", - "react-scripts": "3.3.0" + "react-scripts": "3.3.0", + "semantic-ui-react": "^0.88.2" }, "scripts": { "start": "react-scripts start", diff --git a/webclient/public/.index.html.swp b/webclient/public/.index.html.swp new file mode 100644 index 0000000..6b3fce6 Binary files /dev/null and b/webclient/public/.index.html.swp differ diff --git a/webclient/public/index.html b/webclient/public/index.html index 867f58e..093148b 100644 --- a/webclient/public/index.html +++ b/webclient/public/index.html @@ -25,6 +25,8 @@ Learn how to configure a non-root public URL by running `npm run build`. --> React App + + diff --git a/webclient/src/.App.js.swp b/webclient/src/.App.js.swp new file mode 100644 index 0000000..5160013 Binary files /dev/null and b/webclient/src/.App.js.swp differ diff --git a/webclient/src/.light.css.swp b/webclient/src/.light.css.swp new file mode 100644 index 0000000..a783329 Binary files /dev/null and b/webclient/src/.light.css.swp differ diff --git a/webclient/src/.utils.js.swp b/webclient/src/.utils.js.swp new file mode 100644 index 0000000..34c071c Binary files /dev/null and b/webclient/src/.utils.js.swp differ diff --git a/webclient/src/App.js b/webclient/src/App.js index 7330c68..a4f3e0a 100644 --- a/webclient/src/App.js +++ b/webclient/src/App.js @@ -1,11 +1,142 @@ -import React from 'react'; +import React, { useState } from 'react'; +import './light.css'; +import Logo from './logo.svg'; +import { Container, Divider, Form, Grid, Header, Menu, Message } from 'semantic-ui-react'; +import { requester } from './utils.js'; + +function LoginForm() { + const [input, setInput] = useState({}) + const [error, setError] = useState({}) + + const handleChange = (e) => setInput({ + ...input, + [e.currentTarget.name]: e.currentTarget.value + }); + + const handleSubmit = (e) => { + requester('/rest-auth/login/', 'POST', input) + .then(res => { + console.log(res); + setError({}); + }) + .catch(err => { + console.log(err); + setError(err.data); + }); + }; + + return ( +
+ + + + Login + + + ); +} + +function SignupForm() { + const [input, setInput] = useState({}) + + const handleChange = (e) => setInput({ + ...input, + [e.currentTarget.name]: e.currentTarget.value + }); + + const handleSubmit = (e) => { + console.log(input); + } + + return ( +
+ + + + + + + + + Sign Up + + ); +} function App() { return (
-
- Hello world -
+ +
+ +
+
+ + + + + + + + + + + + +
Login to Spaceport
+ + + + Or + +
Sign Up
+ +
+ +

two

+
+
+
); } diff --git a/webclient/src/light.css b/webclient/src/light.css new file mode 100644 index 0000000..3ca0042 --- /dev/null +++ b/webclient/src/light.css @@ -0,0 +1,5 @@ +.header .logo { + max-width: 100%; + display: block; + margin: 1.5rem auto; +} diff --git a/webclient/src/logo.svg b/webclient/src/logo.svg new file mode 100644 index 0000000..a7340f3 --- /dev/null +++ b/webclient/src/logo.svg @@ -0,0 +1,147 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webclient/src/utils.js b/webclient/src/utils.js new file mode 100644 index 0000000..7df3474 --- /dev/null +++ b/webclient/src/utils.js @@ -0,0 +1,56 @@ +var siteUrl, apiUrl; + +if (process.env.NODE_ENV !== 'production') { + siteUrl = 'http://spaceport.dns.t0.vc'; + apiUrl = 'http://spaceport-api.dns.t0.vc'; +} else { + siteUrl = 'https://' + window.location.hostname; + apiUrl = 'https://api.' + window.location.hostname; +} + +export const requester = (route, method, data) => { + var options; + + if (method == 'GET') { + options = {}; + } else if (method == 'POST') { + const formData = new FormData(); + Object.keys(data).forEach(key => + formData.append(key, data[key]) + ); + + options = { + method: 'POST', + body: formData, + }; + } else { + return 'Method not supported'; + } + + const customError = (data) => { + const error = new Error(JSON.stringify(data)); + error.data = data; + return error; + } + + return fetch(apiUrl + route, options) + .then(response => { + if (!response.ok) { + throw customError(response); + } + return response.json(); + }) + .catch(error => { + const code = error.data.status; + if (code == 413) { + throw customError({non_field_errors: ['File too big']}); + } else if (code == 400) { + return error.data.json() + .then(result => { + throw customError(result); + }); + } else { + throw customError({non_field_errors: ['Network Error']}); + } + }); +} diff --git a/webclient/yarn.lock b/webclient/yarn.lock index c1b0060..9a43703 100644 --- a/webclient/yarn.lock +++ b/webclient/yarn.lock @@ -828,7 +828,7 @@ dependencies: regenerator-runtime "^0.13.2" -"@babel/runtime@^7.5.1", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6": +"@babel/runtime@^7.1.2", "@babel/runtime@^7.5.1", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6": version "7.7.7" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.7.tgz#194769ca8d6d7790ec23605af9ee3e42a0aa79cf" integrity sha512-uCnC2JEVAu8AKB5do1WRIsvrdJ0flYx/A/9f/6chdacnEZ7LmavjdsDXr5ksYBegxtuTPR5Va9/+13QF/kFkCA== @@ -1079,11 +1079,36 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== +"@semantic-ui-react/event-stack@^3.1.0": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@semantic-ui-react/event-stack/-/event-stack-3.1.1.tgz#3263d17511db81a743167fe45281a24b3eb6b3c8" + integrity sha512-SA7VOu/tY3OkooR++mm9voeQrJpYXjJaMHO1aFCcSouS2xhqMR9Gnz0LEGLOR0h9ueWPBKaQzKIrx3FTTJZmUQ== + dependencies: + exenv "^1.2.2" + prop-types "^15.6.2" + "@sheerun/mutationobserver-shim@^0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz#8013f2af54a2b7d735f71560ff360d3a8176a87b" integrity sha512-vTCdPp/T/Q3oSqwHmZ5Kpa9oI7iLtGl3RQaA/NyLHikvcrPxACkkKVr/XzkSPJWXHRhKGzVvb0urJsbMlRxi1Q== +"@stardust-ui/react-component-event-listener@~0.38.0": + version "0.38.0" + resolved "https://registry.yarnpkg.com/@stardust-ui/react-component-event-listener/-/react-component-event-listener-0.38.0.tgz#1787faded94b40ad41226e6289baf13e701c6e7f" + integrity sha512-sIP/e0dyOrrlb8K7KWumfMxj/gAifswTBC4o68Aa+C/GA73ccRp/6W1VlHvF/dlOR4KLsA+5SKnhjH36xzPsWg== + dependencies: + "@babel/runtime" "^7.1.2" + prop-types "^15.7.2" + +"@stardust-ui/react-component-ref@~0.38.0": + version "0.38.0" + resolved "https://registry.yarnpkg.com/@stardust-ui/react-component-ref/-/react-component-ref-0.38.0.tgz#52d555f2d5edd213c923c93a106f7de940e427ef" + integrity sha512-xjs6WnvJVueSIXMWw0C3oWIgAPpcD03qw43oGOjUXqFktvpNkB73JoKIhS4sCrtQxBdct75qqr4ZL6JiyPcESw== + dependencies: + "@babel/runtime" "^7.1.2" + prop-types "^15.7.2" + react-is "^16.6.3" + "@svgr/babel-plugin-add-jsx-attribute@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz#dadcb6218503532d6884b210e7f3c502caaa44b1" @@ -2573,6 +2598,11 @@ class-utils@^0.3.5: isobject "^3.0.0" static-extend "^0.1.1" +classnames@^2.2.6: + version "2.2.6" + resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce" + integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q== + clean-css@4.2.x: version "4.2.1" resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17" @@ -2942,6 +2972,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" +create-react-context@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.3.0.tgz#546dede9dc422def0d3fc2fe03afe0bc0f4f7d8c" + integrity sha512-dNldIoSuNSvlTJ7slIKC/ZFGKexBMBrrcc+TTe1NdmROnaASuLPvqpwj9v4XS4uXZ8+YPu0sNmShX2rXI5LNsw== + dependencies: + gud "^1.0.0" + warning "^4.0.3" + cross-spawn@6.0.5, cross-spawn@^6.0.0, cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -3258,7 +3296,7 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -deep-equal@^1.0.1: +deep-equal@^1.0.1, deep-equal@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" integrity sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g== @@ -3961,6 +3999,11 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +exenv@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/exenv/-/exenv-1.2.2.tgz#2ae78e85d9894158670b03d47bec1f03bd91bb9d" + integrity sha1-KueOhdmJQVhnCwPUe+wfA72Ru50= + exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -4579,6 +4622,11 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= +gud@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0" + integrity sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw== + gzip-size@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-5.1.1.tgz#cb9bee692f87c0612b232840a873904e4c135274" @@ -5997,6 +6045,11 @@ jsx-ast-utils@^2.2.1: array-includes "^3.0.3" object.assign "^4.1.0" +keyboard-key@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/keyboard-key/-/keyboard-key-1.0.4.tgz#52d8fa07b7e17757072aa22a67fb4ae85e4c46b0" + integrity sha512-my04dE6BCwPpwoe4KYKfPxWiwgDYQOHrVmtzn1CfzmoEsGG/ef4oZGaXCzi1+iFhG7CN5JkOuxmei5OABY8/ag== + killable@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892" @@ -7401,6 +7454,11 @@ pnp-webpack-plugin@1.5.0: dependencies: ts-pnp "^1.1.2" +popper.js@^1.14.4: + version "1.16.0" + resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.0.tgz#2e1816bcbbaa518ea6c2e15a466f4cb9c6e2fbb3" + integrity sha512-+G+EkOPoE5S/zChTpmBSSDYmhXJ5PsW8eMhH8cP/CQHMFPBG/kC9Y5IIw6qNYgdJ+/COf0ddY2li28iHaZRSjw== + portfinder@^1.0.25: version "1.0.25" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.25.tgz#254fd337ffba869f4b9d37edc298059cb4d35eca" @@ -8150,7 +8208,7 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.3" -prop-types@^15.6.2, prop-types@^15.7.2: +prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -8371,11 +8429,24 @@ react-error-overlay@^6.0.4: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.4.tgz#0d165d6d27488e660bc08e57bdabaad741366f7a" integrity sha512-ueZzLmHltszTshDMwyfELDq8zOA803wQ1ZuzCccXa1m57k1PxSHfflPD5W9YIiTXLs0JTLzoj6o1LuM5N6zzNA== -react-is@^16.8.1, react-is@^16.8.4: +react-is@^16.6.3, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: version "16.12.0" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c" integrity sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q== +react-popper@^1.3.4: + version "1.3.7" + resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-1.3.7.tgz#f6a3471362ef1f0d10a4963673789de1baca2324" + integrity sha512-nmqYTx7QVjCm3WUZLeuOomna138R1luC4EqkW3hxJUrAe+3eNz3oFCLYdnPwILfn0mX1Ew2c3wctrjlUMYYUww== + dependencies: + "@babel/runtime" "^7.1.2" + create-react-context "^0.3.0" + deep-equal "^1.1.1" + popper.js "^1.14.4" + prop-types "^15.6.1" + typed-styles "^0.0.7" + warning "^4.0.2" + react-scripts@3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-3.3.0.tgz#f26a21f208f20bd04770f43e50b5bbc151920c2a" @@ -8964,6 +9035,23 @@ selfsigned@^1.10.7: dependencies: node-forge "0.9.0" +semantic-ui-react@^0.88.2: + version "0.88.2" + resolved "https://registry.yarnpkg.com/semantic-ui-react/-/semantic-ui-react-0.88.2.tgz#3d4b54f8b799769b412435c8531475fd34aa4149" + integrity sha512-+02kN2z8PuA/cMdvDUsHhbJmBzxxgOXVHMFr9XK7zGb0wkW9A6OPQMFokWz7ozlVtKjN6r7zsb+Qvjk/qq1OWw== + dependencies: + "@babel/runtime" "^7.1.2" + "@semantic-ui-react/event-stack" "^3.1.0" + "@stardust-ui/react-component-event-listener" "~0.38.0" + "@stardust-ui/react-component-ref" "~0.38.0" + classnames "^2.2.6" + keyboard-key "^1.0.4" + lodash "^4.17.15" + prop-types "^15.7.2" + react-is "^16.8.6" + react-popper "^1.3.4" + shallowequal "^1.1.0" + "semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -9081,6 +9169,11 @@ shallow-clone@^3.0.0: dependencies: kind-of "^6.0.2" +shallowequal@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8" + integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ== + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -9869,6 +9962,11 @@ type@^2.0.0: resolved "https://registry.yarnpkg.com/type/-/type-2.0.0.tgz#5f16ff6ef2eb44f260494dae271033b29c09a9c3" integrity sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow== +typed-styles@^0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/typed-styles/-/typed-styles-0.0.7.tgz#93392a008794c4595119ff62dde6809dbc40a3d9" + integrity sha512-pzP0PWoZUhsECYjABgCGQlRGL1n7tOHsgwYv3oIiEpJwGhFTuty/YNeduxQYzXXa3Ge5BdT6sHYIQYpl4uJ+5Q== + typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" @@ -10129,6 +10227,13 @@ walker@^1.0.7, walker@~1.0.5: dependencies: makeerror "1.0.x" +warning@^4.0.2, warning@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3" + integrity sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w== + dependencies: + loose-envify "^1.0.0" + watchpack@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"