-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a325bac
commit ed682fe
Showing
21 changed files
with
265 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
16 changes: 16 additions & 0 deletions
16
src/app/components/pages/saved-venues/saved-venues.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="text-center"> | ||
<h1 class="text-5xl text-mmRust my-2 font-FFXIV uppercase">Attuned Venues</h1> | ||
<p class="text-sm my-1">These are the venues you've saved on MiqoMixers.</p> | ||
</div> | ||
|
||
<div *ngIf="savedVenues$ | async as venues; else emptyList"> | ||
<ng-container *ngIf="venues.length > 0; else emptyList"> | ||
<div *ngFor="let venue of venues"> | ||
<app-venue-post [venue]="venue"></app-venue-post> | ||
</div> | ||
</ng-container> | ||
</div> | ||
|
||
<ng-template #emptyList> | ||
<p class="text-center pt-5 font-bold text-mmRust dark:text-mmSand">You haven't saved any venues yet.</p> | ||
</ng-template> |
23 changes: 23 additions & 0 deletions
23
src/app/components/pages/saved-venues/saved-venues.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SavedVenuesComponent } from './saved-venues.component'; | ||
|
||
describe('SavedVenuesComponent', () => { | ||
let component: SavedVenuesComponent; | ||
let fixture: ComponentFixture<SavedVenuesComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SavedVenuesComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SavedVenuesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
src/app/components/pages/saved-venues/saved-venues.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import { map, Observable, withLatestFrom } from 'rxjs'; | ||
import { CombinedVenue } from '../../../models/combined-venue.interface'; | ||
import { SavedStateService } from '../../../store/saved-state/saved-state.service'; | ||
import { VenueStateService } from '../../../store/venue-state/venue-state.service'; | ||
import { VenuePostComponent } from '../../ui/venue-post/venue-post.component'; | ||
|
||
@Component({ | ||
selector: 'app-saved-venues', | ||
standalone: true, | ||
imports: [CommonModule, VenuePostComponent], | ||
templateUrl: './saved-venues.component.html', | ||
styleUrl: './saved-venues.component.css' | ||
}) | ||
export class SavedVenuesComponent { | ||
savedVenues$: Observable<CombinedVenue[]>; | ||
|
||
constructor(private venueStateService: VenueStateService, private savedStateService: SavedStateService) { | ||
this.savedVenues$ = savedStateService.savedVenues$.pipe( | ||
withLatestFrom(venueStateService.venues$), | ||
map(([savedVenues, venues]) => venues.filter(venue => savedVenues.find(sv => sv === venue.venue.venueID))) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { AuthState } from './auth-state/auth-state.interface'; | ||
import { SavedState } from './saved-state/saved-state.interface'; | ||
|
||
export interface AppState { | ||
authState: AuthState; | ||
savedState: SavedState; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SavedState } from './saved-state.interface'; | ||
|
||
export const savedInitialState: SavedState = { | ||
savedVenues: [] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { CombinedVenue } from '../../models/combined-venue.interface'; | ||
|
||
export abstract class SavedStateActions { | ||
static readonly saveAttempt = createAction('@miqomixers/action/save/attempt', props<{ venue: CombinedVenue }>()); | ||
static readonly saveSuccess = createAction('@miqomixers/action/save/success', props<{ venue: CombinedVenue }>()); | ||
static readonly unsaveAttempt = createAction('@miqomixers/action/unsave/attempt', props<{ venue: CombinedVenue }>()); | ||
static readonly unsaveSuccess = createAction('@miqomixers/action/unsave/success', props<{ venue: CombinedVenue }>()); | ||
static readonly clearAttempt = createAction('@miqomixers/action/save/clear/attempt'); | ||
static readonly clearSuccess = createAction('@miqomixers/action/save/clear/success'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Actions, createEffect, ofType } from '@ngrx/effects'; | ||
import { map } from 'rxjs'; | ||
import { SavedStateActions } from './saved-state.actions'; | ||
import { SavedStateService } from './saved-state.service'; | ||
|
||
@Injectable() | ||
export class SavedStateEffects { | ||
constructor(private actions$: Actions, private savedStateService: SavedStateService) {} | ||
|
||
saveVenueAttempt$ = createEffect(() => | ||
this.actions$.pipe( | ||
ofType(SavedStateActions.saveAttempt), | ||
map(action => SavedStateActions.saveSuccess(action)) | ||
) | ||
); | ||
|
||
unsaveVenueAttempt$ = createEffect(() => | ||
this.actions$.pipe( | ||
ofType(SavedStateActions.unsaveAttempt), | ||
map(action => SavedStateActions.unsaveSuccess(action)) | ||
) | ||
); | ||
|
||
clearVenuesAttempt$ = createEffect(() => | ||
this.actions$.pipe( | ||
ofType(SavedStateActions.clearAttempt), | ||
map(action => SavedStateActions.clearSuccess()) | ||
) | ||
); | ||
|
||
// For success, maybe show a notification | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface SavedState { | ||
savedVenues: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { createReducer, on } from '@ngrx/store'; | ||
import { savedInitialState } from './saved-initial-state'; | ||
import { SavedStateActions } from './saved-state.actions'; | ||
import { SavedState } from './saved-state.interface'; | ||
|
||
export const savedStateReducer = createReducer( | ||
savedInitialState, | ||
on( | ||
SavedStateActions.saveSuccess, | ||
(state, action): SavedState => ({ | ||
...state, | ||
savedVenues: [...state.savedVenues, action.venue.venue.venueID] | ||
}) | ||
), | ||
on( | ||
SavedStateActions.clearSuccess, | ||
(state, action): SavedState => ({ | ||
...state, | ||
savedVenues: [] | ||
}) | ||
), | ||
on(SavedStateActions.unsaveSuccess, (state, action): SavedState => { | ||
var newList = [...state.savedVenues]; | ||
var i = newList.findIndex(v => v === action.venue.venue.venueID); | ||
|
||
if (i >= 0) { | ||
newList.splice(i, 1); | ||
} | ||
|
||
return { | ||
...state, | ||
savedVenues: newList | ||
}; | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { createFeatureSelector, createSelector } from '@ngrx/store'; | ||
import { SavedState } from './saved-state.interface'; | ||
|
||
export const selectSavedState = createFeatureSelector<SavedState>('savedState'); | ||
export const selectSavedVenues = createSelector(selectSavedState, (state: SavedState) => state.savedVenues); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
import { Observable } from 'rxjs'; | ||
import { CombinedVenue } from '../../models/combined-venue.interface'; | ||
import { SavedStateActions } from './saved-state.actions'; | ||
import { selectSavedVenues } from './saved-state.selectors'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class SavedStateService { | ||
savedVenues$: Observable<string[]> = this.store.select(selectSavedVenues); | ||
|
||
constructor(private store: Store) {} | ||
|
||
onSaveVenue(venue: CombinedVenue): void { | ||
this.store.dispatch(SavedStateActions.saveAttempt({ venue })); | ||
} | ||
|
||
onUnsaveVenue(venue: CombinedVenue): void { | ||
this.store.dispatch(SavedStateActions.unsaveAttempt({ venue })); | ||
} | ||
|
||
onClearSaved(): void { | ||
this.store.dispatch(SavedStateActions.clearAttempt()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { authStateReducer } from './auth-state/auth-state.reducer'; | ||
import { savedStateReducer } from './saved-state/saved-state.reducer'; | ||
|
||
export const rootReducer = { | ||
authState: authStateReducer | ||
authState: authStateReducer, | ||
savedState: savedStateReducer | ||
}; |