Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M-6 Activity Create UI #12

Merged
merged 69 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
237380b
M-6 Activity Create page
SachiGoto Dec 3, 2023
aabcbb9
M-6 Activity Create Page
SachiGoto Dec 3, 2023
eb91e11
tailored the form to the figma design
SachiGoto Dec 5, 2023
f62e107
added zod validation and used form hook react for form
SachiGoto Dec 6, 2023
d1f92fb
added note
SachiGoto Dec 6, 2023
129db0c
Merge branch 'main' into activity-create
SachiGoto Dec 6, 2023
54dad88
fix lint error
SachiGoto Dec 6, 2023
cef4e86
updated based on feedback
SachiGoto Dec 12, 2023
5a08291
fix lint error
SachiGoto Dec 12, 2023
dc8d608
added customized day time picker
SachiGoto Dec 29, 2023
2aee48d
got rid of seconds
SachiGoto Dec 29, 2023
39fc7ef
added css style to have the calendar positioned at the bottom of each…
SachiGoto Dec 29, 2023
774986a
css adjustment
SachiGoto Dec 29, 2023
6ae4700
changed input focus color to primary color
SachiGoto Dec 29, 2023
765b074
commit
SachiGoto Jan 4, 2024
1f8125f
implemented signin
Yo-mah-Ya Dec 5, 2023
28657c1
rename folders
Yo-mah-Ya Dec 5, 2023
afadc75
fixed
Yo-mah-Ya Dec 5, 2023
7ce5437
fixed routing
Yo-mah-Ya Dec 7, 2023
b87a8bc
renamed action.ts
Yo-mah-Ya Dec 7, 2023
1b13037
added Username field to signup
Yo-mah-Ya Dec 8, 2023
10bfead
added build process to CI
Yo-mah-Ya Dec 8, 2023
0c560fd
rename variables
Yo-mah-Ya Dec 13, 2023
3d7c8b6
Add tripe details header
kanatagu Dec 17, 2023
6683985
Add roundIcon variant button
kanatagu Dec 17, 2023
ca25316
Add activity card
kanatagu Dec 19, 2023
1299b01
Deleted code and test picture
kanatagu Dec 19, 2023
94d63a0
Change to UUID
kanatagu Dec 20, 2023
4cecdda
Fix for reviews
kanatagu Dec 23, 2023
067a8f1
Fix type
kanatagu Dec 23, 2023
128fbc4
Add Todo comment for date format
kanatagu Dec 23, 2023
551d754
Enable UUID coming from user session usable everywhere
Yo-mah-Ya Dec 19, 2023
3da07b1
fix CI
Yo-mah-Ya Dec 19, 2023
7f83955
put all providers into providers folder
Yo-mah-Ya Dec 19, 2023
56d73d1
fix providers
Yo-mah-Ya Dec 21, 2023
a644b0b
fix how to append multiple cookies
Yo-mah-Ya Dec 21, 2023
fac749d
refactored middleware
Yo-mah-Ya Dec 22, 2023
2be24e0
format
SachiGoto Jan 4, 2024
edd889f
Revert "format"
SachiGoto Jan 4, 2024
0aa506e
Merge branch 'main' into activity-create
SachiGoto Jan 4, 2024
7b8b64a
format
SachiGoto Jan 4, 2024
07cad6f
fix type error
SachiGoto Jan 4, 2024
8d06e7a
adjusted a few things based on feedback
SachiGoto Jan 4, 2024
11fb113
Change Date
kanatagu Dec 23, 2023
8f213f6
Installed dependencies
kanatagu Dec 23, 2023
2596b9a
Set up test and fix tabs for different date
kanatagu Dec 24, 2023
512eabe
Add test for trip details tabs
kanatagu Dec 25, 2023
c44b7cf
Add test action
kanatagu Jan 5, 2024
a90971e
feat: Add Account layout and page components.
samuraikun Dec 2, 2023
8bb09d9
Add new GraphQL query to fetch user
samuraikun Dec 3, 2023
cf3e1de
chore: buid with turbopack
samuraikun Dec 8, 2023
c1ca210
fix: Refactor account page and remove loading component
samuraikun Dec 8, 2023
2495ae5
chore: cosmetic MenuItem color & fix npm script
samuraikun Dec 8, 2023
d815286
fix: fix UI layout based on Figma.
samuraikun Dec 22, 2023
b3de7f1
chore: disable underline when hover account link
samuraikun Dec 22, 2023
013d8ba
fix: access account page via session uuid using useUserUuid hook
samuraikun Jan 4, 2024
c5e56e8
Add margin bottom to account page & AlertButton props
samuraikun Jan 4, 2024
5826f5a
Fix style
kanatagu Jan 4, 2024
e366c06
chore: remove account/error.tsx
samuraikun Jan 4, 2024
0d7cbd1
Add password change link in account page.
samuraikun Jan 4, 2024
6a0a663
implemeneted signout
Yo-mah-Ya Dec 20, 2023
bffa2c7
changed cookie name of user UUID
Yo-mah-Ya Dec 29, 2023
19481d7
moved logout component to auth
Yo-mah-Ya Jan 5, 2024
dc61a00
replaced seiral based id with uuid using graphql-codegen
Yo-mah-Ya Jan 6, 2024
3407a71
replaced uuid with id
Yo-mah-Ya Jan 6, 2024
8dc5753
fixed query param
Yo-mah-Ya Jan 7, 2024
dfcb458
Merge branch 'main' into activity-create
SachiGoto Jan 9, 2024
105ac44
merge
SachiGoto Jan 11, 2024
2f3c1f7
Merge branch 'main' into activity-create
SachiGoto Jan 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions app/activity/create/components/form.tsx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the title field required so that people can quickly add a new activity and add more information later.

I am unsure about how we are handling images. Are we storing images in the cloud and storing their CDN in the database? Currently, once images are added and the submit button is clicked, it stores image information like the example below:
Screenshot 2023-12-03 at 2 01 57 AM

Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import React, { useCallback, useState } from 'react'
import { useDropzone } from 'react-dropzone'
import {
Box,
Container,
FormControl,
FormLabel,
Input,
Button,
Textarea,
Image,
SimpleGrid,
Text,
Flex
} from '@chakra-ui/react'

import { PrimaryButton } from '@/components/button'

export const Form = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to say FormActivity which is more clearly and easier to search!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name to FormActivity!

const [selectedImages, setSelectedImages] = useState<File[]>([])

const onDrop = useCallback((acceptedFiles: File[]) => {
setSelectedImages((prevImages) => [...prevImages, ...acceptedFiles])
}, [])
const { getRootProps, getInputProps } = useDropzone({ onDrop })
function removeImage(index: number) {
setSelectedImages((prevImages) => {
const newImages = [...prevImages]
newImages.splice(index, 1)
return newImages
})
}

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()

const formData = new FormData(event.currentTarget)
const title = formData.get('title') as string
const address = formData.get('address') as string
const timeFrom = formData.get('timeFrom') as string
const timeTo = formData.get('timeTo') as string
const url = formData.get('url') as string
const memo = formData.get('memo') as string
const cost = formData.get('cost') as string

console.log({
title,
address,
timeFrom,
timeTo,
url,
memo,
cost,
selectedImages
})
}


return (
<Container
pt={{ base: '40px', md: '40px' }}
pb={{ base: '40px', md: '80px' }}
>
<form onSubmit={handleSubmit}>
<FormControl isRequired>
<FormLabel>Title</FormLabel>
<Input name="title" type="text" placeholder="Enter title" />
</FormControl>

<FormControl mt={{ base: '30px', md: '40px' }}>
<FormLabel>Address</FormLabel>
<Input name="address" type="text" placeholder="Enter address" />
</FormControl>

<FormControl mt={{ base: '30px', md: '40px' }}>
<FormLabel>Time From</FormLabel>
<Input name="timeFrom" type="time" />
</FormControl>

<FormControl mt={{ base: '30px', md: '40px' }}>
<FormLabel>Time To</FormLabel>
<Input name="timeTo" type="time" />
</FormControl>

<FormControl mt={{ base: '30px', md: '40px' }}>
<FormLabel>URL</FormLabel>
<Input name="url" type="url" placeholder="Enter URL" />
</FormControl>

<Text mt={{ base: '30px', md: '40px' }} fontWeight="medium">
Image
</Text>
<SimpleGrid
mt={{ base: '30px', md: '40px' }}
columns={{ base: 2, md: 3 }}
spacing={4}
>
{selectedImages.map((image, index) => (
<Image
key={index}
src={URL.createObjectURL(image)}
alt={`Selected Image ${image.name}`}
objectFit="cover"
width={{ base: '160px', md: '180px' }}
height={{ base: '106px', md: '120px' }}
margin="auto"
onClick={() => removeImage(index)}
/>
))}
</SimpleGrid>

<Box
{...getRootProps()}
textAlign="center"
mt={{ base: '30px', md: '40px' }}
>
<PrimaryButton variant="outline">
<input {...getInputProps()} />
Add Image
</PrimaryButton>
</Box>

<FormControl mt={{ base: '30px', md: '40px' }}>
<FormLabel>Memo</FormLabel>
<Textarea name="memo" placeholder="Enter memo" />
</FormControl>

<FormControl mt={{ base: '30px', md: '40px' }}>
<FormLabel>Cost</FormLabel>
<Input name="cost" type="number" placeholder="Enter cost" />
</FormControl>


<Flex justifyContent="center">
<Button
mt={{ base: '30px', md: '40px' }}
colorScheme="teal"
type="submit"
margin="auto"
>
Create Activity
</Button>
</Flex>
</form>
</Container>
)
}
1 change: 1 addition & 0 deletions app/activity/create/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {Form} from "./form"
39 changes: 39 additions & 0 deletions app/activity/create/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use client'

import {
Box,
Container,
Heading,
useColorModeValue
} from '@chakra-ui/react'
import { Header, Footer } from '@/components/navigation'
import {Form} from "./components"


export default function Create() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to name like CreateActivityPage which is more clear!


const bg = useColorModeValue('white', 'gray.800')
const color = useColorModeValue('black', 'gray.300')

return (
<>
<Box as="main" minH="100vh" bg={bg} color={color}>
<Header />
<Container
maxW={{ base: '100%', md: 'container.md' }}
pt={{ base: '20px', md: '30px' }}
pb={{ base: '40px', md: '80px' }}
margin="auto"
>
<Container>
<Heading as={'h1'} fontSize={{ base: '2xl', md: '4xl' }}>
Create Activity
</Heading>
</Container>
<Form />
</Container>
Copy link
Contributor

@kanatagu kanatagu Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Container /> is usually one per page. Please change to one <Container /> with container.md for PC as you already use for top layer. You don't need to use <Container /> in Form component too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the extra container tags in page.tsx under the create directory, and removed container tags in form.tsx under the components directory. Could you please take a quick look and let me know if it looks good?

<Footer />
</Box>
</>
)
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"graphql": "^16.8.1",
"next": "14.0.1",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"react-dropzone": "^14.2.3"
},
"devDependencies": {
"@chakra-ui/storybook-addon": "^5.0.1",
Expand Down
27 changes: 27 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.