diff --git a/web/src/Routes.js b/web/src/Routes.js index 798f9e5..b7a253c 100644 --- a/web/src/Routes.js +++ b/web/src/Routes.js @@ -16,7 +16,8 @@ const Routes = () => { {/* */} - + + {/* GENERATED ROUTES BELOW, probably going to clean these up and delete most of them, but the CRUD functionality is useful for now */} diff --git a/web/src/components/Button/Button.js b/web/src/components/Button/Button.js index 38277a1..c327ec1 100644 --- a/web/src/components/Button/Button.js +++ b/web/src/components/Button/Button.js @@ -1,6 +1,6 @@ import Svg from 'src/components/Svg' -const Button = ({onClick, children}) => { +const Button = ({onClick, iconName, children}) => { return (
) diff --git a/web/src/components/EditUser2Cell/EditUser2Cell.js b/web/src/components/EditUser2Cell/EditUser2Cell.js new file mode 100644 index 0000000..07656aa --- /dev/null +++ b/web/src/components/EditUser2Cell/EditUser2Cell.js @@ -0,0 +1,25 @@ +import UserProfile from 'src/components/UserProfile' + +export const QUERY = gql` + query FIND_USER_BY_ID($userName: String!) { + user: userName(userName: $userName) { + id + userName + email + createdAt + updatedAt + image + bio + } + } +` + +export const Loading = () =>
Loading...
+ +export const Empty = () =>
Empty
+ +export const Failure = ({ error }) =>
Error: {error.message}
+ +export const Success = ({ user }) => { + return +} diff --git a/web/src/components/EditUser2Cell/EditUser2Cell.mock.js b/web/src/components/EditUser2Cell/EditUser2Cell.mock.js new file mode 100644 index 0000000..99b257c --- /dev/null +++ b/web/src/components/EditUser2Cell/EditUser2Cell.mock.js @@ -0,0 +1,6 @@ +// Define your own mock data here: +export const standard = (/* vars, { ctx, req } */) => ({ + editUser2: { + id: 42, + }, +}) diff --git a/web/src/components/EditUser2Cell/EditUser2Cell.stories.js b/web/src/components/EditUser2Cell/EditUser2Cell.stories.js new file mode 100644 index 0000000..d416704 --- /dev/null +++ b/web/src/components/EditUser2Cell/EditUser2Cell.stories.js @@ -0,0 +1,20 @@ +import { Loading, Empty, Failure, Success } from './EditUser2Cell' +import { standard } from './EditUser2Cell.mock' + +export const loading = () => { + return Loading ? : null +} + +export const empty = () => { + return Empty ? : null +} + +export const failure = () => { + return Failure ? : null +} + +export const success = () => { + return Success ? : null +} + +export default { title: 'Cells/EditUser2Cell' } diff --git a/web/src/components/EditUser2Cell/EditUser2Cell.test.js b/web/src/components/EditUser2Cell/EditUser2Cell.test.js new file mode 100644 index 0000000..eb9b86f --- /dev/null +++ b/web/src/components/EditUser2Cell/EditUser2Cell.test.js @@ -0,0 +1,26 @@ +import { render, screen } from '@redwoodjs/testing' +import { Loading, Empty, Failure, Success } from './EditUser2Cell' +import { standard } from './EditUser2Cell.mock' + +describe('EditUser2Cell', () => { + test('Loading renders successfully', () => { + render() + // Use screen.debug() to see output + expect(screen.getByText('Loading...')).toBeInTheDocument() + }) + + test('Empty renders successfully', async () => { + render() + expect(screen.getByText('Empty')).toBeInTheDocument() + }) + + test('Failure renders successfully', async () => { + render() + expect(screen.getByText(/Oh no/i)).toBeInTheDocument() + }) + + test('Success renders successfully', async () => { + render() + expect(screen.getByText(/42/i)).toBeInTheDocument() + }) +}) diff --git a/web/src/components/ImageUploader/ImageUploader.js b/web/src/components/ImageUploader/ImageUploader.js index 1d2a614..819b236 100644 --- a/web/src/components/ImageUploader/ImageUploader.js +++ b/web/src/components/ImageUploader/ImageUploader.js @@ -68,9 +68,9 @@ export default function ImageUploader({ onImageUpload, imageUrl, aspectRatio, cl } {!cloudinaryId && } {!cloudinaryId && isEditable &&
-
+
Drop files here ... - or + or upload
diff --git a/web/src/components/ProfileTextInput/ProfileTextInput.js b/web/src/components/ProfileTextInput/ProfileTextInput.js new file mode 100644 index 0000000..d0b07d5 --- /dev/null +++ b/web/src/components/ProfileTextInput/ProfileTextInput.js @@ -0,0 +1,29 @@ +import {Fragment, useState} from 'react' + +const ProfileTextInput = ({fields, isEditable, onChange= () => {}}) => { + const keyValueDisplay = Object.entries(fields) + return ( +
+
+ {keyValueDisplay.map(([property, value]) => ( + {property}: + { + isEditable ? +
+
+ onChange({...fields, [property]: target.value})} + value={value} + type="text" + /> +
: + {value} + } + ))} +
+
+ ) +} + +export default ProfileTextInput diff --git a/web/src/components/ProfileTextInput/ProfileTextInput.stories.js b/web/src/components/ProfileTextInput/ProfileTextInput.stories.js new file mode 100644 index 0000000..daef953 --- /dev/null +++ b/web/src/components/ProfileTextInput/ProfileTextInput.stories.js @@ -0,0 +1,7 @@ +import ProfileTextInput from './ProfileTextInput' + +export const generated = () => { + return +} + +export default { title: 'Components/ProfileTextInput' } diff --git a/web/src/components/ProfileTextInput/ProfileTextInput.test.js b/web/src/components/ProfileTextInput/ProfileTextInput.test.js new file mode 100644 index 0000000..e5f6e14 --- /dev/null +++ b/web/src/components/ProfileTextInput/ProfileTextInput.test.js @@ -0,0 +1,11 @@ +import { render } from '@redwoodjs/testing' + +import ProfileTextInput from './ProfileTextInput' + +describe('ProfileTextInput', () => { + it('renders successfully', () => { + expect(() => { + render() + }).not.toThrow() + }) +}) diff --git a/web/src/components/User2Cell/User2Cell.js b/web/src/components/User2Cell/User2Cell.js index 791cbb7..faea1cd 100644 --- a/web/src/components/User2Cell/User2Cell.js +++ b/web/src/components/User2Cell/User2Cell.js @@ -1,8 +1,4 @@ -import User from 'src/components/User' -import {Fragment} from 'react' -import ImageUploader from 'src/components/ImageUploader' -import Button from 'src/components/Button' -import Editor from "rich-markdown-editor"; +import UserProfile from 'src/components/UserProfile' export const QUERY = gql` query FIND_USER_BY_ID($userName: String!) { @@ -22,40 +18,6 @@ export const Loading = () =>
Loading...
export const Empty = () =>
User not found
-export const Success = ({ user }) => { - const {userName, email} = user - const keyValueDisplay = Object.entries({userName, name: email}) // TODO add name field to user - return ( - <> -
-
-
- -
-
-
- {keyValueDisplay.map(([property, value]) => ( - {property}: - {value} - ))} -
- -
-
-
-

Bio:

-
- -
-
-
- - ) +export const Success = ({user}) => { + return } diff --git a/web/src/components/UserProfile/UserProfile.js b/web/src/components/UserProfile/UserProfile.js new file mode 100644 index 0000000..62bf827 --- /dev/null +++ b/web/src/components/UserProfile/UserProfile.js @@ -0,0 +1,46 @@ +import {Fragment} from 'react' +import ImageUploader from 'src/components/ImageUploader' +import Button from 'src/components/Button' +import Editor from "rich-markdown-editor"; +import ProfileTextInput from 'src/components/ProfileTextInput' + + +const UserProfile = ({user, isEditable}) => { + console.log(isEditable) + const {userName, email} = user + const editableTextFields = {userName, name: email} // TODO add name field to user + return ( + <> +
+
+
+ +
+
+ + {isEditable ? + : // TODO replace pencil with a save icon + + } +
+
+
+

Bio:

+
+ +
+
+
+ + ) +} + +export default UserProfile diff --git a/web/src/components/UserProfile/UserProfile.stories.js b/web/src/components/UserProfile/UserProfile.stories.js new file mode 100644 index 0000000..f53091f --- /dev/null +++ b/web/src/components/UserProfile/UserProfile.stories.js @@ -0,0 +1,7 @@ +import UserProfile from './UserProfile' + +export const generated = () => { + return +} + +export default { title: 'Components/UserProfile' } diff --git a/web/src/components/UserProfile/UserProfile.test.js b/web/src/components/UserProfile/UserProfile.test.js new file mode 100644 index 0000000..d4ffd8d --- /dev/null +++ b/web/src/components/UserProfile/UserProfile.test.js @@ -0,0 +1,11 @@ +import { render } from '@redwoodjs/testing' + +import UserProfile from './UserProfile' + +describe('UserProfile', () => { + it('renders successfully', () => { + expect(() => { + render() + }).not.toThrow() + }) +}) diff --git a/web/src/index.css b/web/src/index.css index 5b01aec..46d152f 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -36,7 +36,7 @@ body { /* TODO can I use a tailwind class here? */ - background-color: #E5E5E5; + background-color: #f7fafc; } button, input, label, textarea { diff --git a/web/src/pages/EditUser2Page/EditUser2Page.js b/web/src/pages/EditUser2Page/EditUser2Page.js new file mode 100644 index 0000000..767effa --- /dev/null +++ b/web/src/pages/EditUser2Page/EditUser2Page.js @@ -0,0 +1,12 @@ +import MainLayout from 'src/layouts/MainLayout' +import EditUser2Cell from 'src/components/EditUser2Cell' + +const UserPage = ({ userName }) => { + return ( + + + + ) +} + +export default UserPage diff --git a/web/src/pages/UserPage2/UserPage2.js b/web/src/pages/User2Page/User2Page.js similarity index 100% rename from web/src/pages/UserPage2/UserPage2.js rename to web/src/pages/User2Page/User2Page.js