Skip to content

Commit

Permalink
fixup! 目標に投稿ボタンを追加して完了投稿をリンクして作成する機能を実装
Browse files Browse the repository at this point in the history
  • Loading branch information
MurakawaTakuya committed Dec 6, 2024
1 parent 2554654 commit 4757771
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 147 deletions.
4 changes: 2 additions & 2 deletions src/Components/GoalModal/GoalModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function GoalModal() {
event.preventDefault();

const postData: Goal = {
userId: user ? user.uid : "",
userId: user?.uid as string,
text: text,
deadline: new Date(dueDate),
};
Expand Down Expand Up @@ -95,7 +95,7 @@ export default function GoalModal() {
aria-describedby="create-goal-description"
>
<DialogTitle>目標を作成</DialogTitle>
<DialogContent>自分の目標を入力してください.</DialogContent>
<DialogContent>目標を入力してください</DialogContent>
<form onSubmit={handleSubmit}>
<Stack spacing={2} sx={{ mt: 2 }}>
<Input
Expand Down
129 changes: 0 additions & 129 deletions src/Components/PostForm/PostForm.tsx

This file was deleted.

23 changes: 9 additions & 14 deletions src/Components/PostModal/PostModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ export default function PostModal({ goalId }: { goalId: string }) {
(percent) => setProgress(percent),
(errorMsg) => setError(errorMsg),
async (url, hash) => {
console.log("Image is saved at:", url);
console.log("Generated storage path hash:", hash);

const postData: Post = {
userId: user ? user.uid : "",
userId: user?.uid as string,
storedId: url,
text: text,
goalId: goalId,
Expand All @@ -72,14 +69,13 @@ export default function PostModal({ goalId }: { goalId: string }) {
throw new Error("データの送信に失敗しました");
}

setProgress(100); // アップロード完了の進捗を表示
setProgress(100);
const data = await response.json();
console.log("Post created:", data);

// 投稿作成後にモーダルを閉じる
setImage(null);
setText("");
setOpen(false);
setText(""); // 入力フィールドをリセット
setImage(null); // 画像をリセット
} catch (err) {
setError("データの送信に失敗しました");
console.error(err);
Expand Down Expand Up @@ -110,7 +106,7 @@ export default function PostModal({ goalId }: { goalId: string }) {
onClick={() => setOpen(true)}
disabled={!user || user?.loginType === "Guest"}
>
Create Post
写真を撮って完了する
</Button>

<Modal
Expand All @@ -123,17 +119,16 @@ export default function PostModal({ goalId }: { goalId: string }) {
aria-labelledby="create-post-title"
aria-describedby="create-post-description"
>
<DialogTitle>投稿を作成</DialogTitle>
<DialogContent>投稿内容と画像を入力してください。</DialogContent>
<DialogTitle>完了投稿を作成</DialogTitle>
<DialogContent>投稿コメントと画像を入れてください</DialogContent>
<form onSubmit={(e) => e.preventDefault()}>
<Stack spacing={2} sx={{ mt: 2 }}>
<Typography variant="h6">投稿内容を入力</Typography>
{error && <Typography color="error">{error}</Typography>}
<Input
type="text"
value={text}
onChange={handleTextChange}
placeholder="投稿内容を入力して下さい"
placeholder="投稿コメントを入力して下さい"
required
/>
<input type="file" onChange={handleImageChange} />
Expand All @@ -153,7 +148,7 @@ export default function PostModal({ goalId }: { goalId: string }) {
disabled={!user || user?.loginType === "Guest"}
onClick={handleUpload}
>
Create Post
投稿
</Button>
</Stack>
</Stack>
Expand Down
2 changes: 0 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";
import DashBoard from "@/Components/DashBoard/DashBoard";
import GoalModal from "@/Components/GoalModal/GoalModal";
import PostForm from "@/Components/PostForm/PostForm";
import {
requestPermission,
revokePermission,
Expand All @@ -12,7 +11,6 @@ export default function Top() {
return (
<>
<DashBoard />
<PostForm />
<GoalModal />
<Button variant="contained" onClick={requestPermission}>
通知を受信
Expand Down

0 comments on commit 4757771

Please sign in to comment.