Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions sysken-pay-front/src/pages/charge/complete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useNavigate } from "react-router-dom";
import Button from "../../components/ui/Button";
import { useBalanceStore } from "../../store/useBalanceStore";

export default function Charge() {
const navigate = useNavigate();
Comment on lines +5 to +6
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

complete.tsx のコンポーネント名が function Charge() になっており、pages/charge/index.tsxCharge と同名です。デバッグ時の表示やスタックトレースが紛らわしくなるため、ChargeCompletePage 等にリネームしてください。

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

関数名変更


const handleHome = () => {
navigate("/");
};
return (
Comment on lines +8 to +11
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useChargeStoreclearChargeAmount が用意されていますが、チャージ完了後にクリアされないため次回チャージ開始時に前回金額が残る可能性があります。handleHome(またはこの画面の初期化処理)で clearChargeAmount() を呼ぶなどして、フロー完了時に状態をリセットしてください。

Copilot uses AI. Check for mistakes.
<div className="flex flex-col h-screen overflow-hidden">
<div className="flex flex-col items-center justify-center gap-8 h-full">
<div className="text-6xl font-bold text-[#454a53] mb-13 mt-50">
チャージが完了しました
Comment on lines +13 to +15
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mb-13mt-50 は Tailwind のデフォルト spacing scale に存在しないため(このリポジトリには tailwind.config も見当たらず)、スタイルが適用されない可能性が高いです。既存のスケール(例: mb-12, mt-12, mt-48 など)に合わせるか、必要なら mb-[...] / mt-[...] の任意値クラスを使ってください。

Copilot uses AI. Check for mistakes.
</div>
<div className="text-4xl font-bold text-[#BD2929] mb-20">
現在のカード残高 ¥
{useBalanceStore((state) => state.balance?.balance ?? 0)}
</div>
<Button onClick={handleHome}>ホームへ戻る</Button>
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion sysken-pay-front/src/pages/charge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function Charge() {
// TODO: APIから残高を参照
setBalance({
userId: barcode,
balance: 150,
balance: 550,
});
navigate("/charge/select");
};
Expand Down
39 changes: 39 additions & 0 deletions sysken-pay-front/src/pages/charge/insert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Header from "../../components/layouts/Header/index";
import { useNavigate } from "react-router-dom";
import ArrowButton from "../../components/ui/ArrowButton";
import { PriceLabel } from "../../components/ui/PriceLabel";
import { useChargeStore } from "../../store/useChargeStore";
import { useBalanceStore } from "../../store/useBalanceStore";

export default function ChargeInsertPage() {
const navigate = useNavigate();
const chargeAmount = useChargeStore((state) => state.chargeAmount);
const setBalance = useBalanceStore((state) => state.setBalance);

const handleNext = (barcode: string) => {
// TODO: APIから残高を参照
setBalance({
userId: barcode,
balance: 550,
});
navigate("/charge/complete");
};
Comment on lines +10 to +20
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このページで setBalance({ balance: 550 }) に固定値を入れており、選択した chargeAmount が残高に反映されません(少なくともフロントのスタブとしては既存残高 + chargeAmount などが自然です)。API 実装までの暫定でも、現在の useBalanceStore の残高を取得して加算する/もしくは TODO コメントを「チャージ処理」等に修正して誤解を避けてください。

Copilot uses AI. Check for mistakes.

return (
<div className="flex flex-col h-screen overflow-hidden">
<Header title="チャージ金額" />
<div className="flex-1 flex flex-col items-center justify-center gap-8 pb-[10vh]">
<div className="text-6xl text-center font-bold text-center text-[#454a53]">
箱にお金を入れてください
</div>
<PriceLabel label="チャージ金額" price={chargeAmount} />
</div>
<ArrowButton variant="prev" onClick={() => navigate("/charge/select")}>
戻る
</ArrowButton>
<ArrowButton variant="next" onClick={() => handleNext("user123")}>
完了
</ArrowButton>
Comment on lines +31 to +36
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

完了ボタンで handleNext("user123") を呼んでおり、スキャン済みユーザーID(/chargesetBalance({ userId: barcode, ... }) した値)を上書きしてしまいます。誤ユーザーへのチャージ/表示につながるので、既存の useBalanceStore から userId を参照するか、遷移時に userId を引き回してこのページではハードコードしないでください。

Copilot uses AI. Check for mistakes.
</div>
);
}
14 changes: 10 additions & 4 deletions sysken-pay-front/src/pages/charge/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import { PriceLabel } from "../../components/ui/PriceLabel";
import { Input } from "../../components/ui/Input";
import { useBalanceStore } from "../../store/useBalanceStore";
import { useState } from "react";
import { useChargeStore } from "../../store/useChargeStore";

export default function ChargeSelectPage() {
const navigate = useNavigate();
const balance = useBalanceStore((state) => state.balance?.balance ?? 0);
const saveChargeAmount = useChargeStore((state) => state.setChargeAmount);
const [chargeAmount, setChargeAmount] = useState("");
const handleHome = () => {
navigate("/");

const handleNext = () => {
const normalizedChargeAmount =
Number(chargeAmount.replace(/[^\d]/g, "")) || 0;
saveChargeAmount(normalizedChargeAmount);
navigate("/charge/insert");
};
Comment on lines +17 to 22
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleNext が未入力/不正入力時に normalizedChargeAmount を 0 にしてそのまま次画面へ遷移してしまい、0円チャージが成立してしまいます。最低金額(例: 1円以上 or ボタンで選べる金額のみ)をバリデーションし、条件を満たさない場合は遷移を止めてエラーメッセージ表示などの UX を追加してください。

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

バリデーションは後でやっておく


return (
Expand All @@ -33,10 +39,10 @@ export default function ChargeSelectPage() {
</div>
<SelectButtonGroup onSelectAmount={setChargeAmount} />
</div>
<ArrowButton variant="prev" onClick={handleHome}>
<ArrowButton variant="prev" onClick={() => navigate("/charge")}>
戻る
</ArrowButton>
<ArrowButton variant="next" onClick={() => navigate("/charge/insert")}>
<ArrowButton variant="next" onClick={handleNext}>
次へ
</ArrowButton>
</div>
Expand Down
2 changes: 2 additions & 0 deletions sysken-pay-front/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export type Path =
| `/buy/confirm`
| `/buy/list`
| `/charge`
| `/charge/complete`
| `/charge/insert`
| `/charge/select`

export type Params = {
Expand Down
13 changes: 13 additions & 0 deletions sysken-pay-front/src/store/useChargeStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { create } from "zustand";

type ChargeStore = {
chargeAmount: number;
setChargeAmount: (amount: number) => void;
clearChargeAmount: () => void;
};

export const useChargeStore = create<ChargeStore>((set) => ({
chargeAmount: 0,
setChargeAmount: (amount) => set({ chargeAmount: amount }),
clearChargeAmount: () => set({ chargeAmount: 0 }),
}));