Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mongoUri='mongodb+srv://munkhzul:zulaa1234@sassybooking.0jskx.mongodb.net/appointments?retryWrites=true&w=majority'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
1 change: 1 addition & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel.json
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ If you want to contact with me you can reach me at [Twitter](https://www.twitter
### License

This project is **free to use** and does not contains any license.
# sassy
# sassy
1 change: 1 addition & 0 deletions adminpanel/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mongodb+srv://bolzopzulaa:rAXGX4maTDhGniWR@cluster0.r7vw0.mongodb.net/sassyNail?retryWrites=true&w=majority&appName=Cluster0"
1 change: 1 addition & 0 deletions adminpanel/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
125 changes: 125 additions & 0 deletions adminpanel/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Admin Panel</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th,
td {
padding: 10px;
border: 1px solid #ddd;
text-align: left;
}
th {
background-color: #f4f4f4;
}
button {
padding: 5px 10px;
margin: 5px;
cursor: pointer;
}
.error {
color: red;
}
</style>
</head>
<body>
<h1>Sassy</h1>
<h2>Захиалгууд</h2>
<div id="loading" style="display: none">Уншиж байна...</div>
<div id="message"></div>
<table id="appointmentsTable">
<thead>
<tr>
<th>Нэр</th>
<th>И-мэйл</th>
<th>Утасны дугаар</th>
<th>Үйлчилгээ</th>
<th>Цаг</th>
<th>Захиалга өгсөн цаг</th>
<th>Устгах</th>
<th class="block" type="hidden">_id</th>
</tr>
</thead>
<tbody id="appointmentsTableBody">
<tr>
<td colspan="5">Цаг байхгүй байна</td>
</tr>
</tbody>
</table>

<script>
async function deleteAppointment(appointmentId) {
try {
const response = await fetch(
`http://localhost:4000/api/appointments`,
{
method: "DELETE",
}
);
if (!response.ok) {
throw new Error("Failed to delete the appointment");
}
alert("Appointment deleted successfully.");
fetchAppointments();
} catch (error) {
console.error("Error deleting appointment:", error);
alert("Error deleting appointment. Please try again.");
}
}
async function fetchAppointments() {
const loadingDiv = document.getElementById("loading");
const messageDiv = document.getElementById("message");
const tableBody = document.getElementById("appointmentsTableBody");
loadingDiv.style.display = "block";
messageDiv.innerHTML = "";
try {
const response = await fetch(
"http://localhost:4000/api/appointments"
);
if (!response.ok) {
throw new Error("Failed to fetch appointments");
}
const appointments = await response.json();
tableBody.innerHTML = "";
if (appointments.length === 0) {
tableBody.innerHTML =
'<tr><td colspan="5">No appointments available.</td></tr>';
} else {
appointments.forEach((app, _id) => {
const row = document.createElement("tr");
row.innerHTML = `
<td>${app.name}</td>
<td>${app.email_address}</td>
<td>${app.phone}</td>
<td>${app.category}</td>
<td>${app.createdAt}</td>
<td>${app.time}</td>
<td>${app.message}</td>
<td>
<button onclick="deleteAppointment('${app._id}')">Delete</button>
</td>
<td>${app._id}</td>

`;
tableBody.appendChild(row);
});
}
} catch (error) {
console.error("Error fetching appointments:", error);
messageDiv.innerHTML =
'<span class="error">Error fetching appointments. Please try again later.</span>';
} finally {
loadingDiv.style.display = "none";
}
}

fetchAppointments();
</script>
</body>
</html>
Binary file added assets/.DS_Store
Binary file not shown.
18 changes: 5 additions & 13 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
#style.css
\*-----------------------------------*/

/**
* copyright 2022 codewithsadee
*/





/*-----------------------------------*\
#CUSTOM PROPERTY
\*-----------------------------------*/
Expand All @@ -20,11 +12,11 @@
* colors
*/

--rich-black-fogra-39_50: hsla(0, 0%, 5%, 0.5);
--rich-black-fogra-39_50: hsla(0, 7%, 55%, 0.5);
--rich-black-fogra-39: hsl(0, 0%, 5%);
--indian-yellow_10: hsla(36, 61%, 58%, 0.1);
--indian-yellow: hsl(36, 61%, 58%);
--harvest-gold: hsl(36, 66%, 53%);
--indian-yellow_10: hsl(313, 49%, 89%);
--indian-yellow: hsl(325, 69%, 66%);
--harvest-gold: hsl(48, 9%, 68%);
--eerie-black-1: hsl(0, 0%, 14%);
--eerie-black-2: hsl(0, 0%, 12%);
--eerie-black-2_85: hsla(0, 0%, 12%, 0.85);
Expand All @@ -38,7 +30,7 @@
--white_30: hsla(0, 0%, 100%, 0.3 );
--white_50: hsla(0, 0%, 100%, 0.5);
--white: hsl(0, 0%, 100%);
--jet: hsl(0, 0%, 21%);
--jet: hsla(50, 95%, 91%, 0.816);

/**
* typography
Expand Down
Binary file added assets/download.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/download.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added assets/images/sassy bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
'use strict';



/**
* add event on element
*/
Expand All @@ -16,8 +13,6 @@ const addEventOnElem = function (elem, type, callback) {
}
}



/**
* navbar toggle
*/
Expand Down
Binary file added assets/nail-polish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy bg_245x762.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy bg_251x776.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy pedi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy.1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy2resize.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassy8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sassyresize.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wax.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
116 changes: 116 additions & 0 deletions backend/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import mongoose from 'mongoose';

const app = express();
const PORT = process.env.PORT || 4000;

// MongoDB connection string
const mongoUri ='mongodb+srv://munkhzul:zulaa1234@sassybooking.0jskx.mongodb.net/appointments?retryWrites=true&w=majority'
// Middleware
app.use(cors());
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));

// Connect to MongoDB
mongoose
.connect(mongoUri)
.then(() => console.log('Connected to MongoDB'))
.catch((err) => console.error('Error connecting to MongoDB:', err));

app.get('/api/appointments', async (req, res) => {
try {
const appointments = await Appointment.find();
res.status(200).send(appointments);
} catch (error) {
console.error('Error fetching appointments:', error);
res.status(500).send({ message: 'Internal server error' });
}
});

const appointmentSchema = new mongoose.Schema({
email_address: { type: String, required: true },
name: { type: String, required: true },
category: { type: String, required: true },
time: { type: String, required: true },
phone: { type: String, required: true },
createdAt: { type: Date, default: Date.now },
message: { type: String, required: true },
});

const Appointment = mongoose.model('Appointment', appointmentSchema);
// export default async (req, res) => {
// if (req.method === 'GET') {
// try {
// const appointments = await Appointment.find();
// res.status(200).json(appointments);
// } catch (error) {
// res.status(500).json({ error: 'Error fetching appointments' });
// }
// } else if (req.method === 'POST') {
// try {
// const { email_address, name, category, time, phone } = req.body;
// const newAppointment = new Appointment({ email_address, name, category, time, phone });
// await newAppointment.save();
// res.status(201).json({ message: 'Appointment created successfully' });
// } catch (error) {
// res.status(500).json({ error: 'Error creating appointment' });
// }
// } else {
// res.status(405).json({ error: 'Method not allowed' });
// }
// };
app.post('/api/appointments', async (req, res) => {
try {
const { email_address, name, category, time, phone, _id, message} = req.body;
if (!email_address || !name || !category || !time || !phone, _id) {
return res.status(400).send({ message: 'All fields are required!' });
}
const [hours, minutes] = time.split(':');
const appointmentDate = new Date();
appointmentDate.setHours(hours, minutes, 0, 0);
const newAppointment = new Appointment({
_id,
email_address,
name,
time,
category,
time: appointmentDate,
phone,
createdAt: new Date(),
message,
});
await newAppointment.save();
res.status(201).send({ message: 'Таны цаг амжилттай илгээгдлээ!', appointment: newAppointment });
} catch (error) {
console.error('Error creating appointment:', error);
res.status(500).send({ message: 'Илгээхэд алдаа гарлаа' });
}
});

app.delete('/api/appointments:id', async (req, res) => {
try {
const { id } = req.params;
if (!id === _id) {
return res.status(400).send({ message: 'Appointment ID is required' });
}

const deletedAppointment = await Appointment.findByIdAndDelete(_id);
if (!deletedAppointment) {
return res.status(404).send({ message: 'Appointment not found' });
}

res.status(200).send({ message: 'Appointment deleted successfully' });
} catch (error) {
console.error('Error deleting appointment:', error);
res.status(500).send({ message: 'Устгахад алдаа гарлла' });
}
});

// Start the server
app.listen(PORT, () => {
console.log(`[server]: Server is running on http://localhost:${PORT}`);
});


1 change: 1 addition & 0 deletions flaticon.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added footer-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading