diff --git a/src/app/app.component.html b/src/app/app.component.html
index 36093e1..089a58e 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -334,3 +334,7 @@
+
+
+
+
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 40d1abc..f0f9063 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,13 +1,37 @@
-import { Component } from '@angular/core';
-import { RouterOutlet } from '@angular/router';
+import { Component, OnInit } from '@angular/core';
+import { RouterOutlet, Router } from '@angular/router';
+import { CommonModule } from '@angular/common';
+
+import { AuthService } from './auth.service';
@Component({
selector: 'app-root',
standalone: true,
- imports: [RouterOutlet],
+ imports: [
+ RouterOutlet,
+ CommonModule
+ ],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
-export class AppComponent {
+export class AppComponent implements OnInit {
title = 'jedi-archive-frontend';
+ isAuthenticated = false;
+
+ constructor(private authService: AuthService, private router: Router) {}
+
+ ngOnInit(): void {
+ this.isAuthenticated = !!localStorage.getItem('token');
+ }
+
+ createSheet() {
+ this.authService.createSheet('My New Sheet').subscribe(
+ res => {
+ console.log('Sheet created with ID:', res.sheetId);
+ alert('Sheet created with ID: ' + res.sheetId);
+ },
+ err => console.error(err)
+ );
+ }
+
}
diff --git a/src/app/auth.service.ts b/src/app/auth.service.ts
index 55d7590..bad3936 100644
--- a/src/app/auth.service.ts
+++ b/src/app/auth.service.ts
@@ -1,6 +1,6 @@
// src/app/auth.service.ts
import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
@@ -26,4 +26,10 @@ export class AuthService {
handleGoogleCallback(code: string): Observable {
return this.http.get(`${this.apiUrl}/google/callback?code=${code}`);
}
+
+ createSheet(title: string): Observable {
+ const token = localStorage.getItem('token');
+ const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
+ return this.http.post(`${this.apiUrl}/create-sheet`, { title }, { headers });
+ }
}