From b91487e344855c618979d271f947deabbc64bfcd Mon Sep 17 00:00:00 2001 From: Romain CLEMENT Date: Sun, 9 Apr 2023 23:11:57 +0200 Subject: [PATCH] Send to remote button --- src/App.tsx | 1 - src/auth/SignIn.tsx | 20 +++++++++++++------- src/auth/SignUp.tsx | 19 ++++++++++++++----- src/clip/ClipElementLocal.tsx | 23 ++++++++++++++++++++--- src/clip/ClipList.tsx | 4 ++-- src/clip/ClipViewLocal.tsx | 2 +- src/clip/ClipViewRemote.tsx | 3 +-- src/redux/actions.tsx | 4 ++-- src/redux/reducers.tsx | 2 +- 9 files changed, 54 insertions(+), 24 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2c4f0f7..8a005a9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -38,7 +38,6 @@ class App extends React.Component { username: "" } store.subscribe(() => { - console.log("see a dispatch"); this.setState({ token: store.getState().userReducer.token }); }); } diff --git a/src/auth/SignIn.tsx b/src/auth/SignIn.tsx index ffd696c..1cd80f4 100644 --- a/src/auth/SignIn.tsx +++ b/src/auth/SignIn.tsx @@ -16,30 +16,36 @@ export default class SignIn extends React.Component { } async signInFunction() { + const data = new FormData(); + data.append("username", this.state.username); + data.append("password", this.state.password); const signInResponse = await fetch( - 'https://notifysync.simailadjalim.fr/user?username=' + this.state.username + '&password=' + this.state.password, - { method: 'POST' } + 'https://notifysync.simailadjalim.fr/user', + { + method: 'POST', + body: data + } ); const signInJson = await signInResponse.json(); if (signInJson.status === "ok") { - this.props.store.dispatch(setUser(signInJson.token, this.state.username)); + this.props.store.dispatch(setUser(signInJson.token)); } else console.log(signInJson); } updateUsername(event: any) { - this.setState({username: event.target.value}); + this.setState({ username: event.target.value }); } updatePassword(event: any) { - this.setState({password: event.target.value}); + this.setState({ password: event.target.value }); } render(): React.ReactNode { return ( Connexion - - + +