removed styled module and fixed account reset and create

This commit is contained in:
balzack 2022-09-12 23:58:17 -07:00
parent 75dbab6778
commit 3611530f11
14 changed files with 84 additions and 21405 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,7 @@
"react-native-sqlite-storage": "^6.0.1",
"react-native-web": "~0.18.7",
"react-router-dom": "6",
"react-router-native": "^6.3.0",
"styled-components": "^5.3.5"
"react-router-native": "^6.3.0"
},
"devDependencies": {
"@babel/core": "^7.12.9"

View File

@ -1,5 +1,5 @@
import { SafeAreaView, View } from 'react-native';
import { Wrapper, Container, PaddedPane, Pane, Splash } from './Access.styled';
import { SafeAreaView, Image, View } from 'react-native';
import { styles } from './Access.styled';
import { useAccess } from './useAccess.hook';
import { Login } from './login/Login';
import { Create } from './create/Create';
@ -11,14 +11,14 @@ export function Access({ mode }) {
const { state, actions } = useAccess();
return (
<Wrapper>
<View style={styles.wrapper}>
<SafeAreaView>
{ state.split === true && (
<Container>
<PaddedPane>
<Splash source={logo} />
</PaddedPane>
<Pane>
<View style={styles.container}>
<View style={styles.paddedPane}>
<Image style={styles.splash} source={logo} />
</View>
<View style={styles.pane}>
{ mode === 'login' && (
<Login />
)}
@ -28,11 +28,11 @@ export function Access({ mode }) {
{ mode === 'reset' && (
<Reset />
)}
</Pane>
</Container>
</View>
</View>
)}
{ state.split === false && (
<Container>
<View style={styles.container}>
{ mode === 'login' && (
<Login />
)}
@ -42,10 +42,10 @@ export function Access({ mode }) {
{ mode === 'reset' && (
<Reset />
)}
</Container>
</View>
)}
</SafeAreaView>
</Wrapper>
</View>
);
}

View File

@ -1,32 +1,30 @@
import styled from 'styled-components/native';
import { StyleSheet } from 'react-native';
import { Colors } from 'constants/Colors';
export const Wrapper = styled.View`
background-color: ${Colors.background};
width: 100%;
height: 100%;
`
export const Container = styled.View`
padding: 16px;
display: flex;
flex-direction: row;
`
export const Splash = styled.Image`
flex: 1;
width: null;
height: null;
resize-mode: contain;
`
export const Pane = styled.View`
width: 50%;
height: 100%;
`
export const PaddedPane = styled.View`
width: 50%;
height: 100%;
padding-right: 16px;
`
export const styles = StyleSheet.create({
wrapper: {
backgroundColor: Colors.background,
width: '100%',
height: '100%',
},
container: {
padding: 16,
display: 'flex',
flexDirection: 'row',
},
splash: {
flex: 1,
width: null,
height: null,
resizeMode: 'contain',
},
pane: {
width: '50%',
height: '100%',
},
paddedPane: {
width: '50%',
height: '100%',
paddingRight: 16,
},
});

View File

@ -14,7 +14,7 @@ export function Create() {
catch (err) {
Alert.alert(
"Create Failed",
"Please check your username and password.",
"Please check your server and token.",
);
}
}

View File

@ -173,14 +173,14 @@ export function useCreate() {
},
create: async () => {
if (!state.busy) {
updateState({ busy: true });
try {
await app.actions.create(state.login, state.password);
navigate('/');
updateState({ busy: true });
await app.actions.create(state.server, state.username, state.password, state.token);
updateState({ busy: false });
}
catch (err) {
console.log(err);
updateState({ busy: false, showAlert: true });
updateState({ busy: false });
throw new Error('create failed');
}
updateState({ busy: false });

View File

@ -9,11 +9,11 @@ export function Reset() {
const reset = async () => {
try {
await actions.reset();
await actions.access();
}
catch (err) {
Alert.alert(
"Reset Failed",
"Access Failed",
"Please check your server and token.",
);
}

View File

@ -49,17 +49,16 @@ export function useReset() {
},
access: async () => {
if (!state.busy) {
updateState({ busy: true });
try {
await app.actions.login(state.login, state.password);
navigate('/');
updateState({ busy: true });
await app.actions.access(state.server, state.token);
updateState({ busy: false });
}
catch (err) {
console.log(err);
updateState({ busy: false, showAlert: true });
throw new Error('login failed');
updateState({ busy: false });
throw new Error("access failed");
}
updateState({ busy: false });
}
}
};

View File

@ -1,14 +1,14 @@
import { checkResponse, fetchWithCustomTimeout } from './fetchUtil';
import base64 from 'react-native-base64'
export async function addAccount(username, password, token) {
export async function addAccount(server, username, password, token) {
let access = "";
if (token) {
access = `?token=${token}`
}
let headers = new Headers()
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
let profile = await fetchWithCustomTimeout(`/account/profile${access}`, { method: 'POST', headers: headers }, 60000)
let profile = await fetchWithCustomTimeout(`https://${server}/account/profile${access}`, { method: 'POST', headers: headers }, 60000)
checkResponse(profile);
return await profile.json()
}

View File

@ -1,8 +1,8 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setAccountAccess(token) {
export async function setAccountAccess(server, token) {
let app = { Name: "indicom", Description: "decentralized communication" }
let access = await fetchWithTimeout(`/account/access?token=${token}`, { method: 'PUT', body: JSON.stringify(app) })
let access = await fetchWithTimeout(`https://${server}/account/access?token=${token}`, { method: 'PUT', body: JSON.stringify(app) })
checkResponse(access)
return await access.json()
}

View File

@ -29,11 +29,14 @@ export function useAppContext() {
const actions = {
available: getAvailable,
username: getUsername,
create: async (username, password, token) => {
const acc = username.split('@');
await addAccount(acc[0], acc[1], password, token);
const access = await setLogin(acc[0], acc[1], password)
store.actions.setSession({ ...access, server: acc[1] });
create: async (server, username, password, token) => {
await addAccount(server, username, password, token);
const access = await setLogin(username, server, password)
store.actions.setSession({ ...access, server });
},
access: async (server, token) => {
const access = await setAccountAccess(server, token);
store.actions.setSession({ ...access, server });
},
login: async (username, password) => {
const acc = username.split('@');

View File

@ -1,7 +1,8 @@
import { RootWrapper } from './Root.styled';
import { View } from 'react-native';
import { styles } from './Root.styled';
import { useRoot } from './useRoot.hook';
export function Root() {
const root = useRoot();
return <RootWrapper />
return <View style={styles.wrapper} />
}

View File

@ -1,8 +1,10 @@
import styled from 'styled-components/native';
import { StyleSheet } from 'react-native';
import { Colors } from 'constants/Colors';
export const RootWrapper = styled.View`
background-color: ${Colors.background};
width: 100%;
height: 100%;
`
export const styles = StyleSheet.create({
wrapper: {
backgroundColor: Colors.background,
width: '100%',
height: '100%',
}
});

View File

@ -59,7 +59,7 @@
"@jridgewell/gen-mapping" "^0.3.2"
jsesc "^2.5.1"
"@babel/helper-annotate-as-pure@^7.16.0", "@babel/helper-annotate-as-pure@^7.18.6":
"@babel/helper-annotate-as-pure@^7.18.6":
version "7.18.6"
resolved "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz"
integrity sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==
@ -151,7 +151,7 @@
dependencies:
"@babel/types" "^7.18.9"
"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.16.0", "@babel/helper-module-imports@^7.18.6":
"@babel/helper-module-imports@^7.18.6":
version "7.18.6"
resolved "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz"
integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==
@ -1029,7 +1029,7 @@
"@babel/parser" "^7.18.10"
"@babel/types" "^7.18.10"
"@babel/traverse@^7.14.0", "@babel/traverse@^7.18.9", "@babel/traverse@^7.19.0", "@babel/traverse@^7.4.5":
"@babel/traverse@^7.14.0", "@babel/traverse@^7.18.9", "@babel/traverse@^7.19.0":
version "7.19.0"
resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.19.0.tgz"
integrity sha512-4pKpFRDh+utd2mbRC8JLnlsMUii3PMHjpL6a0SZ4NMZy7YFP9aXORxEhdMVOc9CpWtDF09IkciQLEhK7Ml7gRA==
@ -1054,28 +1054,6 @@
"@babel/helper-validator-identifier" "^7.18.6"
to-fast-properties "^2.0.0"
"@emotion/is-prop-valid@^1.1.0":
version "1.2.0"
resolved "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.0.tgz"
integrity sha512-3aDpDprjM0AwaxGE09bOPkNxHpBd+kA6jty3RnaEXdweX1DF1U3VQpPYb0g1IStAuK7SVQ1cy+bNBBKp4W3Fjg==
dependencies:
"@emotion/memoize" "^0.8.0"
"@emotion/memoize@^0.8.0":
version "0.8.0"
resolved "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.0.tgz"
integrity sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==
"@emotion/stylis@^0.8.4":
version "0.8.5"
resolved "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz"
integrity sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==
"@emotion/unitless@^0.7.4":
version "0.7.5"
resolved "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz"
integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==
"@expo/bunyan@4.0.0", "@expo/bunyan@^4.0.0":
version "4.0.0"
resolved "https://registry.npmjs.org/@expo/bunyan/-/bunyan-4.0.0.tgz"
@ -2055,22 +2033,6 @@ babel-plugin-react-native-web@~0.18.2:
resolved "https://registry.npmjs.org/babel-plugin-react-native-web/-/babel-plugin-react-native-web-0.18.9.tgz"
integrity sha512-A9rrSfV98CFRS+ACgZorxaHH8gDrVyK2Nea8OHepY4Sv/Mf+vk8uvQq+tRUEBpHnUvd/qRDKIjFLbygecAt9VA==
"babel-plugin-styled-components@>= 1.12.0":
version "2.0.7"
resolved "https://registry.npmjs.org/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.7.tgz"
integrity sha512-i7YhvPgVqRKfoQ66toiZ06jPNA3p6ierpfUuEWxNF+fV27Uv5gxBkf8KZLHUCc1nFA9j6+80pYoIpqCeyW3/bA==
dependencies:
"@babel/helper-annotate-as-pure" "^7.16.0"
"@babel/helper-module-imports" "^7.16.0"
babel-plugin-syntax-jsx "^6.18.0"
lodash "^4.17.11"
picomatch "^2.3.0"
babel-plugin-syntax-jsx@^6.18.0:
version "6.18.0"
resolved "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz"
integrity sha512-qrPaCSo9c8RHNRHIotaufGbuOBN8rtdC4QrrFFc43vyWCCz7Kl7GL1PGaXtMGQZUXrkCjNEgxDfmAuAabr/rlw==
babel-plugin-syntax-trailing-function-commas@^7.0.0-beta.0:
version "7.0.0-beta.0"
resolved "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz"
@ -2377,11 +2339,6 @@ camelcase@^6.0.0:
resolved "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
camelize@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/camelize/-/camelize-1.0.0.tgz"
integrity sha512-W2lPwkBkMZwFlPCXhIlYgxu+7gC/NUlCtdK652DAJ1JdgV0sTrvuPFshNPrFa1TY2JOkLhgdeEBplB4ezEa+xg==
caniuse-lite@^1.0.30001370:
version "1.0.30001390"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001390.tgz"
@ -2713,11 +2670,6 @@ crypto-random-string@^2.0.0:
resolved "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz"
integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==
css-color-keywords@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz"
integrity sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==
css-in-js-utils@^2.0.0:
version "2.0.1"
resolved "https://registry.npmjs.org/css-in-js-utils/-/css-in-js-utils-2.0.1.tgz"
@ -2726,15 +2678,6 @@ css-in-js-utils@^2.0.0:
hyphenate-style-name "^1.0.2"
isobject "^3.0.1"
css-to-react-native@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.0.0.tgz"
integrity sha512-Ro1yETZA813eoyUp2GDBhG2j+YggidUmzO1/v9eYBKR2EHVEniE2MI/NqpTQ954BMpTPZFsGNPm46qFB9dpaPQ==
dependencies:
camelize "^1.0.0"
css-color-keywords "^1.0.0"
postcss-value-parser "^4.0.2"
dag-map@~1.0.0:
version "1.0.2"
resolved "https://registry.npmjs.org/dag-map/-/dag-map-1.0.2.tgz"
@ -3598,13 +3541,6 @@ history@^5.2.0:
dependencies:
"@babel/runtime" "^7.7.6"
hoist-non-react-statics@^3.0.0:
version "3.3.2"
resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
dependencies:
react-is "^16.7.0"
hosted-git-info@^3.0.2:
version "3.0.8"
resolved "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-3.0.8.tgz"
@ -4269,7 +4205,7 @@ lodash.throttle@^4.1.1:
resolved "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz"
integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==
lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.4:
lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.4:
version "4.17.21"
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@ -5203,7 +5139,7 @@ picocolors@^1.0.0:
resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz"
integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==
picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.0, picomatch@^2.3.1:
picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1:
version "2.3.1"
resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
@ -5255,7 +5191,7 @@ posix-character-classes@^0.1.0:
resolved "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz"
integrity sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==
postcss-value-parser@^4.0.2, postcss-value-parser@^4.2.0:
postcss-value-parser@^4.2.0:
version "4.2.0"
resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz"
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==
@ -5386,11 +5322,6 @@ react-dom@18.0.0:
resolved "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz"
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
react-is@^17.0.1:
version "17.0.2"
resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz"
@ -5900,11 +5831,6 @@ shallow-clone@^3.0.0:
dependencies:
kind-of "^6.0.2"
shallowequal@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz"
integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz"
@ -6161,22 +6087,6 @@ structured-headers@^0.4.1:
resolved "https://registry.npmjs.org/structured-headers/-/structured-headers-0.4.1.tgz"
integrity sha512-0MP/Cxx5SzeeZ10p/bZI0S6MpgD+yxAhi1BOQ34jgnMXsCq3j1t6tQnZu+KdlL7dvJTLT3g9xN8tl10TqgFMcg==
styled-components@^5.3.5:
version "5.3.5"
resolved "https://registry.npmjs.org/styled-components/-/styled-components-5.3.5.tgz"
integrity sha512-ndETJ9RKaaL6q41B69WudeqLzOpY1A/ET/glXkNZ2T7dPjPqpPCXXQjDFYZWwNnE5co0wX+gTCqx9mfxTmSIPg==
dependencies:
"@babel/helper-module-imports" "^7.0.0"
"@babel/traverse" "^7.4.5"
"@emotion/is-prop-valid" "^1.1.0"
"@emotion/stylis" "^0.8.4"
"@emotion/unitless" "^0.7.4"
babel-plugin-styled-components ">= 1.12.0"
css-to-react-native "^3.0.0"
hoist-non-react-statics "^3.0.0"
shallowequal "^1.1.0"
supports-color "^5.5.0"
styleq@^0.1.2:
version "0.1.2"
resolved "https://registry.npmjs.org/styleq/-/styleq-0.1.2.tgz"
@ -6209,7 +6119,7 @@ sudo-prompt@^9.0.0:
resolved "https://registry.npmjs.org/sudo-prompt/-/sudo-prompt-9.2.1.tgz"
integrity sha512-Mu7R0g4ig9TUuGSxJavny5Rv0egCEtpZRNMrZaYS1vxkiIxGiGUwoezU3LazIQ+KE04hTrTfNPgxU5gzi7F5Pw==
supports-color@^5.3.0, supports-color@^5.5.0:
supports-color@^5.3.0:
version "5.5.0"
resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz"
integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==