This file contains hidden or 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
| // Interceptor | |
| const setupAxiosInterceptors = (onUnauthenticated: () => void) => { | |
| const onRequestSuccess = (config: AxiosRequestConfig) => { | |
| console.log("request success", config); | |
| const token = Storage.local.get("auth"); | |
| if (token) { | |
| config.headers.Authorization = `Bearer ${token}`; | |
| } | |
| return config; |
This file contains hidden or 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
| export const authLoginEffects = (data: AuthLoginFormData) => ( | |
| dispatch: ThunkDispatch<{}, {}, AnyAction> | |
| ) => { | |
| AuthService.login(data) | |
| .then((data) => { | |
| dispatch(authLoginSuccess(data)); | |
| Storage.local.set("auth", data); | |
| dispatch(push("/user")); | |
| }) | |
| .catch((_) => { |
This file contains hidden or 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
| Credit to | |
| https://medium.com/javascript-in-plain-english/react-controlled-forms-with-hooks-538762aab935 | |
| import React, { ChangeEvent, FormEvent, useReducer } from "react"; | |
| const useForm = (initialState: any) => { | |
| const reducer = ( | |
| state: typeof initialState, | |
| payload: { field: string; value: string } | |
| ) => { |
This file contains hidden or 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
| @Injectable() | |
| export class CategoriesGuard implements CanActivate { | |
| constructor(private store: Store<fromStore.CategoriesState>) {} | |
| canActivate(): Observable<boolean> { | |
| return this.checkStore().pipe( | |
| switchMap(() => of(true)), | |
| catchError(() => of(false)) | |
| ); | |
| } |
This file contains hidden or 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
| import React from "react"; | |
| export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { | |
| onClick: () => void; | |
| } | |
| const Button: React.FC<ButtonProps> = ({ | |
| children, | |
| ...buttonProps | |
| }) => { | |
| return ( |
This file contains hidden or 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
| Module | |
| // Core | |
| import { NgModule, Optional, SkipSelf } from '@angular/core'; | |
| // Big.js | |
| import Big from 'big.js/big.mjs'; | |
| import { BigjsService } from './bigjs.service'; | |
| @NgModule({ |
This file contains hidden or 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
| getPendingOrders(): Observable<MatrixPendingOrders[]> { | |
| return this.accountFacade.account$.pipe( | |
| switchMap(account => { | |
| let id: any = ''; | |
| if (account) { | |
| id = account.auth.id; | |
| } | |
| return this.service.getPendingOrders(id); | |
| }), | |
| map((data: PendingOrdersDto) => data.orders), |
This file contains hidden or 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
| let starterChanges$ = of(null); | |
| const starter = this.frm.get('starter'); | |
| if (starter) { | |
| starterChanges$ = starter.valueChanges; | |
| } | |
| let spreadChanges$ = of(null); | |
| const spread = this.frm.get('spread'); | |
| if (spread) { | |
| spreadChanges$ = spread.valueChanges; | |
| } |
This file contains hidden or 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
| <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="logo192.png"/><link rel="manifest" href="/manifest.json"/><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/><title>React App</title><link href="/static/css/main.a38a0264.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(p){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],l=0,a=[];l<n.length;l++)t=n[l],Object.prototype.hasOwnProperty.call(i,t)&&i[t]&&a.push(i[t][0]),i[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(p[r]=o[r]);for(s&&s(e);a.length;)a.shift()();return c.push.apply(c,u||[]),f()}function f(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0, |
This file contains hidden or 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
| <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="logo192.png"/><link rel="manifest" href="/manifest.json"/><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/><title>React App</title><link href="/static/css/main.a38a0264.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(p){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],l=0,a=[];l<n.length;l++)t=n[l],Object.prototype.hasOwnProperty.call(i,t)&&i[t]&&a.push(i[t][0]),i[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(p[r]=o[r]);for(s&&s(e);a.length;)a.shift()();return c.push.apply(c,u||[]),f()}function f(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0, |