feat: チャージボタンコンポーネントを追加#12
Conversation
sana-sagegami
commented
Jun 10, 2026
There was a problem hiding this comment.
Pull request overview
ホーム画面の「チャージ」導線を独立したボタンコンポーネントに分離しつつ、ホーム画面から商品バーコードをスキャンして購入フロー(カート一覧)へ進めるようにしたPRです。
Changes:
- Home(
/) に商品用BarcodeReaderとエラー表示を追加し、スキャン成功時にカートへ追加して/buy/listへ遷移 - チャージボタンを
ChargeButtonコンポーネントとして新規追加し、HomeButtons を削除 - Home のエラー表示用スタイル(固定表示+フェードイン)を追加
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sysken-pay-front/src/pages/index.tsx | ホームでの商品スキャン→カート追加→購入リスト遷移、チャージボタン配置に変更 |
| sysken-pay-front/src/pages/index.module.scss | ホームのエラー表示スタイルを追加(fixed表示+アニメーション) |
| sysken-pay-front/src/components/features/home/HomeButtons/index.tsx | HomeButtons を削除 |
| sysken-pay-front/src/components/features/home/HomeButtons/HomeButtons.module.scss | HomeButtons のスタイルを削除 |
| sysken-pay-front/src/components/features/home/ChargeButton/index.tsx | チャージ用ボタンコンポーネントを新規追加 |
| sysken-pay-front/src/components/features/home/ChargeButton/ChargeButton.module.scss | ChargeButton のスタイルを新規追加 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const navigate = useNavigate(); | ||
| const addItem = useCartStore((state) => state.addItem); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { |
| const handleScan = async (barcode: string) => { | ||
| try { | ||
| const data = await ItemRepositoryImpl.getItemByJanCode(barcode); | ||
| if (!data?.item_id) throw new Error("商品が見つかりませんでした。ご不明の際は担当者にご連絡ください。"); | ||
| addItem(data); | ||
| navigate("/buy/list"); | ||
| } catch (e) { | ||
| setError(e instanceof Error ? e.message : "商品の取得に失敗しました"); | ||
| } | ||
| }; |
| const handleScan = async (barcode: string) => { | ||
| try { | ||
| const data = await ItemRepositoryImpl.getItemByJanCode(barcode); | ||
| if (!data?.item_id) throw new Error("商品が見つかりませんでした。ご不明の際は担当者にご連絡ください。"); | ||
| addItem(data); | ||
| navigate("/buy/list"); |
There was a problem hiding this comment.
個人的には、無理に共通化しても破壊的変更になるかもなので慎重に考えてもらえると Goodです
|
対応お願いしますと書いたCopilotレビューは修正をお願いします。 |
| const handleScan = async (barcode: string) => { | ||
| try { | ||
| const data = await ItemRepositoryImpl.getItemByJanCode(barcode); | ||
| if (!data?.item_id) throw new Error("商品が見つかりませんでした。ご不明の際は担当者にご連絡ください。"); | ||
| addItem(data); | ||
| navigate("/buy/list"); |
There was a problem hiding this comment.
個人的には、無理に共通化しても破壊的変更になるかもなので慎重に考えてもらえると Goodです
| const handleScan = async (barcode: string) => { | ||
| try { | ||
| const data = await ItemRepositoryImpl.getItemByJanCode(barcode); | ||
| if (!data?.item_id) throw new Error("商品が見つかりませんでした。ご不明の際は担当者にご連絡ください。"); | ||
| addItem(data); | ||
| navigate("/buy/list"); | ||
| } catch (e) { | ||
| setError(e instanceof Error ? e.message : "商品の取得に失敗しました"); | ||
| } | ||
| }; |
| const navigate = useNavigate(); | ||
| const addItem = useCartStore((state) => state.addItem); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { |
| height: 10rem; | ||
| background-color: $blue-40; | ||
| color: $white; | ||
| font-size: 4.0625rem; |
There was a problem hiding this comment.
[imo] font-sizeも固定にした方が良いと思います
大きい、中くらい、小さいでそれぞれ分けて(分け方はなんでも良い)固定値で使っていくと
文字の大きさも統一がされて綺麗になると思います
| <button | ||
| type="button" | ||
| className={styles.chargeButton} | ||
| onClick={onCharge ?? (() => navigate("/charge"))} |
There was a problem hiding this comment.
[FYI] ?? だと「onCharge が渡されていれば navigate しない」という排他になる。もし「onCharge があれば呼びつつ、デフォルトの遷移もしたい」みたいな要件が将来出てくるなら以下のように修正をした方が良いと思います
const handleClick = () => {
if (onCharge) {
onCharge();
} else {
navigate("/charge");
}
};| background-color: $blue-40; | ||
| color: $white; | ||
| font-size: 4.0625rem; | ||
| font-weight: bold; |
There was a problem hiding this comment.
[must] sysken-pay-front/src/pages/index.module.scssの方では
font-weight: $bold;となっています。
$bold か boldなのか統一をしてください