diff --git a/web/public/index.html b/web/public/index.html
index 30b7702..5dfdf29 100644
--- a/web/public/index.html
+++ b/web/public/index.html
@@ -5,6 +5,7 @@
+
{children}
);
}
+
+function Row({ children }: any) {
+ return
{children}
;
+}
diff --git a/web/src/components/accountForm.tsx b/web/src/components/accountForm.tsx
deleted file mode 100644
index 953981e..0000000
--- a/web/src/components/accountForm.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import React, { Component } from 'react';
-import { AccountOptions, createAccount } from '../services/accounts';
-
-interface FormState {
- username: string;
- password: string;
- sharedSecret: string;
- identity: string;
- gameId: number;
- trashLimit: number;
- owners: string[];
- tradeWith0Profit: boolean;
- [x: string]: string | boolean | number | string[];
-}
-
-export default class Form extends Component
{
- constructor(props: any) {
- super(props);
-
- this.handleInputChange = this.handleInputChange.bind(this);
- this.handleSubmit = this.handleSubmit.bind(this);
- this.setState({});
- }
-
- render() {
- return (
-
- );
- }
-
- handleInputChange(event: React.ChangeEvent) {
- const target = event.target;
- const value = target.type === 'checkbox' ? target.checked : target.value;
- const name = target.name;
-
- this.setState({
- [name]: value
- });
- }
-
- handleSubmit(event: React.FormEvent) {
- event.preventDefault();
- console.log(this.state);
-
- const { username, password, sharedSecret, identity, gameId, owners, trashLimit, tradeWith0Profit } = this.state;
-
- const options: AccountOptions = {
- login: {
- username,
- password,
- sharedSecret,
- identity
- },
- status: {
- gameId
- },
- trading: {
- owners,
- trashLimit,
- tradeWith0Profit
- }
- };
-
- createAccount(options).then((r) => console.log(r.data));
- }
-
- TextInput = ({ type, name, help, title }: any) => {
- return (
-
-
-
-
- {help}
-
-
- );
- };
-
- SwitchInput = ({ name, title, help }: any) => {
- return (
-
-
this.handleInputChange(e)}
- />
-
-
- {help}
-
-
- );
- };
-}
diff --git a/web/src/components/accounts.tsx b/web/src/components/accounts.tsx
deleted file mode 100644
index a67b2ff..0000000
--- a/web/src/components/accounts.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import React, { Component } from 'react';
-import { PencilFill, Power } from 'react-bootstrap-icons';
-import { AccountOptions } from '../services/accounts';
-import RegisterAccount from './registerAccount';
-
-interface AccountState {
- accounts: AccountOptions[];
-}
-
-export default class Account extends Component {
- renderAccount(acc?: AccountOptions): any {
- return (
-
-
-
-
{'Hazork'}
-
-
-
- );
- }
-
- // TODO: Fetch user image
- getUserImage(acc?: AccountOptions): string {
- return 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/b5/b5bd56c1aa4644a474a2e4972be27ef9e82e517e_full.jpg';
- }
-
- renderAccounts() {
- return this.state.accounts.map((acc) => this.renderAccount(acc));
- }
-
- render() {
- return (
-
-
- {this.renderAccount()}
- {this.renderAccount()}
- {this.renderAccount()}
- {this.renderAccount()}
- {this.renderAccount()}
- {this.renderAccount()}
- {this.renderAccount()}
- {this.renderAccount()}
- {this.renderAccount()}
-
-
-
-
-
-
- );
- }
-}
diff --git a/web/src/components/accounts/account.tsx b/web/src/components/accounts/account.tsx
new file mode 100644
index 0000000..c8a2a27
--- /dev/null
+++ b/web/src/components/accounts/account.tsx
@@ -0,0 +1,46 @@
+import React from 'react';
+import { PencilFill, Power } from 'react-bootstrap-icons';
+import {login, logout} from '../../services/accounts'
+
+export default function Account({ account }:any) {
+ const name = account.login.username;
+ return (
+
+
+
+
+
+ );
+}
+
+function Button({ Icon, color, paddingLeft, onMouseDown }: any) {
+ return (
+
+
+
+ );
+}
+
+function ProfilePhoto({ account }: any) {
+ return (
+
+ );
+}
+
+// TODO: Fetch user profile photo correctly
+function fetchSteamUserImage(): string {
+ // Default steam profile photo
+ return 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/b5/b5bd56c1aa4644a474a2e4972be27ef9e82e517e_full.jpg';
+}
diff --git a/web/src/components/accounts/display.css b/web/src/components/accounts/display.css
new file mode 100644
index 0000000..72a5bdc
--- /dev/null
+++ b/web/src/components/accounts/display.css
@@ -0,0 +1,13 @@
+#accounts {
+ height: 50vh;
+ max-height: 50vh;
+}
+
+#accounts > #list {
+ height: 100%;
+ max-height: calc(50vh - 60px);
+}
+
+#accounts > #list:nth-child(even) {
+ background: hsla(0, 0%, 0%, 0.22);
+}
diff --git a/web/src/components/accounts/form.tsx b/web/src/components/accounts/form.tsx
new file mode 100644
index 0000000..5c7640a
--- /dev/null
+++ b/web/src/components/accounts/form.tsx
@@ -0,0 +1,100 @@
+import React, { Component } from 'react';
+import { AccountOptions, createAccount } from '../../services/accounts';
+
+interface FormInputs {
+ username: string;
+ password: string;
+ sharedSecret: string;
+ identity: string;
+ gameId: number;
+ trashLimit: number;
+ owners: string[];
+ tradeWith0Profit: boolean;
+ [x: string]: string | boolean | number | string[];
+}
+
+interface FormProps {
+ onFormEntry: (acc: AccountOptions) => void;
+}
+
+export default class Form extends Component {
+ private TextInput = ({ type, name, help, title }: any) => (
+
+
+
+
+ {help}
+
+
+ );
+
+ private SwitchInput = ({ name, title, help }: any) => (
+
+
+
+
+ {help}
+
+
+ );
+
+ private handleInputChange = (event: React.ChangeEvent) => {
+ const target = event.target;
+ this.setState({ [target.name]: target.type === 'checkbox' ? target.checked : target.value });
+ };
+
+ private handleSubmit = (event: React.FormEvent) => {
+ event.preventDefault();
+ const { username, password, sharedSecret, identity, gameId, owners, trashLimit, tradeWith0Profit } = this.state;
+ const options = {
+ login: { username, password, sharedSecret, identity },
+ status: { gameId },
+ trading: { owners, trashLimit, tradeWith0Profit }
+ };
+ createAccount(options)
+ .then((r) => {
+ if(r.data.status === 'Success') {
+ this.props.onFormEntry(options)
+ } else {
+ alert(r.data.response)
+ }
+ })
+ };
+
+ render() {
+ return (
+
+ );
+ }
+}
diff --git a/web/src/components/accounts/index.tsx b/web/src/components/accounts/index.tsx
new file mode 100644
index 0000000..f11af4f
--- /dev/null
+++ b/web/src/components/accounts/index.tsx
@@ -0,0 +1,47 @@
+import React, { Component } from 'react';
+import AccountDisplay from './account';
+import { Offcanvas, Button } from './offcanvas';
+import { AccountOptions, getAccounts } from '../../services/accounts';
+import './display.css'
+
+interface DisplayState {
+ accounts: AccountOptions[];
+}
+
+export default class Display extends Component {
+ id = 'displayOffcanvas';
+
+ constructor(props: any) {
+ super(props);
+
+ getAccounts()
+ .then((resp) => resp.data.response)
+ .then((accounts: AccountOptions[]) => this.setState({ accounts }));
+ }
+
+ private renderAccounts() {
+ if (this.state == null) {
+ return 'Loading...';
+ } else {
+ return this.state.accounts.map((acc) => );
+ }
+ }
+
+ private addAccount = (account: AccountOptions) => {
+ this.setState({ accounts: [...this.state.accounts, account] });
+ }
+
+ render() {
+ return (
+
+
+ {this.renderAccounts()}
+
+
+
+
+
+
+ );
+ }
+}
diff --git a/web/src/components/accounts/offcanvas.tsx b/web/src/components/accounts/offcanvas.tsx
new file mode 100644
index 0000000..40b37a2
--- /dev/null
+++ b/web/src/components/accounts/offcanvas.tsx
@@ -0,0 +1,30 @@
+import React from 'react';
+import OffcanvasTemplate from '../offcanvas';
+import Form from './form';
+
+export function Button({ id, message }: any) {
+ return (
+
+ {message}
+
+ );
+}
+
+export function Offcanvas({ id, onFormEntry }: any) {
+ return (
+
+
+
+
+ );
+}
diff --git a/web/src/components/bootstrap.tsx b/web/src/components/bootstrap.tsx
deleted file mode 100644
index 69afd04..0000000
--- a/web/src/components/bootstrap.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import React from 'react';
-
-export function Container({ children }: any) {
- return {children}
;
-}
-
-export function Row({ children }: any) {
- return {children}
;
-}
-
-export function Nav({ children }: any) {
- return ;
-}
-
-export function NavBrand({ children }: any) {
- return {children};
-}
diff --git a/web/src/components/registerAccount.tsx b/web/src/components/registerAccount.tsx
index 2c69f19..84cebfc 100644
--- a/web/src/components/registerAccount.tsx
+++ b/web/src/components/registerAccount.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import Offcanvas from './offCanvas';
+import Offcanvas from './offcanvas';
import AccountForm from './accountForm';
export default function AccountRegistration({ id }: any) {
diff --git a/web/src/services/accounts.ts b/web/src/services/accounts.ts
index fad51f1..c686825 100644
--- a/web/src/services/accounts.ts
+++ b/web/src/services/accounts.ts
@@ -40,3 +40,7 @@ export function editAccount(options: AccountOptions) {
export function login(name: string) {
return axios({ method: 'POST', url: url(`${name}/login`) });
}
+
+export function logout(name: string) {
+ return axios({ method: 'POST', url: url(`${name}/logout`) });
+}
diff --git a/web/webpack.config.ts b/web/webpack.config.ts
index d9fd17a..c1ccc9f 100644
--- a/web/webpack.config.ts
+++ b/web/webpack.config.ts
@@ -64,7 +64,10 @@ const config: Configuration = {
externals: {
bootstrap: 'bootstrap',
react: 'React',
- 'react-dom': 'ReactDOM'
+ 'react-dom': 'ReactDOM',
+ 'socket.io-client': 'io',
+ axios:'axios',
+ 'reactBootstrapIcons':'react-bootstrap-icons'
}
};