Skip to content

Commit

Permalink
Merge pull request #111 from ayahiro1729/110/aoyama/isFollowUI
Browse files Browse the repository at this point in the history
follow状態の確認
  • Loading branch information
sekibuuun authored Oct 9, 2024
2 parents 26b937c + 6c2e4aa commit 9192bdb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
20 changes: 15 additions & 5 deletions frontend/app/components/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useState, useEffect } from 'react'
import { Button } from '~/components/ui/button'
import X from '/x_logo.png'
import Instagram from '/instagram_logo.png'
Expand All @@ -8,9 +8,19 @@ import { Form, useParams } from "@remix-run/react";
const Profile: React.FC<ProfileProps> = ({displayName, iconImage, xLink, instagramLink, myUserId}) => {
const params = useParams()
const pageUserId = params.user_id
const [isFollowed, setIsFollowed] = useState<boolean>(false)

// TODO: フォロー状態の確認
const isFollowed = false
useEffect(() => {
const followJudge = async () => {
const response = await fetch(`http://localhost:8080/api/v1/is_following/${myUserId}/${pageUserId}`)
if (!response.ok) {
throw new Error (`Failed to fetch follower data: ${response.statusText}`)
}
const data = await response.json()
setIsFollowed(data.is_following)
}
followJudge()
}, [isFollowed])

return (
<div className='flex flex-col gap-4'>
Expand All @@ -26,12 +36,12 @@ const Profile: React.FC<ProfileProps> = ({displayName, iconImage, xLink, instagr
<Form method='post' action='/unfollow'>
<input type='hidden' name='followings_id' value={pageUserId}/>
{ myUserId && <input type='hidden' name='follower_id' value={myUserId}/> }
<Button type='submit' name='_action' aria-label='delete' value='delete'>Unfollow</Button>
<Button type='submit' name='_action' aria-label='delete' value='delete' onClick={() => location.reload()}>Unfollow</Button>
</Form> :
<Form method='post' action='/follow'>
<input type='hidden' name='followings_id' value={pageUserId}/>
{ myUserId && <input type='hidden' name='follower_id' value={myUserId}/> }
<Button type='submit' name='_action' aria-label='post' value='post' variant="outline">Follow</Button>
<Button type='submit' name='_action' aria-label='post' value='post' variant="outline" onClick={() => location.reload()}>Follow</Button>
</Form>
}
</div>
Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/UserSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const UserSearch = () => {
<PlaceholdersAndVanishInput
placeholders={placeholders}
onChange={handleChange}
onSubmit={() => {}}
/>
</div>
</DialogHeader>
Expand Down
9 changes: 0 additions & 9 deletions frontend/app/routes/Follow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,4 @@ export const action = async ({ request }: ActionFunctionArgs) => {
}

return redirect(`/user/${followings_id}`)
}

export default function Follow() {

return (
<div>
<p>Follow</p>
</div>
)
}
9 changes: 0 additions & 9 deletions frontend/app/routes/Unfollow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,4 @@ export const action = async ({ request }: ActionFunctionArgs) => {
}

return redirect(`/user/${followings_id}`)
}

export default function UnFollow() {

return (
<div>
<p>UnFollow</p>
</div>
)
}
1 change: 0 additions & 1 deletion frontend/app/routes/user.$user_id_.edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export default function EditContact() {
return (
<div>
<Header
iconImage={userInfo.iconImage}
myUserId={myUserId}
/>
<div className="p-4 pt-20">
Expand Down

0 comments on commit 9192bdb

Please sign in to comment.