Dwayne Harris
5 years ago
18 changed files with 105 additions and 84 deletions
-
4src/actions/directory.ts
-
6src/api/errors.ts
-
4src/components/app/index.ts
-
3src/components/pages/directory/directory.scss
-
14src/components/pages/directory/directory.tsx
-
6src/components/pages/directory/index.ts
-
14src/components/pages/register/index.ts
-
4src/components/pages/register/register.tsx
-
2src/components/spinner/index.tsx
-
8src/components/spinner/spinner.scss
-
4src/components/user-info/index.ts
-
20src/routes/index.ts
-
25src/selectors/index.ts
-
4src/store/index.ts
-
10src/store/schemas.ts
-
41src/types/store.ts
-
4tsconfig.json
-
16webpack.config.ts
@ -0,0 +1,3 @@ |
|||
@import "../../../../node_modules/bulma/sass/utilities/_all.sass"; |
|||
@import "../../../../node_modules/bulma/sass/base/_all.sass"; |
|||
@import "../../../../node_modules/bulma/sass/elements/title.sass"; |
@ -1,21 +1,9 @@ |
|||
import { connect } from 'react-redux' |
|||
import { ThunkDispatch } from 'redux-thunk' |
|||
|
|||
import { fetchGroups, FetchGroupsAction } from '../../../actions/groups' |
|||
import { AppState } from '../../../types' |
|||
|
|||
import Register from './register' |
|||
|
|||
const mapStateToProps = () => { |
|||
} |
|||
|
|||
const mapDispatchToProps = (dispatch: ThunkDispatch<AppState, void, FetchGroupsAction>) => ({ |
|||
fetchGroups: () => { |
|||
dispatch(fetchGroups()) |
|||
} |
|||
}) |
|||
|
|||
export default connect( |
|||
mapStateToProps, |
|||
mapDispatchToProps |
|||
mapStateToProps |
|||
)(Register) |
@ -1,20 +0,0 @@ |
|||
import { FC } from 'react' |
|||
import { Dispatch } from 'redux' |
|||
import Home from '../components/pages/home' |
|||
|
|||
export interface Route { |
|||
id: string |
|||
path: string |
|||
component: FC |
|||
fetchInitialData?: (dispatch: Dispatch, ...args: any[]) => void |
|||
} |
|||
|
|||
const routes: Route[] = [ |
|||
{ |
|||
id: 'home', |
|||
path: '/', |
|||
component: Home, |
|||
} |
|||
] |
|||
|
|||
export default routes |
@ -1,13 +1,26 @@ |
|||
import { denormalize } from 'normalizr' |
|||
import { createSelector } from 'reselect' |
|||
import values from 'lodash/values' |
|||
import { AppState, APIRequest } from '../types' |
|||
|
|||
const REQUEST_LOADING_MIN = 500 |
|||
import { groupSchema } from '../store/schemas' |
|||
import { AppState, Entity } from '../types' |
|||
|
|||
export const getEntityStore = (state: AppState) => state.entities |
|||
|
|||
export const getMenuCollapsed = (state: AppState) => state.menu.collapsed |
|||
export const getAuthenticated = (state: AppState) => state.authentication.authenticated |
|||
export const getNotifications = (state: AppState) => state.notifications |
|||
export const getRequests = (state: AppState) => state.requests |
|||
|
|||
export const getFetching = createSelector(getRequests, requests => { |
|||
return values(requests).reduce((fetching, request) => fetching || request.fetching, false) |
|||
}) |
|||
|
|||
export const getDirectoryGroupIds = (state: AppState) => state.directory.groups |
|||
|
|||
export const getFetching = (state: AppState) => { |
|||
const isFetching = (request: APIRequest) => request.fetching && (Date.now() - request.started > REQUEST_LOADING_MIN) |
|||
return values(state.requests).reduce((fetching, request) => fetching || isFetching(request) , false) |
|||
} |
|||
export const getDirectoryGroups = createSelector( |
|||
[getEntityStore, getDirectoryGroupIds], |
|||
(store, groups) => { |
|||
return denormalize(groups, [groupSchema], store) as Entity[] |
|||
} |
|||
) |
@ -1,12 +1,12 @@ |
|||
import { schema } from 'normalizr' |
|||
|
|||
const group = new schema.Entity('groups') |
|||
const groupSchema = new schema.Entity('groups') |
|||
|
|||
const user = new schema.Entity('users', { |
|||
group, |
|||
const userSchema = new schema.Entity('users', { |
|||
groupSchema, |
|||
}) |
|||
|
|||
export { |
|||
group, |
|||
user, |
|||
groupSchema, |
|||
userSchema, |
|||
} |
@ -1,11 +1,13 @@ |
|||
{ |
|||
"compilerOptions": { |
|||
"outDir": "./dist/", |
|||
"baseUrl": ".", |
|||
"sourceMap": true, |
|||
"strict": true, |
|||
"module": "commonjs", |
|||
"esModuleInterop": true, |
|||
"target": "es6", |
|||
"jsx": "react" |
|||
"jsx": "react", |
|||
"resolveJsonModule": true |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue