Skip to content

Commit a41a6f0

Browse files
committed
Add message field to the payment form
1 parent 8e21dd6 commit a41a6f0

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

src/components/CrowdFund/donors.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const DonorsList: FunctionComponent<Props> = ({ campaign }) => {
5050
<p className="text-xs text-gray-600">
5151
{fromnow(new Date(item.created_at), { max: 2, suffix: true })}
5252
</p>
53+
<p className="text-xs text-gray-600">{item.message}</p>
5354
</div>
5455
<div className="px-4">
5556
<span className="inline-block bg-green-600 text-xs rounded-full px-3 py-1 text-white">

src/components/common/PaymentForm.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface FormState {
2323
email: string;
2424
phone: string;
2525
name: string;
26+
message: string;
2627
}
2728

2829
export const PaymentForm: FunctionComponent<Props> = ({ campaign, inlineForm = false, isPayment = false }) => {
@@ -36,6 +37,7 @@ export const PaymentForm: FunctionComponent<Props> = ({ campaign, inlineForm = f
3637
email: '',
3738
phone: '',
3839
name: '',
40+
message: '',
3941
};
4042
const [form, setFormValue] = useState(initialState);
4143
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -250,6 +252,22 @@ export const PaymentForm: FunctionComponent<Props> = ({ campaign, inlineForm = f
250252
/>
251253
</div>
252254
</div>
255+
<div className="mb-6">
256+
<label className="text-sm text-gray-800 mb-1 block" htmlFor="message">
257+
Message
258+
</label>
259+
<div>
260+
<input
261+
className="bg-white focus:outline-0 border border-gray-300 rounded py-2 px-2 block w-full appearance-none leading-normal"
262+
type="text"
263+
name="message"
264+
id="message"
265+
value={form.message}
266+
onChange={onChange}
267+
disabled={isSubmitting}
268+
/>
269+
</div>
270+
</div>
253271
<div className="flex justify-center mb-3">
254272
<Button type="submit" isLoading={isSubmitting} disabled={isSubmitting}>
255273
<IconCards width={27} height={22} />

src/pages/api/campaigns/[slug].tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
2020
.select({ view: Views.grid, sort: [{ field: 'created_at', direction: 'desc' }] })
2121
.firstPage();
2222
const fundings = fundingResults
23-
.map(({ fields: { name, donated_amount, created_at, campaign, status }, id }) => ({
23+
.map(({ fields: { name, donated_amount, created_at, campaign, status, message }, id }) => ({
2424
name,
2525
donated_amount,
2626
created_at,
2727
campaign,
2828
status,
2929
id,
30+
message,
3031
}))
3132
.filter(({ campaign, status }) => campaign === _slug && status === PaymentStatus.captured);
32-
3333
res.send({ ...campaign, fundings });
3434
} catch (error) {
3535
console.log(error);

src/pages/api/rzp.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
2626
hours_spent_cost,
2727
tip,
2828
phone,
29+
message,
2930
paymentMethod = 'Razorpay',
3031
campaign,
3132
isPayment,
@@ -42,6 +43,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
4243
name,
4344
campaign,
4445
isPayment,
46+
message,
4547
},
4648
});
4749
if (campaign) {
@@ -52,6 +54,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
5254
email,
5355
phone,
5456
campaign,
57+
message,
5558
donated_amount: Number(amount),
5659
payment_method: paymentMethod,
5760
status: PaymentStatus.created,
@@ -67,6 +70,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
6770
name,
6871
email,
6972
phone,
73+
message,
7074
hours_spent: Number(hours_spent),
7175
hours_spent_cost: Number(hours_spent_cost),
7276
tip: Number(tip),
@@ -85,6 +89,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
8589
name,
8690
email,
8791
phone,
92+
message,
8893
donated_amount: Number(amount),
8994
payment_method: paymentMethod,
9095
status: PaymentStatus.created,

src/services/airtable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface RZPPayment {
2525
name: string;
2626
email: string;
2727
phone: string;
28+
message: string;
2829
payment_method: string;
2930
created_at: string;
3031
order_id: string;

0 commit comments

Comments
 (0)