-
Notifications
You must be signed in to change notification settings - Fork 0
charge画面の追加 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
charge画面の追加 #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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(); | ||
|
|
||
| const handleHome = () => { | ||
| navigate("/"); | ||
| }; | ||
| return ( | ||
|
Comment on lines
+8
to
+11
|
||
| <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
|
||
| </div> | ||
| <div className="text-4xl font-bold text-[#BD2929] mb-20"> | ||
| 現在のカード残高 ¥ | ||
| {useBalanceStore((state) => state.balance?.balance ?? 0)} | ||
| </div> | ||
| <Button onClick={handleHome}>ホームへ戻る</Button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| 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
|
||
|
|
||
| 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
|
||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
|
|
||
| return ( | ||
|
|
@@ -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> | ||
|
|
||
| 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 }), | ||
| })); |
There was a problem hiding this comment.
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.tsxのChargeと同名です。デバッグ時の表示やスタックトレースが紛らわしくなるため、ChargeCompletePage等にリネームしてください。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
関数名変更