-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
124 additions
and
29 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
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,16 +0,0 @@ | ||
# 実現したこと | ||
|
||
Vite + React(TypeScript) + Firebase の構成で以下の機能を持つアプリを作成し、Firebase にホスティングした。GitHub へ Push 時に Firebase にホスティングするようワークフローを設定している。 | ||
|
||
- サインイン、サインアウト | ||
- メモの一覧表示 | ||
- メモの登録、更新 | ||
- メモの削除 | ||
|
||
# 注意事項 | ||
|
||
- .env ファイルは[Vite + React + Firebase のハンズオン](https://qiita.com/Inp/items/906100b46fcbda6fb2ee)等を参考に別途作成する必要あり | ||
|
||
# 詳細 | ||
|
||
[React(TypeScript) + Firebase でメモアプリ開発](https://zenn.dev/shoji9x9/articles/eb185b3d66567b)参照。 | ||
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useState, ChangeEvent, FormEvent, useEffect } from 'react'; | ||
import { Button, TextField, Typography } from "@mui/material"; | ||
import { useRecoilState } from 'recoil'; | ||
import { userAtom } from "../states/userAtom"; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export function APIKeyPage(): JSX.Element { | ||
const [apiKey, setApiKey] = useState(''); | ||
const [user, setUser] = useRecoilState(userAtom); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
if (user?.apiKey) { | ||
setApiKey(user.apiKey); | ||
} | ||
}, [user]); | ||
|
||
const handleSubmit = (event: FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
setUser({ ...user, apiKey: apiKey }); | ||
navigate('/memolist'); | ||
}; | ||
|
||
const handleDelete = () => { | ||
setApiKey(''); | ||
setUser({ ...user, apiKey: '' }); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Typography variant="h4" gutterBottom> | ||
API Keyを入力してください。 | ||
</Typography> | ||
{user?.apiKey && ( | ||
<> | ||
<Typography variant="h6" gutterBottom> | ||
登録済みです | ||
</Typography> | ||
<Button onClick={handleDelete} variant="contained" color="secondary"> | ||
API Keyを削除する | ||
</Button> | ||
</> | ||
)} | ||
{!user?.apiKey && ( | ||
<form onSubmit={handleSubmit}> | ||
<TextField | ||
label="API Key" | ||
value={apiKey} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => setApiKey(e.target.value)} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<Button type="submit" variant="contained" color="primary"> | ||
Save | ||
</Button> | ||
</form> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default APIKeyPage; |
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
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