Skip to content

Commit

Permalink
🐛 Revise NewService button
Browse files Browse the repository at this point in the history
  • Loading branch information
sheagrief committed Aug 24, 2024
1 parent 1e27cce commit 751bc23
Showing 1 changed file with 89 additions and 17 deletions.
106 changes: 89 additions & 17 deletions src/app/store/new-service.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,100 @@
import RegisterStorePopup from "@/components/RegisterStore";
import { registerReservationSlot } from "@/utils/store/service";
import { useState } from "react";
import { TransactionButton } from "thirdweb/react";

export default function NewService(props: { storeId: number, deposit: number, serviceFee: number, datetime: number }) {
export default function NewService(props: {
storeId: number;
deposit: number;
serviceFee: number;
datetime: number;
}) {
const [showPopup, setShowPopup] = useState(false);
const [deposit, setDeposit] = useState("");
const [serviceFee, setServiceFee] = useState("");
const [dateTime, setDateTime] = useState("");
return (
<div>
<TransactionButton
transaction={() => {
const tx = registerReservationSlot(props.storeId, props.datetime, props.deposit, props.serviceFee);
return tx;
}}
onTransactionSent={(result) => {
console.log("Transaction submitted", result.transactionHash);
}}
onTransactionConfirmed={(receipt) => {
console.log("Transaction confirmed", receipt.transactionHash);
window.location.reload();
}}
onError={(error) => {
console.error("Transaction error", error);
<button
onClick={() => {
setShowPopup(true);
}}
className="px-4 py-2 rounded bg-blue-500 text-white"
>
サービス新規登録
</TransactionButton>
Register New Service
</button>

{showPopup && (
<div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
<div className="bg-white p-6 rounded shadow-lg">
<h2 className="font-bold mb-4 text-black">Register New Service</h2>

<div className="mb-4">
<label className="block mb-2 text-black">Deposit Amount</label>
<input
type="number"
value={deposit}
onChange={(e) => setDeposit(e.target.value)}
className="w-full px-3 py-2 border rounded text-black"
/>
</div>

<div className="mb-4">
<label className="block mb-2 text-black">Service Fee</label>
<input
type="number"
value={serviceFee}
onChange={(e) => setServiceFee(e.target.value)}
className="w-full px-3 py-2 border rounded text-gray-500"
/>
</div>

<div className="mb-4">
<label className="block mb-2 text-black">Date</label>
<input
type="datetime-local"
value={dateTime}
onChange={(e) => setDateTime(e.target.value)}
className="w-full px-3 py-2 border rounded text-gray-500"
/>
</div>

<div className="flex justify-end">
<button
onClick={() => setShowPopup(false)}
className="px-4 py-2 rounded bg-gray-300 text-gray-700 mr-2"
>
Cancel
</button>
<TransactionButton
unstyled
className="px-4 py-2 rounded bg-green-500 text-white"
transaction={() => {
const tx = registerReservationSlot(
props.storeId,
props.datetime,
props.deposit,
props.serviceFee
);
return tx;
}}
onTransactionSent={(result) => {
console.log("Transaction submitted", result.transactionHash);
}}
onTransactionConfirmed={(receipt) => {
console.log("Transaction confirmed", receipt.transactionHash);
window.location.reload();
}}
onError={(error) => {
console.error("Transaction error", error);
}}
>
OK
</TransactionButton>
</div>
</div>
</div>
)}
</div>
);
}

0 comments on commit 751bc23

Please sign in to comment.