Skip to content

Commit

Permalink
Merge pull request #4 from Prathamesh-Dukare/main
Browse files Browse the repository at this point in the history
Payment Page Amount and UI Fixes
  • Loading branch information
vamsii777 authored Jul 3, 2023
2 parents f9c3ce7 + 309c419 commit 499bb6f
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions app/giving/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function Giving() {
const [inputStatus, setInputStatus] = useState(true); // true = input field disabled
const [isFirstInputHidden, setIsFirstInputHidden] = useState(false);
const [isSecondInputHidden, setIsSecondInputHidden] = useState(true);
const [isDonateBtnLoading, setIsDonateBtnLoading] = useState(false);

const donationArray = [
"10.00",
Expand Down Expand Up @@ -95,6 +96,7 @@ function Giving() {
};

const initiateStripePayment = async () => {
setIsDonateBtnLoading(true);
try {
const _amount = parseInt(currentInputFieldValue) * 100;
const { paymentIntent, ephemeralKey, customer } = await makeStripePayment(
Expand All @@ -118,6 +120,8 @@ function Giving() {
console.log(e);
alert("Error in Stripe Payment");
}

setIsDonateBtnLoading(false);
};

return (
Expand Down Expand Up @@ -157,14 +161,18 @@ function Giving() {
</div>
<input
hidden={isFirstInputHidden}
className=" text-[20px] px-2"
className=" text-[20px] px-2 text-black font-semibold"
disabled={inputStatus}
value={currentInputFieldValue}
/>
<input
type="number"
onChange={(e) => {
e.preventDefault();
setCurrentInputFieldValue(String(e.target.value));
}}
hidden={isSecondInputHidden}
className=" text-[20px] px-2"
className=" text-[20px] px-2 text-black font-semibold"
/>
</div>
<div className=" mt-4 w-[50%]">
Expand All @@ -178,25 +186,34 @@ function Giving() {
{donationArray &&
donationArray.map((data, index) => (
<option
className="text-black font-semibold"
key={index}
value={data}
selected={index === 0 ? true : false}
>
$
$ {data}
</option>
))}
</select>
</div>
<button
className=" bg-gray-200 text-white font-semibold hover:bg-gray-300 px-4 py-2 mt-6 border-[1px] border-gray-400"
className=" bg-gray-200 text-black font-bold hover:bg-gray-300 px-4 py-2 mt-6 border-[1px] border-gray-400"
onClick={initiateStripePayment}
>
Donate Now
{isDonateBtnLoading ? "Loading..." : "Donate Now"}
</button>

<h2 className=" mt-10 text-[18px] font-semibold">Domestic (India)</h2>
<div className="py-[0px] h-[1px] w-1/2 bg-gray-300 my-4"></div>

<h2 className=" mt-10 text-[24px] mb-3 font-semibold">
Domestic (India)
</h2>

<button onClick={initiateRazorpayPayment} style={{ margin: "10px" }}>
<button
onClick={initiateRazorpayPayment}
style={{ margin: "10px" }}
className="hover:scale-105 transform transition-all duration-300 ease-in-out"
>
<Image
// fill
style={{
Expand Down

0 comments on commit 499bb6f

Please sign in to comment.