-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdate.html
81 lines (70 loc) · 3.01 KB
/
date.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Menstrual Cycle Tracker</title>
<style>
a{
text-decoration:none ;
text-align: center;
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
/* Full height of the viewport */
margin: 0;
}
body{
background: repeating-linear-gradient(
60deg, /* Angle of the stripes */
pink, /* Mint color replacing pink */
white 10px,
white 10px, /* Color of the second stripe */
white 20px /* Height of the second stripe */
)
}
</style>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet"/>
</head>
<body class="font-roboto bg-gray-50">
<main class="p-8">
<section class="max-w-md mx-auto bg-white p-6 rounded-lg shadow-lg">
<h2 class="text-2xl font-bold text-gray-800 mb-4"><u>Track Your Menstrual Cycle</u></h2>
<p class="text-gray-700 mb-4">Enter your last menstrual cycle start date to keep track on your next expected menstural cycle date.</p>
<form id="cycle-form" class="mb-4">
<label for="start-date" class="block text-gray-700 font-medium">Start Date:</label>
<input type="date" id="start-date" class="w-full p-2 border border-gray-300 rounded-lg mt-2" required>
<button type="submit" class="mt-4 w-full bg-pink-500 text-white py-2 rounded-lg">Track Cycle</button>
</form>
<div id="result" class="text-gray-700 mt-4 p-4 bg-pink-50 rounded-lg"></div>
<a href="/welcome2.html">Go Back to Home Page</a>
</section>
</main>
<script>
document.getElementById("cycle-form").addEventListener("submit", async function(event) {
event.preventDefault();
const startDateInput = document.getElementById("start-date").value;
try {
const response = await fetch('http://localhost:3000/calculate-next-cycle', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ startDate: startDateInput }),
});
if (!response.ok) {
throw new Error('Failed to calculate the next cycle date');
}
const data = await response.json();
document.getElementById("result").innerHTML = `
<strong>Next Expected Cycle Date:</strong> ${data.nextCycleDate}
`;
} catch (error) {
console.error(error);
document.getElementById("result").innerHTML = `
<strong>Error:</strong> Unable to calculate the next cycle date.
`;
}
});
</script>
</body>
</html>