-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update URLTranslationForm and VoteButtons components
- Loading branch information
Showing
10 changed files
with
132 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,69 @@ | ||
import type { User } from "@prisma/client"; | ||
import { Link } from "@remix-run/react"; | ||
import { TranslationLanguageSelect } from "./TranslationLanguageSelect"; | ||
import { Form, useSubmit } from "@remix-run/react"; | ||
import { TranslationLanguageSelect } from "./TranslationLanguageSelect"; | ||
|
||
type UserWithoutPassword = Omit<User, "password">; | ||
|
||
interface HeaderProps { | ||
user: UserWithoutPassword | null; | ||
language: string; | ||
user: UserWithoutPassword | null; | ||
language: string; | ||
} | ||
|
||
export function Header({ user, language }: HeaderProps) { | ||
const submit = useSubmit(); | ||
const submit = useSubmit(); | ||
|
||
const handleLanguageChange = (newLanguage: string) => { | ||
const formData = new FormData(); | ||
formData.append("language", newLanguage); | ||
submit(formData, { method: "post" }); | ||
}; | ||
return ( | ||
<header className="bg-white shadow-sm"> | ||
<div className="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8 flex justify-between items-center"> | ||
<Link to="/"> | ||
<h1 className="text-3xl font-bold text-gray-900">EveEve</h1> | ||
</Link> | ||
<div className="flex items-center space-x-4"> | ||
<Form method="post"> | ||
<TranslationLanguageSelect | ||
value={language} | ||
onChange={handleLanguageChange} | ||
/> | ||
</Form> | ||
<nav> | ||
{user ? ( | ||
<div className="flex items-center space-x-4"> | ||
<span className="text-gray-700">ようこそ、{user.name}さん!</span> | ||
<Link | ||
to="/auth/logout" | ||
className="text-blue-600 hover:text-blue-800 font-medium" | ||
> | ||
ログアウト | ||
</Link> | ||
</div> | ||
) : ( | ||
<div className="space-x-4"> | ||
<Link | ||
to="/auth/login" | ||
className="text-blue-600 hover:text-blue-800 font-medium" | ||
> | ||
ログイン | ||
</Link> | ||
<Link | ||
to="/auth/signup" | ||
className="text-blue-600 hover:text-blue-800 font-medium" | ||
> | ||
サインアップ | ||
</Link> | ||
</div> | ||
)} | ||
</nav> | ||
</div> | ||
</div> | ||
</header> | ||
); | ||
} | ||
const handleLanguageChange = (newLanguage: string) => { | ||
const formData = new FormData(); | ||
formData.append("language", newLanguage); | ||
submit(formData, { method: "post" }); | ||
}; | ||
|
||
return ( | ||
<header className="bg-white shadow-sm"> | ||
<div className="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8 flex justify-between items-center"> | ||
<Link to="/"> | ||
<h1 className="text-3xl font-bold text-gray-900">EveEve</h1> | ||
</Link> | ||
<div className="flex items-center space-x-4"> | ||
<Form method="post"> | ||
<TranslationLanguageSelect | ||
value={language} | ||
onChange={handleLanguageChange} | ||
/> | ||
</Form> | ||
<nav> | ||
{user ? ( | ||
<div className="flex items-center space-x-4"> | ||
<span className="text-gray-700"> | ||
ようこそ、{user.name}さん! | ||
</span> | ||
<Link | ||
to="/auth/logout" | ||
className="text-blue-600 hover:text-blue-800 font-medium" | ||
> | ||
ログアウト | ||
</Link> | ||
</div> | ||
) : ( | ||
<div className="space-x-4"> | ||
<Link | ||
to="/auth/login" | ||
className="text-blue-600 hover:text-blue-800 font-medium" | ||
> | ||
ログイン | ||
</Link> | ||
<Link | ||
to="/auth/signup" | ||
className="text-blue-600 hover:text-blue-800 font-medium" | ||
> | ||
サインアップ | ||
</Link> | ||
</div> | ||
)} | ||
</nav> | ||
</div> | ||
</div> | ||
</header> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,4 @@ export function URLTranslationForm() { | |
); | ||
} | ||
|
||
export { urlTranslationSchema }; | ||
export { urlTranslationSchema }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,4 @@ export function VoteButtons({ translation, onVote, userId }: VoteButtonsProps) { | |
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.