Skip to content

Commit

Permalink
DiscountInput 切り出し
Browse files Browse the repository at this point in the history
  • Loading branch information
toririm committed Sep 29, 2024
1 parent 4807477 commit 9fb1ea6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
38 changes: 38 additions & 0 deletions app/components/organisms/DiscountInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { OrderEntity } from "~/models/order";
import { ThreeDigitsInput } from "../molecules/ThreeDigitsInput";

type props = {
id: string;
value: string;
onChange: (value: string) => void;
disabled: boolean;
discountOrder?: OrderEntity;
lastPurchasedCups: number;
};

const DiscountInput = ({
id,
value,
onChange,
disabled,
discountOrder,
lastPurchasedCups,
}: props) => {
return (
<div>
<p>割引券番号</p>
<ThreeDigitsInput
id={id}
value={value}
onChange={onChange}
disabled={disabled}
/>
<p>
{discountOrder === undefined ? "見つかりません" : null}
{discountOrder && `有効杯数: ${lastPurchasedCups}`}
</p>
</div>
);
};

export { DiscountInput };
23 changes: 9 additions & 14 deletions app/routes/cashier-v2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type ClientActionFunction, useSubmit } from "@remix-run/react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import useSWRSubscription from "swr/subscription";
import { z } from "zod";
import { ThreeDigitsInput } from "~/components/molecules/ThreeDigitsInput";
import { DiscountInput } from "~/components/organisms/DiscountInput";
import { ItemAssign } from "~/components/organisms/ItemAssign";
import { OrderAlertDialog } from "~/components/organisms/OrderAlertDialog";
import { Button } from "~/components/ui/button";
Expand Down Expand Up @@ -237,19 +237,14 @@ export default function Cashier() {
<p>合計金額</p>
<p>{newOrder.billingAmount}</p>
</div>
<div>
<p>割引券番号</p>
<ThreeDigitsInput
id="discountOrderId"
value={discountOrderId}
onChange={(value) => setDiscountOrderId(value)}
disabled={inputStatus !== "discount"}
/>
<p>
{discountOrder === undefined ? "見つかりません" : null}
{discountOrder && `有効杯数: ${lastPurchasedCups}`}
</p>
</div>
<DiscountInput
id="discountOrderId"
value={discountOrderId}
onChange={(value) => setDiscountOrderId(value)}
disabled={inputStatus !== "discount"}
discountOrder={discountOrder}
lastPurchasedCups={lastPurchasedCups}
/>
<Input
type="number"
value={received}
Expand Down

0 comments on commit 9fb1ea6

Please sign in to comment.