Skip to content

Commit

Permalink
Merge pull request #72 from CS506-MS3/milestone/iteration-1-remainders
Browse files Browse the repository at this point in the history
Milestone/iteration 1 remainders
  • Loading branch information
yclee0210 authored Nov 28, 2017
2 parents bfe9205 + af32c9b commit 43063dd
Show file tree
Hide file tree
Showing 169 changed files with 12,475 additions and 443 deletions.
1 change: 1 addition & 0 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"local": "environments/environment.local.ts",
"prod": "environments/environment.prod.ts"
}
}
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function (config) {
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
8,815 changes: 8,815 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.2",
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
Expand Down
12 changes: 11 additions & 1 deletion src/app/_actions/accesses.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import {ItemId} from '../_domains/item-id';
import * as CrudActions from './crud.actions';
import {Accesses} from '../_domains/accesses';
import {Access} from '../_domains/access';
import {Action} from '@ngrx/store';

export const ACTION_NAME = 'AccessesActions';

export const SET = ACTION_NAME + CrudActions.SET;
export const ADD_ITEM = ACTION_NAME + CrudActions.ADD_ITEM;
export const REMOVE_ITEM = ACTION_NAME + CrudActions.REMOVE_ITEM;
export const CLEAR = ACTION_NAME + CrudActions.CLEAR;
export const CANCEL_SUBSCRIPTION = ACTION_NAME + 'CANCEL_SUBSCRIPTION';

export class Set extends CrudActions.Set {
constructor(public payload: Accesses) {
Expand All @@ -34,8 +36,16 @@ export class Clear extends CrudActions.Clear {
}
}

export class CancelSubscription implements Action {
type = CANCEL_SUBSCRIPTION;

constructor(public payload: string) {
}
}

export type All
= Set
| AddItem
| RemoveItem
| Clear;
| Clear
| CancelSubscription;
36 changes: 33 additions & 3 deletions src/app/_actions/accesses.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,41 @@ import {Accesses} from '../_domains/accesses';
const prefix = AccessesActions.ACTION_NAME;
const INIT = 'INIT';
const initialState: Accesses = {
list: []
vendor: null,
customer: null
};

export function reducer(state = initialState, action: Action = {type: INIT}): Accesses {
const newState = Crud.reducer(state, action, prefix, initialState);
switch (action.type) {
case AccessesActions.CANCEL_SUBSCRIPTION:
switch ((<AccessesActions.CancelSubscription>action).payload) {
case 'VENDOR': {

return newState === null ? initialState : newState;
return {
vendor: Object.assign({}, state.vendor, {
next_payment_date: null
}),
customer: state.customer
};
}

case 'CUSTOMER': {

return {
vendor: state.vendor,
customer: Object.assign({}, state.customer, {
next_payment_date: null
})
};
}

default:
return state;
}

default:
const newState = Crud.reducer(state, action, prefix, initialState);

return newState === null ? initialState : newState;
}
}
11 changes: 10 additions & 1 deletion src/app/_actions/auth.actions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as CrudActions from './crud.actions';
import {Auth} from '../_domains/auth';
import {Action} from '@ngrx/store';

export const ACTION_NAME = 'AuthActions';

export const SET = ACTION_NAME + CrudActions.SET;
export const CLEAR = ACTION_NAME + CrudActions.CLEAR;
export const UPDATE_TOKEN = ACTION_NAME + 'UPDATE_TOKEN';

export class Set extends CrudActions.Set {
constructor(public payload: Auth) {
Expand All @@ -18,6 +20,13 @@ export class Clear extends CrudActions.Clear {
}
}

export class UpdateToken implements Action {
type = UPDATE_TOKEN;

constructor(public payload: any) {
}
}
export type All
= Set
| Clear;
| Clear
| UpdateToken;
11 changes: 9 additions & 2 deletions src/app/_actions/auth.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ const INIT = 'INIT';
const initialState: Auth = new Auth();

export function reducer(state = initialState, action: Action = {type: INIT}): Auth {
const newState = Crud.reducer(state, action, prefix, initialState);
switch (action.type) {
case AuthActions.UPDATE_TOKEN:
return Object.assign({}, state, (<AuthActions.UpdateToken>action).payload);

default:
const newState = Crud.reducer(state, action, prefix, initialState);

return newState === null ? initialState : newState;
}

return newState === null ? initialState : newState;
}
5 changes: 3 additions & 2 deletions src/app/_actions/properties.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import {Properties} from '../_domains/properties';
const prefix = PropertiesActions.ACTION_NAME;
const INIT = 'INIT';
const initialState: Properties = {
list: []
list: [],
cursor: null
};

export function reducer(state = initialState, action: Action = {type: INIT}): Properties {
switch (action.type) {
case PropertiesActions.INCREASE_LIST:
return {
...state,
cursor: (<PropertiesActions.IncreaseList>action).payload.cursor,
list: [...state.list, ...((<PropertiesActions.IncreaseList>action).payload.list)]
};

Expand Down
15 changes: 15 additions & 0 deletions src/app/_actions/property-options.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as CrudActions from './crud.actions';
import {PropertyOptions} from '../_domains/property-options';

export const ACTION_NAME = 'PropertyOptionsActions';

export const SET = ACTION_NAME + CrudActions.SET;

export class Set extends CrudActions.Set {
constructor(public payload: PropertyOptions) {
super(ACTION_NAME);
}
}

export type All
= Set;
17 changes: 17 additions & 0 deletions src/app/_actions/property-options.reducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Action} from '@ngrx/store';
import * as PropertyOptionsActions from './property-options.actions';
import * as Crud from './crud.reducer';
import {Property} from '../_domains/property';
import {PropertyOptions} from '../_domains/property-options';

const prefix = PropertyOptionsActions.ACTION_NAME;
const INIT = 'INIT';
const initialState: PropertyOptions = {
list: []
};

export function reducer(state = initialState, action: Action = {type: INIT}): Property {
const newState = Crud.reducer(state, action, prefix, initialState);

return newState === null ? initialState : newState;
}
4 changes: 2 additions & 2 deletions src/app/_actions/property.reducer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Action, ActionReducer} from '@ngrx/store';
import * as UserInfoActions from './user-info.actions';
import * as PropertyActions from './property.actions';
import * as Crud from './crud.reducer';
import {Property} from '../_domains/property';

const prefix = UserInfoActions.ACTION_NAME;
const prefix = PropertyActions.ACTION_NAME;
const INIT = 'INIT';
const initialState = null;

Expand Down
6 changes: 4 additions & 2 deletions src/app/_domains/access.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface Access {
id: number;
// TODO: Needs configuration
id: string;
cancelled: boolean;
nextPaymentDate: string;
paymentAmount: number;
}
3 changes: 2 additions & 1 deletion src/app/_domains/accesses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Access} from './access';

export interface Accesses {
list: Access[];
vendor: Access;
customer: Access;
}
2 changes: 1 addition & 1 deletion src/app/_domains/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export class Auth {

constructor(public token: string = null,
public email: string = null,
public id: number = null) {
public id: number | string = null) {
}
}
4 changes: 4 additions & 0 deletions src/app/_domains/change-password-form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface ChangePasswordForm {
password: string;
new_password: string;
}
7 changes: 7 additions & 0 deletions src/app/_domains/edit-user-info-form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {NotificationSettings} from './notification-settings';

export interface EditUserInfoForm {
phone: string;
notification: NotificationSettings;
password: string;
}
2 changes: 1 addition & 1 deletion src/app/_domains/item-id.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface ItemId {
id: number;
id: number | string;
}
4 changes: 4 additions & 0 deletions src/app/_domains/password-reset-form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface PasswordResetForm {
token: string;
password: string;
}
2 changes: 1 addition & 1 deletion src/app/_domains/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export interface Pricing {
id: number;
type: 'VENDOR_SUBSCRIPTION' | 'VENDOR_ADDITIONAL' | 'CUSTOMER_SUBSCRIPTION';
alias: string;
pricePerItem: number;
price: number;
canHaveMultiple: boolean;
}
1 change: 1 addition & 0 deletions src/app/_domains/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import {PropertySummary} from './property-summary';

export interface Properties {
list: PropertySummary[];
cursor: string;
}
5 changes: 1 addition & 4 deletions src/app/_domains/property-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ export interface PropertyForm {
title: string;
address: any;
description: string;
propertyType: string;
roomType: string;
price: number;
startDate: string;
duration: number;
amenities: number[];
pets: number[];
houseRules: number[];
options: number[];
imageUrls: string[];
}
7 changes: 7 additions & 0 deletions src/app/_domains/property-option.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface PropertyOption {
id: number;
alias: string;
type: string;
createTime?: string;
updateTime?: string;
}
5 changes: 5 additions & 0 deletions src/app/_domains/property-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {PropertyOption} from './property-option';

export interface PropertyOptions {
list: PropertyOption[];
}
5 changes: 3 additions & 2 deletions src/app/_domains/property-query-params.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface PropertyQueryParams {
sortBy?: string;
sortOrder?: boolean;
sortBy: string;
direction: string;
cursor?: string;
searchBy?: string;
filters?: any;
}
1 change: 1 addition & 0 deletions src/app/_domains/property-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface PropertySummary {
startDate: string;
duration: number;
thumbnailUrl: string;
status?: boolean;
}
25 changes: 24 additions & 1 deletion src/app/_domains/property.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
export interface Property {
id: string;
status: boolean;
title: string;
// TODO: Implementation required
address: {
geocode: {
lat: number;
lng: number;
};
detailLevel1: string;
detailLevel2: string;
city: string;
state: string;
zipcode: string;
type: string;
};
description: string;
roomType: string;
price: number;
startDate: string;
duration: number;
options: number[];
imageUrls: string[];
owner?: string;
createTime?: string;
updateTime?: string;
}
1 change: 0 additions & 1 deletion src/app/_domains/purchase-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import {StripeToken} from './stripe-token';
export interface PurchaseForm {
token: StripeToken;
type: string;
count: number;
}
4 changes: 4 additions & 0 deletions src/app/_domains/subscription-cancel-form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface SubscriptionCancelForm {
password: string;
type: string;
}
29 changes: 29 additions & 0 deletions src/app/_effect-actions/password-change.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {RequestError} from '../_domains/request-error';
import {Action} from '@ngrx/store';
import {ChangePasswordForm} from '../_domains/change-password-form';
import {AuthResponse} from '../_domains/auth-response';

export const REQUEST = 'PasswordChangeActions.REQUEST';
export const SUCCESS = 'PasswordChangeActions.SUCCESS';
export const ERROR = 'PasswordChangeActions.ERROR';

export class Request implements Action {
readonly type = REQUEST;

constructor(public payload: ChangePasswordForm, public userId) {
}
}

export class Success implements Action {
readonly type = SUCCESS;

constructor(public payload: AuthResponse) {
}
}

export class Error implements Action {
readonly type = ERROR;

constructor(public payload: RequestError) {
}
}
Loading

0 comments on commit 43063dd

Please sign in to comment.