diff --git a/src/app/api/supabase/standup.service.spec.ts b/src/app/api/supabase/standup.service.spec.ts new file mode 100644 index 0000000..2bcfc24 --- /dev/null +++ b/src/app/api/supabase/standup.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { StandupService } from './standup.service'; + +describe('StandupService', () => { + let service: StandupService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(StandupService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/api/supabase/standup.service.ts b/src/app/api/supabase/standup.service.ts new file mode 100644 index 0000000..f7953e0 --- /dev/null +++ b/src/app/api/supabase/standup.service.ts @@ -0,0 +1,55 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; +import { StandUp } from './standup'; +import { SupaService } from './supa.service'; + +@Injectable({ + providedIn: 'root' +}) +export class StandupService { + // standupMap: Map = new Map(); + standupMap = {}; + standups: BehaviorSubject = new BehaviorSubject([]); + + constructor( + private supa: SupaService, + ) { } + + getStandUps(): Observable { + if (Object.values(this.standupMap).length === 0) { + console.log('getStandUps - REFRESH') + return this.refreshStandUps(); + } else { + console.log('getStandUps - LOCAL') + return this.standups.asObservable(); + } + } + + refreshStandUps(): Observable { + this.supa.client.from('standup').select('id, name, description') + .then(standups => this.updateStore(standups.body)) + .catch(error => console.log('Error: ', error)); + return this.standups.asObservable(); + } + + updateStore(standups: StandUp[]) { + standups.forEach(e => { + // this.standupMap.set(e.id, e); + this.standupMap[e.id] = e; + }); + this.standups.next(Object.values(this.standupMap)); + } + + updateOne(standup: StandUp) { + + } + + deleteOne(standup: StandUp) { + + } + + addOne(standup: StandUp) { + + } + +} diff --git a/src/app/api/supabase/standup.ts b/src/app/api/supabase/standup.ts new file mode 100644 index 0000000..b6aa608 --- /dev/null +++ b/src/app/api/supabase/standup.ts @@ -0,0 +1,5 @@ +export class StandUp { + id: number; + name: string; + description: string; +} \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index f6a49fa..2144629 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -6,12 +6,29 @@ import { HuddleComponent } from './huddle/huddle.component'; import { LoginComponent } from './login/login.component'; import { SignupComponent } from './signup/signup.component'; import { AuthGuard } from './authguard.service'; +import { ProfileComponent } from './profile/profile.component'; +import { DashboardComponent } from './dashboard/dashboard.component'; +import { ChannelComponent } from './channel/channel.component'; const routes: Routes = [ { - path: 'huddle', + path: 'huddle/:id', component: HuddleComponent, canActivate: [AuthGuard] + },{ + path: 'channel/:id', + component: ChannelComponent, + canActivate: [AuthGuard] + }, + { + path: 'profile', + component: ProfileComponent, + canActivate: [AuthGuard] + }, + { + path: 'home', + component: DashboardComponent, + canActivate: [AuthGuard] }, { path: 'login', @@ -21,7 +38,7 @@ const routes: Routes = [ path: 'signup', component: SignupComponent, }, - { path: '**', redirectTo: '/huddle', pathMatch: 'full' }, + { path: '**', redirectTo: '/home', pathMatch: 'full' }, ] @NgModule({ diff --git a/src/app/app.component.html b/src/app/app.component.html index 2bcf31b..5acaf4c 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,7 +1,14 @@ -