summaryrefslogtreecommitdiff
path: root/frontend/src/App.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/App.tsx')
-rw-r--r--frontend/src/App.tsx58
1 files changed, 58 insertions, 0 deletions
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
new file mode 100644
index 0000000..996a794
--- /dev/null
+++ b/frontend/src/App.tsx
@@ -0,0 +1,58 @@
+import React from 'react';
+import { CredentialResponse, GoogleLogin } from '@react-oauth/google';
+
+interface LoginResponse {
+ id: number
+}
+
+interface User {
+ id: Number,
+ elements: Element[],
+}
+
+interface Element {
+ id: Number,
+ userId: Number,
+ name: string,
+ state: ElementState,
+}
+
+enum ElementState {
+ HasColor,
+ HasIcon,
+}
+
+function App() {
+ const responseMessage = async (googleResponse: CredentialResponse) => {
+ console.log(googleResponse);
+ const url: string = "/auth/login";
+ const body = {
+ "googleToken": googleResponse.credential
+ };
+
+ const response = await fetch(url, {
+ method: "POST",
+ credentials: "include",
+ mode: "cors",
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify(body),
+ });
+ if (!response.ok) {
+ console.log("Backend conection problem");
+ return;
+ }
+
+ const user = await response.json() as LoginResponse;
+ console.log(user);
+ };
+
+ return (
+ <div className="App">
+ <GoogleLogin onSuccess={responseMessage} />
+ </div>
+ );
+}
+
+export default App;