Redux / React -> implement redux localstorage

feature/2_forms
TBS093A 2021-02-17 15:29:24 +01:00
parent f5747c51b0
commit 77a6fd801e
11 changed files with 35 additions and 209 deletions

View File

@ -1,54 +0,0 @@
import * as React from "react"
import { Link } from "gatsby"
// styles
const pageStyles = {
color: "#232129",
padding: "96px",
fontFamily: "-apple-system, Roboto, sans-serif, serif",
}
const headingStyles = {
marginTop: 0,
marginBottom: 64,
maxWidth: 320,
}
const paragraphStyles = {
marginBottom: 48,
}
const codeStyles = {
color: "#8A6534",
padding: 4,
backgroundColor: "#FFF4DB",
fontSize: "1.25rem",
borderRadius: 4,
}
// markup
const NotFoundPage = () => {
return (
<main style={pageStyles}>
<title>Not found</title>
<h1 style={headingStyles}>Page not found</h1>
<p style={paragraphStyles}>
Sorry{" "}
<span role="img" aria-label="Pensive emoji">
😔
</span>{" "}
we couldnt find what you were looking for.
<br />
{process.env.NODE_ENV === "development" ? (
<>
<br />
Try creating a page in <code style={codeStyles}>src/pages/</code>.
<br />
</>
) : null}
<br />
<Link to="/">Go home</Link>.
</p>
</main>
)
}
export default NotFoundPage

View File

@ -0,0 +1,10 @@
import * as React from 'react'
const Root = () => {
return (
<>
</>
)
}
export default Root

View File

@ -1,150 +1,20 @@
import * as React from "react" import React from 'react';
// import ReactDOM from 'react-dom';
// styles import { Provider } from 'react-redux';
const pageStyles = { import { store } from '../redux/store';
color: "#232129",
padding: "96px",
fontFamily: "-apple-system, Roboto, sans-serif, serif",
}
const headingStyles = {
marginTop: 0,
marginBottom: 64,
maxWidth: 320,
}
const headingAccentStyles = {
color: "#663399",
}
const paragraphStyles = {
marginBottom: 48,
}
const codeStyles = {
color: "#8A6534",
padding: 4,
backgroundColor: "#FFF4DB",
fontSize: "1.25rem",
borderRadius: 4,
}
const listStyles = {
marginBottom: 96,
paddingLeft: 0,
}
const listItemStyles = {
fontWeight: "300",
fontSize: "24px",
maxWidth: "560px",
}
const linkStyle = { import Root from './func_group/root';
color: "#8954A8",
fontWeight: "bold",
fontSize: "16px",
verticalAlign: "5%",
}
const docLinkStyle = { // if you have problem with watchers - use it:
...linkStyle, // echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
listStyleType: "none",
marginBottom: 24,
}
const descriptionStyle = { const Index = () => {
color: "#232129",
fontSize: "14px",
}
const docLink = {
text: "Documentation",
url: "https://www.gatsbyjs.com/docs/",
color: "#8954A8",
}
// data
const links = [
{
text: "Tutorial",
url: "https://www.gatsbyjs.com/docs/tutorial/",
description:
"A great place to get started if you're new to web development. Designed to guide you through setting up your first Gatsby site.",
color: "#E95800",
},
{
text: "How to Guides",
url: "https://www.gatsbyjs.com/docs/how-to/",
description:
"Practical step-by-step guides to help you achieve a specific goal. Most useful when you're trying to get something done.",
color: "#1099A8",
},
{
text: "Reference Guides",
url: "https://www.gatsbyjs.com/docs/reference/",
description:
"Nitty-gritty technical descriptions of how Gatsby works. Most useful when you need detailed information about Gatsby's APIs.",
color: "#BC027F",
},
{
text: "Conceptual Guides",
url: "https://www.gatsbyjs.com/docs/conceptual/",
description:
"Big-picture explanations of higher-level Gatsby concepts. Most useful for building understanding of a particular topic.",
color: "#0D96F2",
},
{
text: "Plugin Library",
url: "https://www.gatsbyjs.com/plugins",
description:
"Add functionality and customize your Gatsby site or app with thousands of plugins built by our amazing developer community.",
color: "#000000",
},
]
// markup
const IndexPage = () => {
return ( return (
<main style={pageStyles}> <Provider store={store}>
<title>Home Page</title> <Root />
<h1 style={headingStyles}> </Provider>
Congratulations
<br />
<span style={headingAccentStyles}> you just made a Gatsby site! </span>
<span role="img" aria-label="Party popper emojis">
🎉🎉🎉
</span>
</h1>
<p style={paragraphStyles}>
Edit <code style={codeStyles}>src/pages/index.js</code> to see this page
update in real-time.{" "}
<span role="img" aria-label="Sunglasses smiley emoji">
😎
</span>
</p>
<ul style={listStyles}>
<li style={docLinkStyle}>
<a
style={linkStyle}
href={`${docLink.url}?utm_source=starter&utm_medium=start-page&utm_campaign=minimal-starter`}
>
{docLink.text}
</a>
</li>
{links.map(link => (
<li key={link.url} style={{ ...listItemStyles, color: link.color }}>
<span>
<a
style={linkStyle}
href={`${link.url}?utm_source=starter&utm_medium=start-page&utm_campaign=minimal-starter`}
>
{link.text}
</a>
<p style={descriptionStyle}>{link.description}</p>
</span>
</li>
))}
</ul>
<img
alt="Gatsby G Logo"
src="data:image/svg+xml,%3Csvg width='24' height='24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2a10 10 0 110 20 10 10 0 010-20zm0 2c-3.73 0-6.86 2.55-7.75 6L14 19.75c3.45-.89 6-4.02 6-7.75h-5.25v1.5h3.45a6.37 6.37 0 01-3.89 4.44L6.06 9.69C7 7.31 9.3 5.63 12 5.63c2.13 0 4 1.04 5.18 2.65l1.23-1.06A7.959 7.959 0 0012 4zm-8 8a8 8 0 008 8c.04 0 .09 0-8-8z' fill='%23639'/%3E%3C/svg%3E"
/>
</main>
) )
} }
export default IndexPage export default Index

View File

@ -1,5 +1,5 @@
import { createAsyncThunk } from '@reduxjs/toolkit' import { createAsyncThunk } from '@reduxjs/toolkit'
import abstractService from './abstractService' import abstractService from './abstracts/abstractService'
let endpoint = '/model/' let endpoint = '/model/'
@ -26,7 +26,7 @@ const fetchGetOneModelAndDownload = createAsyncThunk(
thunkAPI thunkAPI
) => { ) => {
return await abstractService._getOne( return await abstractService._getOne(
trueEndpoint, endpoint,
body.id, body.id,
body.token body.token
) )
@ -49,7 +49,7 @@ const fetchUploadModel = createAsyncThunk(
formData.append("blend", body.file) formData.append("blend", body.file)
body.file = formData body.file = formData
return await abstractService._post( return await abstractService._post(
trueEndpoint, endpoint,
body, body,
body.token body.token
) )

View File

@ -1,5 +1,5 @@
import { createAsyncThunk } from '@reduxjs/toolkit' import { createAsyncThunk } from '@reduxjs/toolkit'
import abstractService from './abstractService' import abstractService from './abstracts/abstractService'
let endpoint = '/render/' let endpoint = '/render/'
@ -26,7 +26,7 @@ const fetchGetOneRenderAndDownload = createAsyncThunk(
thunkAPI thunkAPI
) => { ) => {
return await abstractService._getOne( return await abstractService._getOne(
trueEndpoint, endpoint,
body.id, body.id,
body.token body.token
) )

View File

@ -1,5 +1,5 @@
import { createAsyncThunk } from '@reduxjs/toolkit' import { createAsyncThunk } from '@reduxjs/toolkit'
import GeneralAddress from './abstractAddress' import GeneralAddress from './abstracts/abstractAddress'
let endpoint_single_image = '/render/single/image/' let endpoint_single_image = '/render/single/image/'
let endpoint_single_set = '/render/single/set/' let endpoint_single_set = '/render/single/set/'
@ -109,5 +109,5 @@ const fetchDisconnect = createAsyncThunk(
export default { export default {
fetchConnect, fetchConnect,
fetchSaveMessage, fetchSaveMessage,
fetchDisconnect, fetchDisconnect
} }

View File

@ -1,5 +1,5 @@
import { createAsyncThunk } from '@reduxjs/toolkit' import { createAsyncThunk } from '@reduxjs/toolkit'
import abstractService from './abstractService' import abstractService from './abstracts/abstractService'
let endpoint = '/user/auth' let endpoint = '/user/auth'

View File

@ -1,5 +1,5 @@
import { createAsyncThunk } from '@reduxjs/toolkit' import { createAsyncThunk } from '@reduxjs/toolkit'
import abstractService from './abstractService' import abstractService from './abstracts/abstractService'
let endpoint = '/user/' let endpoint = '/user/'

View File

@ -27,10 +27,10 @@ const renderWebsocketSlice = createSlice(
] ]
}, },
[renderWebsocketAsyncThunk.fetchDisconnect.fulfilled.type]: (state, action) => { [renderWebsocketAsyncThunk.fetchDisconnect.fulfilled.type]: (state, action) => {
state.web_socket = action.web_socket, state.web_socket = action.web_socket
state.address = '', state.address = ''
state.room_uuid = '', state.room_uuid = ''
state.messages = [], state.messages = []
state.connected = false state.connected = false
} }
} }