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

Demo #1

Merged
merged 36 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6901650
Created getGroupById function
matthew-nanthameechai Apr 3, 2024
52caf4b
Start to work on Express route
maitri-thakor Apr 4, 2024
cd82b2a
Merge branch 'dev' into view-single-group
maitri-thakor Apr 4, 2024
8fdca1a
created a get route by id
matthew-nanthameechai Apr 4, 2024
5541be4
Created getGroupById in apiGroup.ts
maitri-thakor Apr 4, 2024
0089511
created single group component
matthew-nanthameechai Apr 4, 2024
4b17e17
create a db function for adding a post
alyssa-bruns Apr 4, 2024
3894f0c
Created getGroupMembersById Function & Get route
maitri-thakor Apr 4, 2024
465da07
Create db function and route for addPost
alyssa-bruns Apr 4, 2024
96ef3fc
got all members
matthew-nanthameechai Apr 4, 2024
e52dfb2
Create db function test
alyssa-bruns Apr 4, 2024
447c87e
linked to single group page
matthew-nanthameechai Apr 4, 2024
9634b11
Create route test for addPost
alyssa-bruns Apr 4, 2024
a201f98
Merge branch 'dev' into create-new-post
alyssa-bruns Apr 4, 2024
28daa11
make a add post api client function
alyssa-bruns Apr 4, 2024
2d5c45f
Merge branch 'dev' into view-single-group
matthew-nanthameechai Apr 4, 2024
cfe397f
create hook for addPost
alyssa-bruns Apr 4, 2024
e53b9e6
Install react ticker
jess-bay Apr 4, 2024
2fe521d
Merge branch 'dev' into ticker
jess-bay Apr 4, 2024
b1853c5
simple commit to be able to switch branches and do some pulls
alyssa-bruns Apr 4, 2024
f0b0020
Merge branch 'dev' into create-new-post
alyssa-bruns Apr 4, 2024
cb96744
Co-authored-by: Matthew <[email protected]>
matthew-nanthameechai Apr 4, 2024
1b618d1
add ticker to weather component
HarrisonRogers Apr 4, 2024
4865059
resolve typescript error & join user data for getGroupmembersById
maitri-thakor Apr 4, 2024
5776c9f
Disply member list data & add some css on Group profile page
maitri-thakor Apr 4, 2024
fa1ba60
Completed Css work for Group member list
maitri-thakor Apr 4, 2024
b040c2a
get form working and styling
alyssa-bruns Apr 4, 2024
710ef20
Merge branch 'dev' into view-single-group
jatin-puri-coder Apr 4, 2024
6155b37
Merge branch 'dev' into ticker
jatin-puri-coder Apr 4, 2024
e67f29c
Merge branch 'dev' into ticker
jess-bay Apr 4, 2024
195fb76
Merge branch 'ticker' of https://github.com/tohora-2024/kes-ke-say in…
jatin-puri-coder Apr 4, 2024
8f5d293
remove weather test
jatin-puri-coder Apr 5, 2024
ba4e642
Merge branch 'ticker' into demo
jatin-puri-coder Apr 5, 2024
6133d75
Merge branch 'dev' into create-new-post
jatin-puri-coder Apr 5, 2024
a3d261a
fix add post
jatin-puri-coder Apr 5, 2024
fd0d94a
Merge branch 'create-new-post' into demo
jatin-puri-coder Apr 5, 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
6 changes: 5 additions & 1 deletion client/apis/apiClient.posts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import request from 'superagent'
import { Post } from '../../models/post'
import { NewPost, Post } from '../../models/post'

const root = '/api/v1/posts'

Expand All @@ -12,3 +12,7 @@ export async function getSinglePost(id: number) {
const res = await request.get(`${root}/post/${id}`)
return res.body
}

export async function addPost(newPost: NewPost): Promise<void> {
await request.post(`${root}/post/`).send(newPost)
}
12 changes: 11 additions & 1 deletion client/apis/apiGroup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import request from 'superagent'
import { group } from '../../models/group'
import { group, member } from '../../models/group'

const rootUrl = '/api/v1/groups'

export async function getAllGroups(): Promise<group[]> {
const res = await request.get(rootUrl)
return res.body
}

export async function getGroupById(id: number): Promise<group> {
const res = await request.get(`${rootUrl}/${id}`)
return res.body
}

export async function getGroupMembersById(id: number): Promise<member[]> {
const res = await request.get(`${rootUrl}/members/${id}`)
return res.body
}
81 changes: 81 additions & 0 deletions client/components/AddPost.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { ChangeEvent, useCallback, useState } from 'react'
import useAddPost from '../hooks/use-add-post'
import { useNavigate } from 'react-router-dom'

export function AddPost() {
const [newPost, setNewPost] = useState('')
const [newImage, setNewImage] = useState('')
const [currentUser, setCurrentUser] = useState('')
// const [timestamp, setTimestamp] = useState()
const navigate = useNavigate()
const mutation = useAddPost()

const handleBodyChange = (e: ChangeEvent<HTMLInputElement>) => {
setNewPost(e.target.value)
}

const handleImageChange = (e: ChangeEvent<HTMLInputElement>) => {
setNewImage(e.target.value)
}

const handleUserChange = (e: ChangeEvent<HTMLSelectElement>) => {
setCurrentUser(e.target.value)
}

// const handleTimestamp = (e: ChangeEvent<HTMLSelectElement>) => {
// setTimestamp(Date.now())
// }

const handleSubmit = useCallback(
async (e: React.FormEvent) => {
e.preventDefault()
mutation.mutate({ body: newPost, image: newImage, user_id: currentUser })
setNewPost('')
setNewImage('')
navigate('/')
},
[mutation, newPost, newImage, navigate, currentUser]
)

return (
<>
<div className="h-screen flex flex-col items-center justify-center">
<form onSubmit={handleSubmit}>
<label htmlFor="user_id">Select User: </label>
<select
className="bg-grey-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
id="user_id"
onChange={handleUserChange}
>
<option value="1">Paige</option>
<option value="2">Ida</option>
<option value="3">Shaq</option>
<option value="4">Chris</option>
</select>
<br />
<label htmlFor="body">Body Text: </label>
<input
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="Say what you feel"
onChange={handleBodyChange}
value={newPost}
id="body"
></input>
<br />
<label htmlFor="image">Image Link: </label>
<input
placeholder="Image link here"
onChange={handleImageChange}
value={newImage}
id="image"
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
></input>
<br />
<button className="bg-blue-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
Send post
</button>
</form>
</div>
</>
)
}
85 changes: 44 additions & 41 deletions client/components/AllGroups.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getAllGroups } from '../apis/apiGroup'
import { useQuery } from '@tanstack/react-query'
import { Link } from 'react-router-dom'

export function AllGroups() {
const {
Expand All @@ -14,7 +15,7 @@ export function AllGroups() {
return <h1>Loading...GroupPage</h1>
}

if (isError) {
if (isError || !groupsData) {
return <h1>Error</h1>
}

Expand All @@ -23,49 +24,51 @@ export function AllGroups() {
<h1>All groups</h1>
<div className="p-24 flex flex-wrap items-center justify-center">
{groupsData.map((group) => (
<div
key={group.id}
className="flex-shrink-0 m-6 relative overflow-hidden mt-auto bg-gradient-to-r from-gray-100 via-[#bce1ff] to-gray-1000 rounded-lg max-w-xs shadow-lg"
>
<svg
className="absolute bottom-0 left-0 mb-8 "
viewBox="0 0 375 283"
fill="none"
<Link key={group.id} to={`/groups/${group.id}`}>
<div
key={group.id}
className="flex-shrink-0 m-6 relative overflow-hidden mt-auto bg-gradient-to-r from-gray-100 via-[#bce1ff] to-gray-1000 rounded-lg max-w-xs shadow-lg"
>
<rect
x="159.52"
y="175"
width="152"
height="152"
rx="8"
transform="rotate(-45 159.52 175)"
fill="white"
/>
<rect
y="107.48"
width="152"
height="152"
rx="8"
transform="rotate(-45 0 107.48)"
fill="white"
/>
</svg>
<div className="relative pt-10 px-10 flex items-center justify-center">
<div className="block absolute w-48 h-48 bottom-0 left-0 -mb-24 ml-3"></div>
<img
className="relative w-40"
src={`/images/icons/${group.image}`}
alt={group.name}
/>
</div>
<div className="relative text-black px-6 pb-6 mt-6">
<div className="flex justify-between">
<span className="block font-semibold text-xl">
{group.name}
</span>
<svg
className="absolute bottom-0 left-0 mb-8 "
viewBox="0 0 375 283"
fill="none"
>
<rect
x="159.52"
y="175"
width="152"
height="152"
rx="8"
transform="rotate(-45 159.52 175)"
fill="white"
/>
<rect
y="107.48"
width="152"
height="152"
rx="8"
transform="rotate(-45 0 107.48)"
fill="white"
/>
</svg>
<div className="relative pt-10 px-10 flex items-center justify-center">
<div className="block absolute w-48 h-48 bottom-0 left-0 -mb-24 ml-3"></div>
<img
className="relative w-40"
src={`/images/icons/${group.image}`}
alt={group.name}
/>
</div>
<div className="relative text-black px-6 pb-6 mt-6">
<div className="flex justify-between">
<span className="block font-semibold text-xl">
{group.name}
</span>
</div>
</div>
</div>
</div>
</Link>
))}
</div>
</>
Expand Down
58 changes: 58 additions & 0 deletions client/components/GroupMemberList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useParams } from 'react-router-dom'
import { getGroupMembersById } from '../apis/apiGroup'
import { useQuery } from '@tanstack/react-query'

export function GroupMemberList() {
const { id } = useParams()
const {
isLoading,
isError,
data: memberData,
} = useQuery({
queryKey: ['member', id],
queryFn: () => getGroupMembersById(Number(id)),
})
console.log(memberData)
if (isLoading) {
return <h1>Loading...GroupPage</h1>
}

if (isError || !memberData) {
return <h1>Error</h1>
}

return (
<>
<div className="flex flex-col items-center justify-center min-h-screen p-16 bg-slate-200">
<h1 className="my-10 font-medium text-3xl sm:text-4xl font-black">
Members List
</h1>
<div className="mb-4"></div>
<div className="user-list w-full max-w-lg mx-auto bg-white rounded-xl shadow-xl flex flex-col py-4">
{memberData.map((member) => (
<div
key={member.id}
className="user-row flex flex-col items-center justify-between cursor-pointer p-4 duration-300 sm:flex-row sm:py-4 sm:px-8 hover:bg-[#87c7ea]"
>
<div className="user flex items-center text-center flex-col sm:flex-row sm:text-left">
<div className="avatar-content mb-2.5 sm:mb-0 sm:mr-2.5">
<img
src={`/images/avatars/${member.image}`}
alt={member.image}
/>
</div>
<div className="user-body flex flex-col mb-4 sm:mb-0 sm:mr-4">
<a href="#" className="title font-medium no-underline">
{member.fullName}
</a>
<div className="skills flex flex-col"></div>
</div>
</div>
</div>
))}
</div>
</div>
</>
)
}
export default GroupMemberList
78 changes: 78 additions & 0 deletions client/components/GroupProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { useParams } from 'react-router-dom'
import { getGroupById } from '../apis/apiGroup'
import { useQuery } from '@tanstack/react-query'
import GroupMemberList from './GroupMemberList'

export function GroupProfilePage() {
const { id } = useParams()
const {
isLoading,
isError,
data: groupData,
} = useQuery({
queryKey: ['group', id],
queryFn: () => getGroupById(Number(id)),
})

if (isLoading) {
return <h1>Loading...GroupPage</h1>
}

if (isError || !groupData) {
return <h1>Error</h1>
}

return (
<>
<div className="p-24 flex flex-wrap items-center justify-center">
<div className="header flex w-full justify-center">
<h2 className="font-black pb-10 mb-20 text-5xl text-blue-900 before:block before:absolute before:bg-sky-200 relative before:w-1/3 before:h-1 before:bottom-0 before:left-1/3">
{groupData?.name}
</h2>
</div>
<div
key={groupData.id}
className="flex-shrink-0 m-6 relative overflow-hidden mt-auto bg-gradient-to-r from-gray-100 via-[#bce1ff] to-gray-1000 rounded-lg max-w-xs shadow-lg"
>
<svg
className="absolute bottom-0 left-0 mb-8 "
viewBox="0 0 375 283"
fill="none"
>
<rect
x="159.52"
y="175"
width="152"
height="152"
rx="8"
transform="rotate(-45 159.52 175)"
fill="white"
/>
<rect
y="107.48"
width="152"
height="152"
rx="8"
transform="rotate(-45 0 107.48)"
fill="white"
/>
</svg>
<div className="relative pt-10 px-10 flex items-center justify-center">
<div className="block absolute w-48 h-48 bottom-0 left-0 -mb-24 ml-3"></div>
<img
className="relative w-40"
src={`/images/icons/${groupData?.image}`}
alt={groupData?.name}
/>
</div>
<div className="relative text-black px-6 pb-6 mt-6">
<div className="flex justify-between"></div>
</div>
</div>
</div>

<GroupMemberList />
</>
)
}
export default GroupProfilePage
Loading
Loading