Skip to content

Commit

Permalink
Xへのポストボタンを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatsu47 committed Jun 29, 2024
1 parent bcf0b17 commit 9a2bc17
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
18 changes: 17 additions & 1 deletion src/app/DisplayComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const DisplayComponent: React.FC<DisplayComponentProps> = ({
talkId,
handleCheckWinning,
}) => {
const handlePostToX = () => {
const text = `大吉祥寺.pm #ミニ句会 で投句しました!\n${haiku}\n(詠み人:${haijinName}/投句番号:${talkId})\n#kichijojipm`;
const url = `https://x.com/intent/post?text=${encodeURIComponent(text)}`;
window.open(url, "_blank");
};

return (
<Table className="w-full text-left border-collapse text-xs-responsive">
<TableBody>
Expand All @@ -32,11 +38,21 @@ const DisplayComponent: React.FC<DisplayComponentProps> = ({
<TableCell className="py-2 px-4 border-b">投句番号:</TableCell>
<TableCell className="py-2 px-4 border-b">{talkId}</TableCell>
</TableRow>
<TableRow>
<TableCell colSpan={2} className="p-2 text-center">
<Button
onClick={handlePostToX}
className="bg-black hover:bg-gray-500 text-xs-responsive text-white"
>
X(旧Twitter)にポスト
</Button>
</TableCell>
</TableRow>
<TableRow>
<TableCell colSpan={2} className="p-2 text-center">
<Button
onClick={handleCheckWinning}
className="bg-orange-500 text-white hover:bg-orange-300 text-xs-responsive"
className="bg-orange-500 hover:bg-orange-300 text-xs-responsive text-white hover:text-black"
>
当選結果を確認
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/app/FormComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const FormComponent: React.FC<FormComponentProps> = ({
<Button
type="submit"
disabled={isPending}
className="bg-orange-500 text-white hover:bg-orange-300 text-xs-responsive"
className="bg-orange-500 hover:bg-orange-300 text-xs-responsive text-white hover:text-black"
>
投句
</Button>
Expand Down
6 changes: 4 additions & 2 deletions src/app/list/HaikuTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export function HaikuTable({
<div className="flex items-center justify-end">
<Button
onClick={() => handleToggle(haiku.talk_id)}
className={`text-white hover:bg-orange-300 text-xs-responsive mr-2 ${
haiku.hand_over === 1 ? "bg-orange-300" : "bg-orange-500"
className={`text-xs-responsive mr-2 ${
haiku.hand_over === 1
? "bg-orange-300 hover:bg-orange-500 text-black hover:text-white"
: "bg-orange-500 hover:bg-orange-300 text-white hover:text-black"
}`}
>
{haiku.hand_over === 0 ? "未" : "済"}
Expand Down
6 changes: 3 additions & 3 deletions src/app/list/ListClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function ListClient({
} else if (filter === "handed") {
return haiku.hand_over > 0;
} else if (filter === "winning") {
return haiku.winning && haiku.winning.startsWith("当選");
return haiku.winning;
}
return true; // 'all' or any other value
});
Expand Down Expand Up @@ -82,14 +82,14 @@ export default function ListClient({
<div className="flex justify-start mb-4 space-x-2">
<Button
onClick={handleToggleTalkOn}
className="bg-orange-500 text-white hover:bg-orange-300 text-xs-responsive"
className="bg-orange-500 hover:bg-orange-300 text-xs-responsive text-white hover:text-black"
>
{talkOn ? "投句終了" : "投句再開"}
</Button>
<Button
onClick={handlePerformDraw}
disabled={talkOn}
className="bg-orange-500 text-white hover:bg-orange-300 text-xs-responsive"
className="bg-orange-500 hover:bg-orange-300 text-xs-responsive text-white hover:text-black"
>
{winFin ? "再抽選" : "抽選"}
</Button>
Expand Down
7 changes: 3 additions & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { useState, useEffect, useTransition, Suspense } from "react";
import { useRouter } from "next/navigation";
import { addHaiku, checkWinning } from "../lib/actions";
import FormComponent from "./FormComponent";
import DisplayComponent from "./DisplayComponent";
Expand Down Expand Up @@ -36,7 +35,7 @@ export default function Page() {
setMessage([
"投句ありがとうございます!",
"当選発表をお待ちください!",
"(17時台後半)",
"(17時台後半LTにて)",
]);
}

Expand Down Expand Up @@ -83,10 +82,10 @@ export default function Page() {
};

return (
<div className="max-w-4xl mx-auto p-4 min-w-[360px]">
<div className="mx-auto p-4 min-w-[360px] max-w-[480px]">
<Card>
<CardHeader className="text-center text-2xl font-bold text-gray-800 text-xs-responsive">
投句箱
ミニ句会 投句箱🗳️
</CardHeader>
<CardContent>
<Suspense fallback={<LoadingSpinner />}>
Expand Down
8 changes: 4 additions & 4 deletions src/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function addHaiku(
result: [
"投句ありがとうございます!",
"当選発表をお待ちください!",
"(17時台後半)",
"(17時台後半LTにて)",
],
token: result.rows[0].token,
};
Expand All @@ -126,9 +126,9 @@ export async function addHaiku(
result: [
"投句ありがとうございます!",
`先着${goodsCount}名様にプレゼントがあります!`,
"休憩時間中お早めに受付まで",
"休憩時間中お早めに受付まで",
"※この画面を見せてください",
"(17:00締切/別途抽選あり)",
"(17:00締切/LTで別途抽選あり)",
],
token: result.rows[0].token,
};
Expand Down Expand Up @@ -162,7 +162,7 @@ export async function checkWinning(
return [
"まだ抽選が行われていません",
"当選発表をお待ちください!",
"(17時台後半)",
"(17時台後半LTにて)",
];
}

Expand Down

0 comments on commit 9a2bc17

Please sign in to comment.