Dwayne Harris
5 years ago
23 changed files with 168 additions and 106 deletions
-
12package-lock.json
-
4package.json
-
9src/actions/authentication.ts
-
43src/actions/directory.ts
-
9src/actions/entities.ts
-
18src/actions/forms.ts
-
0src/actions/index.ts
-
6src/actions/menu.ts
-
70src/actions/notifications.ts
-
9src/actions/requests.ts
-
6src/api/groups.ts
-
7src/components/app/app.tsx
-
6src/components/notification-container/index.ts
-
11src/components/notification-container/notification-container.scss
-
1src/components/notification-container/notification-container.tsx
-
9src/components/notification/index.tsx
-
2src/components/pages/directory/index.ts
-
15src/components/pages/register/register.tsx
-
2src/components/user-info/user-info.tsx
-
23src/reducers/notifications.ts
-
2src/store/index.ts
-
9src/store/schemas.ts
-
1src/types/store.ts
@ -1,36 +1,66 @@ |
|||||
import { Action } from 'redux' |
|
||||
|
import { Action, AnyAction } from 'redux' |
||||
|
import { ThunkAction, ThunkDispatch } from 'redux-thunk' |
||||
|
import { v1 } from 'uuid' |
||||
|
|
||||
export interface SetAutoAction extends Action { |
|
||||
type: 'NOTIFICATIONS_SET_AUTO' |
|
||||
|
import { AppState, NotificationType } from '../types' |
||||
|
|
||||
|
export interface AddNotificationAction extends Action { |
||||
|
type: 'NOTIFICATIONS_ADD_NOTIFICATION' |
||||
payload: { |
payload: { |
||||
id: string |
id: string |
||||
|
type: NotificationType |
||||
|
content: string |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
export interface DismissAction extends Action { |
|
||||
type: 'NOTIFICATIONS_DISMISS' |
|
||||
payload: { |
|
||||
id: string |
|
||||
} |
|
||||
|
export interface RemoveNotificationAction extends Action { |
||||
|
type: 'NOTIFICATIONS_REMOVE_NOTIFICATION' |
||||
|
payload: string |
||||
} |
} |
||||
|
|
||||
export type NotificationActions = SetAutoAction | DismissAction |
|
||||
|
export interface ClearNotificationAction extends Action { |
||||
|
type: 'NOTIFICATIONS_CLEAR_NOTIFICATION' |
||||
|
payload: string |
||||
|
} |
||||
|
|
||||
const setAuto = (id: string): SetAutoAction => ({ |
|
||||
type: 'NOTIFICATIONS_SET_AUTO', |
|
||||
|
export interface SetNotificationAutoAction extends Action { |
||||
|
type: 'NOTIFICATIONS_SET_AUTO' |
||||
|
payload: string |
||||
|
} |
||||
|
|
||||
|
export type NotificationActions = AddNotificationAction | RemoveNotificationAction | ClearNotificationAction | SetNotificationAutoAction |
||||
|
|
||||
|
export const addNotification = (id: string, type: NotificationType, content: string): AddNotificationAction => ({ |
||||
|
type: 'NOTIFICATIONS_ADD_NOTIFICATION', |
||||
payload: { |
payload: { |
||||
id, |
id, |
||||
}, |
|
||||
|
type, |
||||
|
content, |
||||
|
} |
||||
}) |
}) |
||||
|
|
||||
const dismiss = (id: string): DismissAction => ({ |
|
||||
type: 'NOTIFICATIONS_DISMISS', |
|
||||
payload: { |
|
||||
id, |
|
||||
}, |
|
||||
|
export const removeNotification = (id: string): RemoveNotificationAction => ({ |
||||
|
type: 'NOTIFICATIONS_REMOVE_NOTIFICATION', |
||||
|
payload: id, |
||||
|
}) |
||||
|
|
||||
|
export const clearNotification = (id: string): ClearNotificationAction => ({ |
||||
|
type: 'NOTIFICATIONS_CLEAR_NOTIFICATION', |
||||
|
payload: id, |
||||
}) |
}) |
||||
|
|
||||
export { |
|
||||
setAuto, |
|
||||
dismiss, |
|
||||
|
export const setNotificationAuto = (id: string): SetNotificationAutoAction => ({ |
||||
|
type: 'NOTIFICATIONS_SET_AUTO', |
||||
|
payload: id, |
||||
|
}) |
||||
|
|
||||
|
export const showNotification = (type: NotificationType, content: string, expiration: number = 5000): ThunkAction<Promise<void>, AppState, void, AnyAction> => { |
||||
|
return async (dispatch: ThunkDispatch<AppState, void, AnyAction>) => { |
||||
|
const id = v1() |
||||
|
dispatch(addNotification(id, type, content)) |
||||
|
|
||||
|
setTimeout(() => { |
||||
|
dispatch(clearNotification(id)) |
||||
|
}, expiration) |
||||
|
} |
||||
} |
} |
@ -1,6 +1,11 @@ |
|||||
|
@import "../../../node_modules/bulma/sass/utilities/_all.sass"; |
||||
|
@import "../../../node_modules/bulma/sass/base/_all.sass"; |
||||
|
@import "../../../node_modules/bulma/sass/elements/button.sass"; |
||||
|
@import "../../../node_modules/bulma/sass/elements/notification.sass"; |
||||
|
|
||||
div#notification-container { |
div#notification-container { |
||||
bottom: 0; |
|
||||
|
bottom: 10px; |
||||
position: absolute; |
position: absolute; |
||||
right: 0; |
|
||||
width: 25%; |
|
||||
|
right: 10px; |
||||
|
width: 40%; |
||||
} |
} |
@ -1,12 +1,7 @@ |
|||||
import { schema } from 'normalizr' |
import { schema } from 'normalizr' |
||||
|
|
||||
const groupSchema = new schema.Entity('groups') |
|
||||
|
export const groupSchema = new schema.Entity('groups') |
||||
|
|
||||
const userSchema = new schema.Entity('users', { |
|
||||
|
export const userSchema = new schema.Entity('users', { |
||||
groupSchema, |
groupSchema, |
||||
}) |
}) |
||||
|
|
||||
export { |
|
||||
groupSchema, |
|
||||
userSchema, |
|
||||
} |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue