From b0449ccfb7736d8934a55cc3a763e308477ac289 Mon Sep 17 00:00:00 2001 From: Dwayne Harris Date: Fri, 18 Oct 2019 23:55:42 -0400 Subject: [PATCH] WIP --- config/config.json | 7 +- src/actions/groups.ts | 4 +- src/actions/users.ts | 25 ++++ src/components/app-info.tsx | 44 +++++++ src/components/app.tsx | 12 +- src/components/create-group-form.tsx | 15 +-- src/components/create-user-form.tsx | 7 +- src/components/forms/cover-image-field.tsx | 16 +++ src/components/forms/file-field.tsx | 18 +-- src/components/forms/icon-image-field.tsx | 16 +++ src/components/forms/image-field.tsx | 16 +++ src/components/pages/create-app.tsx | 10 ++ src/components/pages/edit-app.tsx | 10 +- src/components/pages/group-admin.tsx | 33 +++++- src/components/pages/self.tsx | 53 +++++---- src/components/pages/view-app.tsx | 67 +++++------ .../pages/{group.tsx => view-group.tsx} | 52 ++++++--- src/components/pages/view-user.tsx | 108 ++++++++++++++++++ src/components/self-info.tsx | 79 +++++++++++++ src/components/user-info.tsx | 91 +++++---------- src/reducers/config.ts | 5 + src/types/config.ts | 9 ++ src/types/entities.ts | 3 + src/types/index.ts | 1 + src/types/store.ts | 7 +- 25 files changed, 531 insertions(+), 177 deletions(-) create mode 100644 src/actions/users.ts create mode 100644 src/components/app-info.tsx create mode 100644 src/components/forms/cover-image-field.tsx create mode 100644 src/components/forms/icon-image-field.tsx create mode 100644 src/components/forms/image-field.tsx rename src/components/pages/{group.tsx => view-group.tsx} (61%) create mode 100644 src/components/pages/view-user.tsx create mode 100644 src/components/self-info.tsx create mode 100644 src/types/config.ts diff --git a/config/config.json b/config/config.json index 811af8c..08be48b 100644 --- a/config/config.json +++ b/config/config.json @@ -1,4 +1,9 @@ { "apiUrl": "http://localhost:5000", - "blobUrl": "https://flexordev.blob.core.windows.net/media/" + "blobUrl": "https://flexordev.blob.core.windows.net/media/", + "media": { + "defaultMaxSize": 5242880, + "coverMaxSize": 5242880, + "iconMaxSize": 1048576 + } } diff --git a/src/actions/groups.ts b/src/actions/groups.ts index a22dc23..fa1a7b7 100644 --- a/src/actions/groups.ts +++ b/src/actions/groups.ts @@ -91,7 +91,9 @@ export const fetchGroup = (id: string): AppThunkAction => { path: `/api/group/${id}` }) - dispatch(setEntity(EntityType.Group, group)) + const groups = normalize([group], EntityType.Group) + + dispatch(setEntities(groups.entities)) dispatch(finishRequest(RequestKey.FetchGroup, true)) } catch (err) { dispatch(finishRequest(RequestKey.FetchGroup, false)) diff --git a/src/actions/users.ts b/src/actions/users.ts new file mode 100644 index 0000000..7a6f017 --- /dev/null +++ b/src/actions/users.ts @@ -0,0 +1,25 @@ +import { apiFetch } from 'src/api' +import { setEntities } from 'src/actions/entities' +import { startRequest, finishRequest } from 'src/actions/requests' +import { AppThunkAction, Entity, RequestKey, EntityType } from 'src/types' +import { normalize } from 'src/utils/normalization' + +export const fetchUser = (id: string): AppThunkAction => { + return async dispatch => { + dispatch(startRequest(RequestKey.FetchUser)) + + try { + const user = await apiFetch({ + path: `/api/user/${id}` + }) + + const users = normalize([user], EntityType.User) + + dispatch(setEntities(users.entities)) + dispatch(finishRequest(RequestKey.FetchUser, true)) + } catch (err) { + dispatch(finishRequest(RequestKey.FetchUser, false)) + throw err + } + } +} diff --git a/src/components/app-info.tsx b/src/components/app-info.tsx new file mode 100644 index 0000000..32bc45a --- /dev/null +++ b/src/components/app-info.tsx @@ -0,0 +1,44 @@ +import React, { FC } from 'react' +import moment from 'moment' + +import { App } from 'src/types' + +interface Props { + app: App +} + +const AppInfo: FC = ({ app }) => ( + +) + +export default AppInfo diff --git a/src/components/app.tsx b/src/components/app.tsx index b279a2d..37cbfa1 100644 --- a/src/components/app.tsx +++ b/src/components/app.tsx @@ -16,14 +16,13 @@ import Footer from './footer' import NavigationMenu from './navigation-menu' import NotificationContainer from './notification-container' import Spinner from './spinner' -import UserInfo from './user-info' +import SelfInfo from './self-info' import About from './pages/about' import Apps from './pages/apps' import CreateApp from './pages/create-app' import Developers from './pages/developers' import EditApp from './pages/edit-app' -import Group from './pages/group' import GroupAdmin from './pages/group-admin' import Groups from './pages/groups' import Home from './pages/home' @@ -32,6 +31,8 @@ import Register from './pages/register' import RegisterGroup from './pages/register-group' import Self from './pages/self' import ViewApp from './pages/view-app' +import ViewGroup from './pages/view-group' +import ViewUser from './pages/view-user' import '../styles/app.scss' import '../styles/spinner.scss' @@ -76,7 +77,7 @@ const App: FC = () => { {fetching && } - +