From 3744294372b46d1e4b3407642823ae725f94a757 Mon Sep 17 00:00:00 2001 From: Animesh Das <100115113+Animesh-Das245@users.noreply.github.com> Date: Mon, 30 Oct 2023 18:24:13 +0530 Subject: [PATCH] Create NotificationPreferenceForm.js --- frontend/src/NotificationPreferenceForm.js | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 frontend/src/NotificationPreferenceForm.js diff --git a/frontend/src/NotificationPreferenceForm.js b/frontend/src/NotificationPreferenceForm.js new file mode 100644 index 0000000..6a6f116 --- /dev/null +++ b/frontend/src/NotificationPreferenceForm.js @@ -0,0 +1,53 @@ +// src/NotificationPreferenceForm.js + +import React, { useState } from "react"; + +function NotificationPreferenceForm() { + const [email, setEmail] = useState(''); + const [productId, setProductId] = useState(''); + const [originalPrice, setOriginalPrice] = useState(''); + + const handleSubmit = async (e) => { + e.preventDefault(); + const data = { + email, + product_id: productId, + original_price: originalPrice, + }; + + const response = await fetch('http://localhost:5000/set-notification-preference', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }); + + if (response.ok) { + const result = await response.json(); + alert(result.message); + } else { + alert('Failed to set notification preference. Please try again.'); + } + }; + + return ( +
+ + + + +
+ ); +} + +export default NotificationPreferenceForm;