close to making db work
This commit is contained in:
@@ -134,7 +134,39 @@ export default async function Home() {
|
|||||||
className="bg-emerald-500 text-fuchsia-300"
|
className="bg-emerald-500 text-fuchsia-300"
|
||||||
type="button">Add</button>
|
type="button">Add</button>
|
||||||
|
|
||||||
<button className="bg-slate-500 text-yellow-300 text-stretch-50% font-lg rounded-md p-2" type="submit">Set contacts</button>
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
alert("Saving contacts...");
|
||||||
|
const contactInputs = document.querySelectorAll(".text-input") as NodeListOf<HTMLInputElement>;
|
||||||
|
const contactValues = Array.from(contactInputs).map(input => input.value);
|
||||||
|
console.log("Contact values:", contactValues);
|
||||||
|
// save codeword and contacts to database
|
||||||
|
fetch("/api/databaseStorage", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
email: session.user.email,
|
||||||
|
codeword: codeword,
|
||||||
|
contacts: contactValues,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
|
alert("Contacts saved successfully!");
|
||||||
|
} else {
|
||||||
|
alert("Error saving contacts.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error:", error);
|
||||||
|
alert("Error saving contacts.");
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
className="bg-slate-500 text-yellow-300 text-stretch-50% font-lg rounded-md p-2">Save</button>
|
||||||
</form>
|
</form>
|
||||||
<div>
|
<div>
|
||||||
<a href="/call">
|
<a href="/call">
|
||||||
|
|||||||
Reference in New Issue
Block a user