shopping-cart

v1.2.0arrow_drop_down
v1.2.0
v1.1.0
v1.0.0
STATUS
None
DOWNLOADS
25
VISIBILITY
Public
PUBLISHED
4 years ago
SIZE
N/A
1 contributor
Install shopping-cart as a package?
Copied
npm i @bit/ebyjane.shopping-cart.shopping-cart
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Files
  • shared
    • models
      • app-user.ts
    • services
      • auth-guard.service.ts
      • auth.service.ts
      • user.service.ts
  • src
    • app
      • admin
        • shared
          • components
            • product-card
              • product-card.component.css
              • product-card.component.html
              • product-card.component.spec.ts
              • product-card.component.ts
            • product-quantity
              • product-quantity.component.css
              • product-quantity.component.html
              • product-quantity.component.spec.ts
              • product-quantity.component.ts
          • models
            • app-user.ts
            • order.ts
            • product.ts
            • shopping-cart-item.ts
            • shopping-cart.ts
          • services
            • auth-guard.service.spec.ts
            • auth-guard.service.ts
            • auth.service.spec.ts
            • auth.service.ts
            • category.service.spec.ts
            • category.service.ts
            • order.service.spec.ts
            • order.service.ts
            • product.service.spec.ts
            • product.service.ts
            • shopping-cart.service.spec.ts
            • shopping-cart.service.ts
            • user.service.spec.ts
            • user.service.ts
          • shared.module.ts
      • core
        • components
          • login
            • shared
              • components
                • product-card
                  • product-card.component.css
                  • product-card.component.html
                  • product-card.component.spec.ts
                  • product-card.component.ts
                • product-quantity
                  • product-quantity.component.css
                  • product-quantity.component.html
                  • product-quantity.component.spec.ts
                  • product-quantity.component.ts
              • models
                • app-user.ts
                • order.ts
                • product.ts
                • shopping-cart-item.ts
                • shopping-cart.ts
              • services
                • auth-guard.service.spec.ts
                • auth-guard.service.ts
                • auth.service.spec.ts
                • auth.service.ts
                • category.service.spec.ts
                • category.service.ts
                • order.service.spec.ts
                • order.service.ts
                • product.service.spec.ts
                • product.service.ts
                • shopping-cart.service.spec.ts
                • shopping-cart.service.ts
                • user.service.spec.ts
                • user.service.ts
              • shared.module.ts
      • shopping
        • components
          • my-orders
            • shared
              • components
                • product-card
                  • product-card.component.css
                  • product-card.component.html
                  • product-card.component.spec.ts
                  • product-card.component.ts
                • product-quantity
                  • product-quantity.component.css
                  • product-quantity.component.html
                  • product-quantity.component.spec.ts
                  • product-quantity.component.ts
              • models
                • app-user.ts
                • order.ts
                • product.ts
                • shopping-cart-item.ts
                • shopping-cart.ts
              • services
                • auth-guard.service.spec.ts
                • auth-guard.service.ts
                • auth.service.spec.ts
                • auth.service.ts
                • category.service.spec.ts
                • category.service.ts
                • order.service.spec.ts
                • order.service.ts
                • product.service.spec.ts
                • product.service.ts
                • shopping-cart.service.spec.ts
                • shopping-cart.service.ts
                • user.service.spec.ts
                • user.service.ts
              • shared.module.ts
          • shared
            • components
              • product-card
                • product-card.component.css
                • product-card.component.html
                • product-card.component.spec.ts
                • product-card.component.ts
              • product-quantity
                • product-quantity.component.css
                • product-quantity.component.html
                • product-quantity.component.spec.ts
                • product-quantity.component.ts
            • models
              • app-user.ts
              • order.ts
              • product.ts
              • shopping-cart-item.ts
              • shopping-cart.ts
            • services
              • auth-guard.service.spec.ts
              • auth-guard.service.ts
              • auth.service.spec.ts
              • auth.service.ts
              • category.service.spec.ts
              • category.service.ts
              • order.service.spec.ts
              • order.service.ts
              • product.service.spec.ts
              • product.service.ts
              • shopping-cart.service.spec.ts
              • shopping-cart.service.ts
              • user.service.spec.ts
              • user.service.ts
            • shared.module.ts
        • shared
          • components
            • product-card
              • product-card.component.css
              • product-card.component.html
              • product-card.component.spec.ts
              • product-card.component.ts
            • product-quantity
              • product-quantity.component.css
              • product-quantity.component.html
              • product-quantity.component.spec.ts
              • product-quantity.component.ts
          • models
            • app-user.ts
            • order.ts
            • product.ts
            • shopping-cart-item.ts
            • shopping-cart.ts
          • services
            • auth-guard.service.spec.ts
            • auth-guard.service.ts
            • auth.service.spec.ts
            • auth.service.ts
            • category.service.spec.ts
            • category.service.ts
            • order.service.spec.ts
            • order.service.ts
            • product.service.spec.ts
            • product.service.ts
            • shopping-cart.service.spec.ts
            • shopping-cart.service.ts
            • user.service.spec.ts
            • user.service.ts
          • shared.module.ts
shared/services/auth.service.ts
41 Lines(34 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { UserService } from './user.service';
import { AppUser } from '../models/app-user';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/observable/of'; 
import * as firebase from 'firebase'; 

@Injectable()
export class AuthService {
  user$: Observable<firebase.User>;

  constructor(
    private userService: UserService,
    private afAuth: AngularFireAuth, 
    private route: ActivatedRoute) { 
    this.user$ = afAuth.authState;    
  }

  login() {
    let returnUrl = this.route.snapshot.queryParamMap.get('returnUrl') || '/';
    localStorage.setItem('returnUrl', returnUrl);
    
    this.afAuth.auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider());
  }

  logout() { 
    this.afAuth.auth.signOut();
  }

  get appUser$() : Observable<AppUser> {
    return this.user$
      .switchMap(user => {
        if (user) return this.userService.get(user.uid);

        return Observable.of(null);
      });    
  }
}
Help and resources