diff --git a/app/package.json b/app/package.json index 6504e15..fd6f098 100644 --- a/app/package.json +++ b/app/package.json @@ -28,9 +28,13 @@ "@persea/core": "^1.0.0", "@persea/json": "^1.0.0", "autoprefixer": "^9.8.6", + "connected-react-router": "^6.8.0", "dotenv": "8.2.0", "electron": "^11.2.0", - "react-hot-loader": "4.13.0" + "history": "^4.7.2", + "react-hot-loader": "4.13.0", + "react-router": "^5.2.0", + "react-router-dom": "^5.2.0" }, "devDependencies": { "@neutrinojs/airbnb": "^9.4.0", diff --git a/app/src/react/components/dashboard/index.jsx b/app/src/react/components/dashboard/index.jsx new file mode 100644 index 0000000..693eaa5 --- /dev/null +++ b/app/src/react/components/dashboard/index.jsx @@ -0,0 +1,14 @@ +import './index.scss'; + +import {React} from '@latus/react'; + +const Dashboard = () => ( +
+

Dashboard

+

Sup ;p

+
+); + +Dashboard.propTypes = {}; + +export default Dashboard; diff --git a/app/src/react/components/dashboard/index.scss b/app/src/react/components/dashboard/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/src/react/components/persea/index.jsx b/app/src/react/components/persea/index.jsx new file mode 100644 index 0000000..01f927b --- /dev/null +++ b/app/src/react/components/persea/index.jsx @@ -0,0 +1,39 @@ +import './index.scss'; + +import {PropTypes, React} from '@latus/react'; +import Login from '@latus/user/client/components/login'; +import {useSelector} from '@latus/redux'; +import {userIdSelector} from '@persea/core'; +import {ConnectedRouter} from 'connected-react-router'; +import {hot} from 'react-hot-loader'; +import { + Redirect, + Route, + Switch, +} from 'react-router-dom'; + +import Dashboard from 'components/dashboard'; + +const Persea = ({history}) => { + const isLoggedIn = useSelector(userIdSelector); + return ( + + + + {isLoggedIn ? : Login} + + + + + + + {!isLoggedIn && } + + ); +}; + +Persea.propTypes = { + history: PropTypes.shape({}).isRequired, +}; + +export default hot(module)(Persea); diff --git a/app/src/react/components/persea/index.scss b/app/src/react/components/persea/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/src/react/fonts/Lato-Light.eot b/app/src/react/fonts/Lato-Light.eot new file mode 100644 index 0000000..9d14c9c Binary files /dev/null and b/app/src/react/fonts/Lato-Light.eot differ diff --git a/app/src/react/fonts/Lato-Light.ttf b/app/src/react/fonts/Lato-Light.ttf new file mode 100644 index 0000000..5fa6549 Binary files /dev/null and b/app/src/react/fonts/Lato-Light.ttf differ diff --git a/app/src/react/fonts/Lato-Light.woff b/app/src/react/fonts/Lato-Light.woff new file mode 100644 index 0000000..42ce43c Binary files /dev/null and b/app/src/react/fonts/Lato-Light.woff differ diff --git a/app/src/react/fonts/Lato-Regular.eot b/app/src/react/fonts/Lato-Regular.eot new file mode 100644 index 0000000..f36f480 Binary files /dev/null and b/app/src/react/fonts/Lato-Regular.eot differ diff --git a/app/src/react/fonts/Lato-Regular.ttf b/app/src/react/fonts/Lato-Regular.ttf new file mode 100644 index 0000000..db3c3a5 Binary files /dev/null and b/app/src/react/fonts/Lato-Regular.ttf differ diff --git a/app/src/react/fonts/Lato-Regular.woff b/app/src/react/fonts/Lato-Regular.woff new file mode 100644 index 0000000..52074ee Binary files /dev/null and b/app/src/react/fonts/Lato-Regular.woff differ diff --git a/app/src/react/index.jsx b/app/src/react/index.jsx index acfe148..7a4aaed 100644 --- a/app/src/react/index.jsx +++ b/app/src/react/index.jsx @@ -1,58 +1,25 @@ +import './index.scss'; + import {React} from '@latus/react'; -import {hot} from 'react-hot-loader'; +import {connectRouter, routerMiddleware} from 'connected-react-router'; +import {createBrowserHistory} from 'history'; -import Login from '@latus/user/client/components/login'; -import {useDispatch} from '@latus/redux'; +import Persea from 'components/persea'; -import { - createProject, - createResource, - deleteResource, - renameResource, -} from '@persea/core'; -import {patchJsonResource} from '@persea/json'; +const history = createBrowserHistory(); -const App = () => { - const dispatch = useDispatch(); - dispatch(createProject({tree: {}, uuid: 'foobar'})); - dispatch(createResource({ - data: Buffer.from(JSON.stringify({traits: []})), - project: 'foobar', - uri: '/test.entity.json', - })); - dispatch(patchJsonResource({ - patch: [ - { - op: 'add', - path: '/traits/-', - value: { - type: 'existent', - }, - }, - ], - project: 'foobar', - uri: '/test.entity.json', - })); - dispatch(renameResource({ - project: 'foobar', - from: '/test.entity.json', - to: '/foobar.entity.json', - })); - dispatch(deleteResource({ - project: 'foobar', - uri: '/foobar.entity.json', - })); - return ( -
-

Latus react app

-

Yay, you maaaaade it! :)

- -
- ); -}; +const Index = () => ( + +); export default { hooks: { - '@latus/react/components': () => hot(module)(App), + '@latus/react/components': () => Index, + '@latus/redux/slices': () => ({ + router: connectRouter(history), + }), + '@latus/redux/store': (options) => { + options.middleware.push(routerMiddleware(history)); + }, }, }; diff --git a/app/src/react/index.scss b/app/src/react/index.scss new file mode 100644 index 0000000..eacc18f --- /dev/null +++ b/app/src/react/index.scss @@ -0,0 +1,294 @@ +@import 'scss/colors.scss'; + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +em { + font-style: italic; +} +strong { + font-weight: bold; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +h1 { + font-size: 2em; +} +h2 { + font-size: 1.6em; +} +h3 { + font-size: 1.4em; +} +h4 { + font-size: 1.2em; +} +h5 { + font-size: 1.1em; +} +h6 { + font-size: 1.05em; +} + +* { + box-sizing: border-box; +} +html { + background-color: #212121; + color: #FFFFFF; + --message-font-family: verdana, arial, helvetica, sans-serif; + --title-font-family: LatoLight, Ubuntu, "Droid Sans", sans-serif; + --thick-title-font-family: LatoRegular, Ubuntu, "Droid Sans", sans-serif; +} +body { + scrollbar-width: thin; + scrollbar-color: #777 #333; +} +::-webkit-scrollbar { + width: 12px; + height: 12px; +} +::-webkit-scrollbar-track { + background: #333; +} +::-webkit-scrollbar-thumb { + background-color: #777; + border-radius: 20px; + border: 3px solid #333; +} + +code { + font-family: monospace; +} + +label { + background-color: rgba(255, 255, 255, 0.025); + color: #ffffff; + display: flex; + flex-direction: column; + flex-wrap: wrap; + font-family: var(--thick-title-font-family); + font-size: 1em; + min-height: 3em; + padding: 0.5em 0.5em 0.5em 1em; + user-select: none; + @media(min-width: 20em) { + align-items: center; + flex-direction: row; + justify-content: space-between; + } +} + +label:nth-of-type(2n+1) { + background-color: rgba(0, 0, 0, 0.025); +} + +[contenteditable] { + cursor: text; +} + +a { + color: lighten($color-active, 20%); +} + +input { + background: #333; + border: 1px solid rgba(255, 255, 255, 0.1); + color: #ffffff; + font-size: 0.75em; + padding: 0.5em; +} + +fieldset { + background-color: #151515; + border: 1px solid rgba(255, 255, 255, 0.1); + display: inline-block; + margin: 0 0 1em 0; + padding: 0.5em; + position: relative; + top: -0.5em; + width: 100%; +} + +button, .button { + background-color: rgba(0, 0, 0, 0.65); + border: 1px solid rgba(255, 255, 255, 0.2); + color: #ffffff; + font-size: 100%; + text-decoration: none; + transition: background-color 0.2s; + &:hover { + background-color: rgba(0, 0, 0, 0.85); + } +} + +button, input[type="checkbox"], input[type="checkbox"] + label { + cursor: pointer; +} + +select { + background: #222222; + border: 1px solid rgba(255, 255, 255, 0.1); + color: #ffffff; + cursor: pointer; + font-size: 0.75em; + -moz-appearance: none; + -webkit-appearance: none; + padding: 0.5em; +} + +*:focus { + box-shadow: 0 0 2px 0 $color-active; + outline: none; + z-index: 1; +} + +.react-tabs { + width: 100%; + height: 100%; +} + +.react-tabs__tab-list { + background-color: #272727; + font-family: var(--title-font-family); + font-size: 0.9em; + overflow-x: hidden; + scrollbar-width: thin; + white-space: nowrap; + width: 100%; + &::-webkit-scrollbar { + width: 6px; + height: 6px; + } + &::-webkit-scrollbar-track { + background: #2e1d1d; + } + &::-webkit-scrollbar-thumb { + background-color: #777; + border-radius: 0; + border-width: 1px; + } +} + +.react-tabs__tab { + background-color: #2d2d2d; + color: #aaaaaa; + cursor: pointer; + display: inline-block; + height: 3em; + &:not(:last-of-type) { + border-right: 1px solid #282828; + } + &:hover { + color: #ddd; + } + .wrapper { + align-content: space-between; + align-items: center; + display: flex; + height: 100%; + padding: 0 0.5em; + justify-content: space-evenly; + .text { + height: 1.25em; + padding: 0 0.5em; + } + } + .icon { + padding: 0 0.25em 0 0.5em; + } + .close { + background-color: transparent; + border: none; + color: #999999; + padding: 0.25em; + visibility: hidden; + &:hover { + color: #ffffff; + } + } + &:hover .close { + visibility: visible; + } +} + +.react-tabs__tab--selected[class] { + background-color: #1e1e1e; + color: #ffffff; +} + +.react-tabs__tab-panel { + display: none; + overflow-y: auto; + height: calc(100% - 2.7em); + width: 100%; +} + +.react-tabs__tab-panel--selected { + display: block; +} + +.muted { + color: $color-muted; +} + +@font-face { + font-family: 'LatoLight'; + src: url('./fonts/Lato-Light.eot'); + src: url('./fonts/Lato-Light.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('./fonts/Lato-Light.woff') format('woff'), /* Modern Browsers */ url('./fonts/Lato-Light.ttf') format('truetype'); + font-weight: normal; + text-rendering: optimizeLegibility; +} + +@font-face { + font-family: 'LatoRegular'; + src: url('./fonts/Lato-Regular.eot'); + src: url('./fonts/Lato-Regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('./fonts/Lato-Regular.woff') format('woff'), /* Modern Browsers */ url('./fonts/Lato-Regular.ttf') format('truetype'); + font-weight: normal; + text-rendering: optimizeLegibility; +} + +@font-face { + font-family: "joystix"; + src: + url("/joystix-monospace.ttf") format("truetype") + ; +} diff --git a/app/src/react/scss/colors.scss b/app/src/react/scss/colors.scss new file mode 100644 index 0000000..5a732d9 --- /dev/null +++ b/app/src/react/scss/colors.scss @@ -0,0 +1,4 @@ +$color-active: rgb(0, 99, 112); +$color-muted: #bbbbbb; +$color-owner: #d65130; +$color-unread: rgb(180, 0, 0); diff --git a/app/src/react/scss/graphics.scss b/app/src/react/scss/graphics.scss new file mode 100644 index 0000000..5e95f35 --- /dev/null +++ b/app/src/react/scss/graphics.scss @@ -0,0 +1,8 @@ +@mixin shadow-border($size, $color, $radius: $size) { + box-shadow: + -#{$size} -#{$size} $radius $color, + $size $size $radius $color, + -#{$size} $size $radius $color, + $size -#{$size} $radius $color + ; +} diff --git a/app/yarn.lock b/app/yarn.lock index 3bc8e22..d179e22 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -862,7 +862,7 @@ core-js-pure "^3.0.0" regenerator-runtime "^0.13.4" -"@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7": +"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7": version "7.12.5" resolved "http://npm.cha0sdev/@babel%2fruntime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== @@ -2729,6 +2729,13 @@ connect-redis@^5.0.0: resolved "http://npm.cha0sdev/connect-redis/-/connect-redis-5.0.0.tgz#68fe890117e761ee98e13a14b835338bd6bf044c" integrity sha512-R4nTW5uXeG5s6zr/q4abmtcdloglZrL/A3cpa0JU0RLFJU4mTR553HUY8OZ0ngeySkGDclwQ5xmCcjjKkxdOSg== +connected-react-router@^6.8.0: + version "6.8.0" + resolved "http://npm.cha0sdev/connected-react-router/-/connected-react-router-6.8.0.tgz#ddc687b31d498322445d235d660798489fa56cae" + integrity sha512-E64/6krdJM3Ag3MMmh2nKPtMbH15s3JQDuaYJvOVXzu6MbHbDyIvuwLOyhQIuP4Om9zqEfZYiVyflROibSsONg== + dependencies: + prop-types "^15.7.2" + console-browserify@^1.1.0: version "1.2.0" resolved "http://npm.cha0sdev/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336" @@ -4727,6 +4734,18 @@ he@1.2.0, he@1.2.x, he@^1.2.0: resolved "http://npm.cha0sdev/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== +history@^4.7.2, history@^4.9.0: + version "4.10.1" + resolved "http://npm.cha0sdev/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3" + integrity sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew== + dependencies: + "@babel/runtime" "^7.1.2" + loose-envify "^1.2.0" + resolve-pathname "^3.0.0" + tiny-invariant "^1.0.2" + tiny-warning "^1.0.0" + value-equal "^1.0.1" + hmac-drbg@^1.0.0: version "1.0.1" resolved "http://npm.cha0sdev/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -5380,6 +5399,11 @@ is-wsl@^1.1.0: resolved "http://npm.cha0sdev/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= +isarray@0.0.1: + version "0.0.1" + resolved "http://npm.cha0sdev/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= + isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "http://npm.cha0sdev/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -5749,7 +5773,7 @@ long@^4.0.0: resolved "http://npm.cha0sdev/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== -loose-envify@^1.1.0, loose-envify@^1.4.0: +loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0: version "1.4.0" resolved "http://npm.cha0sdev/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== @@ -6001,6 +6025,14 @@ min-document@^2.19.0: dependencies: dom-walk "^0.1.0" +mini-create-react-context@^0.4.0: + version "0.4.1" + resolved "http://npm.cha0sdev/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz#072171561bfdc922da08a60c2197a497cc2d1d5e" + integrity sha512-YWCYEmd5CQeHGSAKrYvXgmzzkrvssZcuuQDDeqkT+PziKGMgE+0MCCtcKbROzocGBG1meBLl2FotlRwf4gAzbQ== + dependencies: + "@babel/runtime" "^7.12.1" + tiny-warning "^1.0.3" + mini-css-extract-plugin@^0.12.0: version "0.12.0" resolved "http://npm.cha0sdev/mini-css-extract-plugin/-/mini-css-extract-plugin-0.12.0.tgz#ddeb74fd6304ca9f99c1db74acc7d5b507705454" @@ -6997,6 +7029,13 @@ path-to-regexp@0.1.7: resolved "http://npm.cha0sdev/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= +path-to-regexp@^1.7.0: + version "1.8.0" + resolved "http://npm.cha0sdev/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a" + integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA== + dependencies: + isarray "0.0.1" + path-type@^1.0.0: version "1.1.0" resolved "http://npm.cha0sdev/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" @@ -7477,7 +7516,7 @@ react-hot-loader@4.13.0, react-hot-loader@^4.13.0: shallowequal "^1.1.0" source-map "^0.7.3" -react-is@^16.13.1, react-is@^16.7.0, react-is@^16.8.1: +react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1: version "16.13.1" resolved "http://npm.cha0sdev/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== @@ -7498,6 +7537,35 @@ react-redux@^7.2.2: prop-types "^15.7.2" react-is "^16.13.1" +react-router-dom@^5.2.0: + version "5.2.0" + resolved "http://npm.cha0sdev/react-router-dom/-/react-router-dom-5.2.0.tgz#9e65a4d0c45e13289e66c7b17c7e175d0ea15662" + integrity sha512-gxAmfylo2QUjcwxI63RhQ5G85Qqt4voZpUXSEqCwykV0baaOTQDR1f0PmY8AELqIyVc0NEZUj0Gov5lNGcXgsA== + dependencies: + "@babel/runtime" "^7.1.2" + history "^4.9.0" + loose-envify "^1.3.1" + prop-types "^15.6.2" + react-router "5.2.0" + tiny-invariant "^1.0.2" + tiny-warning "^1.0.0" + +react-router@5.2.0, react-router@^5.2.0: + version "5.2.0" + resolved "http://npm.cha0sdev/react-router/-/react-router-5.2.0.tgz#424e75641ca8747fbf76e5ecca69781aa37ea293" + integrity sha512-smz1DUuFHRKdcJC0jobGo8cVbhO3x50tCL4icacOlcwDOEQPq4TMqwx3sY1TP+DvtTgz4nm3thuo7A+BK2U0Dw== + dependencies: + "@babel/runtime" "^7.1.2" + history "^4.9.0" + hoist-non-react-statics "^3.1.0" + loose-envify "^1.3.1" + mini-create-react-context "^0.4.0" + path-to-regexp "^1.7.0" + prop-types "^15.6.2" + react-is "^16.6.0" + tiny-invariant "^1.0.2" + tiny-warning "^1.0.0" + react-sortable-tree@^2.8.0: version "2.8.0" resolved "http://npm.cha0sdev/react-sortable-tree/-/react-sortable-tree-2.8.0.tgz#9901711778628d0546c045f845216480507c366a" @@ -7872,6 +7940,11 @@ resolve-from@^4.0.0: resolved "http://npm.cha0sdev/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== +resolve-pathname@^3.0.0: + version "3.0.0" + resolved "http://npm.cha0sdev/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd" + integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng== + resolve-url@^0.2.1: version "0.2.1" resolved "http://npm.cha0sdev/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -8938,6 +9011,16 @@ timers-browserify@^2.0.4: dependencies: setimmediate "^1.0.4" +tiny-invariant@^1.0.2: + version "1.1.0" + resolved "http://npm.cha0sdev/tiny-invariant/-/tiny-invariant-1.1.0.tgz#634c5f8efdc27714b7f386c35e6760991d230875" + integrity sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw== + +tiny-warning@^1.0.0, tiny-warning@^1.0.3: + version "1.0.3" + resolved "http://npm.cha0sdev/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" + integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA== + tmp@^0.0.33: version "0.0.33" resolved "http://npm.cha0sdev/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -9330,6 +9413,11 @@ validator@^10.11.0: resolved "http://npm.cha0sdev/validator/-/validator-10.11.0.tgz#003108ea6e9a9874d31ccc9e5006856ccd76b228" integrity sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw== +value-equal@^1.0.1: + version "1.0.1" + resolved "http://npm.cha0sdev/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c" + integrity sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw== + vary@^1, vary@~1.1.2: version "1.1.2" resolved "http://npm.cha0sdev/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" diff --git a/packages/core/src/index.js b/packages/core/src/index.js index fa2ce18..23c80e7 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -1,4 +1,4 @@ -import {projects} from './state'; +import {projects, user} from './state'; export * from './state'; @@ -6,6 +6,7 @@ export default { hooks: { '@latus/redux/slices': () => ({ projects, + user, }), }, }; diff --git a/packages/core/src/server/index.js b/packages/core/src/server/index.js index 56f4b5d..377f2d4 100644 --- a/packages/core/src/server/index.js +++ b/packages/core/src/server/index.js @@ -52,6 +52,11 @@ export default { projects, resources, }, + user: { + id: req + ? req.user.id + : 0, + }, }; }, }, diff --git a/packages/core/src/state/index.js b/packages/core/src/state/index.js index 7d747f8..5f1eaaf 100644 --- a/packages/core/src/state/index.js +++ b/packages/core/src/state/index.js @@ -1,2 +1,4 @@ export * from './projects'; export {default as projects} from './projects'; +export * from './user'; +export {default as user} from './user'; diff --git a/packages/core/src/state/user.js b/packages/core/src/state/user.js new file mode 100644 index 0000000..7763174 --- /dev/null +++ b/packages/core/src/state/user.js @@ -0,0 +1,25 @@ +import { + createSlice, +} from '@latus/redux'; + +export const userSelector = ({user}) => user; + +export const userIdSelector = ({user}) => user.id; + +const slice = createSlice({ + name: 'persea/user', + initialState: { + id: 0, + }, + /* eslint-disable no-param-reassign */ + reducers: { + }, + extraReducers: { + }, + /* eslint-enable no-param-reassign */ +}); + +// export const { +// } = slice.actions; + +export default slice.reducer;