Skip to content

Commit

Permalink
Latest Code of Frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanmandal-M committed May 11, 2023
1 parent 4276190 commit c958150
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 52 deletions.
13 changes: 9 additions & 4 deletions Frontend/Services/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.onload = () => {
document.getElementById("logo-href").href = "../index.html";
document.getElementById("bookhref").href = "gender.html";
document.getElementById("viewhref").href = "appointment.html";
document.getElementById("contacthref").href = "../index.html";
document.getElementById("contacthref").href = "./feedbackForm.html";
// document.getElementById("loginhref").href =
// "../routes/loginSignup/login.html";
};
Expand Down Expand Up @@ -117,7 +117,7 @@ const card_div = document.querySelector(".car-div");
async function getData() {
try {
let data = await fetch(
"https://hairsalonbackend-production-1188.up.railway.app/services/female/"
"https://hair-salon-backend.onrender.com/services/female/"
);
data = await data.json();
renderData(data);
Expand Down Expand Up @@ -170,12 +170,17 @@ async function renderData(product_data) {
async function getServiceDat(id) {
try {
let data = await fetch(
`https://hairsalonbackend-production-1188.up.railway.app/services/female/${id}`
`https://hair-salon-backend.onrender.com/services/female/${id}`
);
data = await data.json();
sessionStorage.setItem("service_data", JSON.stringify(data));
window.location.href = "../html/styler.html";
} catch (error) {
console.log(error);
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Bad Request 404',
width:"25%",
})
}
}
5 changes: 1 addition & 4 deletions Frontend/html/appointment.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<!------------------ SweetAlert JS ------------------>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="sweetalert2.min.js"></script>
<script src="sweetalert2.all.min.js"></script>

</head>

Expand All @@ -27,5 +25,4 @@
</body>

</html>
<script type="module" src="../scripts/appointment.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script type="module" src="../scripts/appointment.js"></script>
2 changes: 1 addition & 1 deletion Frontend/routes/loginSignup/js/signup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ----------------->>>> API and their EndPoints <<<<---------------------

const BaseUrl = "https://nice-pink-antelope-gear.cyclic.app";
const BaseUrl = "https://hair-salon-backend.onrender.com";
const DefaultUrl = `${BaseUrl}/user`;
const RegisterUrl = `${DefaultUrl}/register`

Expand Down
2 changes: 1 addition & 1 deletion Frontend/routes/loginSignup/js/singin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ----------------->>>> API and their EndPoints <<<<---------------------

const BaseUrl = "https://nice-pink-antelope-gear.cyclic.app";
const BaseUrl = "https://hair-salon-backend.onrender.com";
const DefaultUrl = `${BaseUrl}/user`;
const LoginUrl = `${DefaultUrl}/login`

Expand Down
2 changes: 1 addition & 1 deletion Frontend/scripts/admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ------------------- API's ----------------------

const BaseUrl = 'https://nice-pink-antelope-gear.cyclic.app';
const BaseUrl = 'https://hair-salon-backend.onrender.com';
const Default = `${BaseUrl}/admin`
const PostDataCheck = `${Default}/check`

Expand Down
2 changes: 1 addition & 1 deletion Frontend/scripts/adminrender.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ----------------->>>> API and their EndPoints <<<<---------------------

const BaseUrl = 'https://nice-pink-antelope-gear.cyclic.app';
const BaseUrl = 'https://hair-salon-backend.onrender.com';
const DefaultUrl = `${BaseUrl}/services`;
const MaleUrl = `${DefaultUrl}/male`;
const FemaleUrl = `${DefaultUrl}/female`;
Expand Down
4 changes: 2 additions & 2 deletions Frontend/scripts/appointment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ----------------->>>> API and their EndPoints <<<<---------------------

const BaseUrl = 'https://nice-pink-antelope-gear.cyclic.app';
const BaseUrl = 'https://hair-salon-backend.onrender.com';
const DefaultUrl = `${BaseUrl}/appointments`;
const GetAppointment = `${DefaultUrl}/appointment`;
const DeleteAppointment = `${DefaultUrl}/appointment/delete`;
Expand Down Expand Up @@ -136,7 +136,7 @@ window.onload = () => {
document.getElementById("logo-href").href = "../index.html";
document.getElementById("bookhref").href = "gender.html";
document.getElementById("viewhref").href = "appointment.html";
document.getElementById("contacthref").href = "../index.html";
document.getElementById("contacthref").href = "./feedbackForm.html";
// document.getElementById("loginhref").href =
// "";
};
Expand Down
2 changes: 1 addition & 1 deletion Frontend/scripts/feedbackForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ------------------- API's ----------------------

const BaseUrl = "https://nice-pink-antelope-gear.cyclic.app";
const BaseUrl = "https://hair-salon-backend.onrender.com";
const Default = `${BaseUrl}/feedback`;
const PostDataCheck = `${Default}/forms`;

Expand Down
11 changes: 1 addition & 10 deletions Frontend/scripts/gender.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.onload = () => {
document.getElementById("logo-href").href = "../index.html";
document.getElementById("bookhref").href = "gender.html";
document.getElementById("viewhref").href = "appointment.html";
document.getElementById("contacthref").href = "../index.html";
document.getElementById("contacthref").href = "./feedbackForm.html";
};

let nav = document.getElementById("NAVBAR");
Expand All @@ -24,7 +24,6 @@ window.addEventListener("scroll", function () {
var navBar = document.querySelector(".nav");
if (document.documentElement.scrollTop > 50) {
navBar.classList.add("affix");
console.log("Working");
} else {
navBar.classList.remove("affix");
}
Expand All @@ -37,7 +36,6 @@ const observer = new IntersectionObserver((entries) => {
const isVisible = entries[0].isIntersecting;
if (!isVisible) {
navBar.classList.add("affix");
console.log("Working");
} else {
navBar.classList.remove("affix");
}
Expand All @@ -60,13 +58,6 @@ navTrigger.addEventListener("click", function () {
let footer = document.getElementById("footer-main");
footer.innerHTML = Footer();

/* -------------------------------------------------------------------------- */
/* copy this to get navbar and footer */
/* -------------------------------------------------------------------------- */

// let insta = document.getElementById("insta");

// console.log(insta.src)

/* -------------------------------------------------------------------------- */
/* clearing the localStorage and changing Login to Logout */
Expand Down
2 changes: 0 additions & 2 deletions Frontend/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ window.addEventListener("scroll", function () {
var navBar = document.querySelector(".nav");
if (document.documentElement.scrollTop > 50) {
navBar.classList.add("affix");
console.log("Working");
} else {
navBar.classList.remove("affix");
}
Expand All @@ -37,7 +36,6 @@ const observer = new IntersectionObserver((entries) => {
const isVisible = entries[0].isIntersecting;
if (!isVisible) {
navBar.classList.add("affix");
console.log("Working");
} else {
navBar.classList.remove("affix");
}
Expand Down
8 changes: 4 additions & 4 deletions Frontend/scripts/male_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.onload = () => {
document.getElementById("logo-href").href = "../index.html";
document.getElementById("bookhref").href = "gender.html";
document.getElementById("viewhref").href = "appointment.html";
document.getElementById("contacthref").href = "../index.html";
document.getElementById("contacthref").href = "./feedbackForm.html";
// document.getElementById("loginhref").href = "../routes/loginSignup/login.html";
};

Expand Down Expand Up @@ -115,7 +115,7 @@ const card_div = document.querySelector(".card-service-page");
async function getData() {
try {
let data = await fetch(
"https://nice-pink-antelope-gear.cyclic.app/services/male/"
"https://hair-salon-backend.onrender.com/services/male/"
);
data = await data.json();
renderData(data);
Expand Down Expand Up @@ -299,7 +299,6 @@ async function renderData(product_data) {
btn.addEventListener("click", (event) => {
let product_id = event.target.id;
getServiceDat(product_id);
window.location.href = "../html/styler.html";
});
}

Expand All @@ -309,10 +308,11 @@ async function renderData(product_data) {
async function getServiceDat(id) {
try {
let data = await fetch(
`https://nice-pink-antelope-gear.cyclic.app/services/male/${id}`
`https://hair-salon-backend.onrender.com/services/male/${id}`
);
data = await data.json();
sessionStorage.setItem("service_data", JSON.stringify(data));
window.location.href = "../html/styler.html";
} catch (error) {
console.log(error);
}
Expand Down
6 changes: 3 additions & 3 deletions Frontend/scripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.onload = () => {
document.getElementById("logo-href").href = "../index.html";
document.getElementById("bookhref").href = "gender.html";
document.getElementById("viewhref").href = "appointment.html";
document.getElementById("contacthref").href = "../index.html";
document.getElementById("contacthref").href = "./feedbackForm.html";
// document.getElementById("loginhref").href =
// "../routes/loginSignup/login.html";
};
Expand Down Expand Up @@ -117,7 +117,7 @@ const card_div = document.querySelector(".car-div");
async function getData() {
try {
let data = await fetch(
"https://nice-pink-antelope-gear.cyclic.app/services/female/"
"https://hair-salon-backend.onrender.com/services/female/"
);
data = await data.json();
renderData(data);
Expand Down Expand Up @@ -170,7 +170,7 @@ async function renderData(product_data) {
async function getServiceDat(id) {
try {
let data = await fetch(
`https://nice-pink-antelope-gear.cyclic.app/services/female/${id}`
`https://hair-salon-backend.onrender.com/services/female/${id}`
);
data = await data.json();
sessionStorage.setItem("service_data", JSON.stringify(data));
Expand Down
76 changes: 58 additions & 18 deletions Frontend/scripts/styler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ time_btn.addEventListener("submit", (event) => {
let userdata = JSON.parse(localStorage.getItem("userdata"));
let service_data = JSON.parse(sessionStorage.getItem("service_data"));

console.log(userdata)

if(userdata==null){
return Swal.fire({
title: 'Login First',
Expand Down Expand Up @@ -37,7 +35,7 @@ time_btn.addEventListener("submit", (event) => {
let fetAllStylerFn = async (obj) => {
try {
let req = await fetch(
"https://nice-pink-antelope-gear.cyclic.app/stylist/styler",
"https://hair-salon-backend.onrender.com/stylist/styler",
{
method: "GET",
headers: {
Expand All @@ -49,11 +47,20 @@ let fetAllStylerFn = async (obj) => {
let allData = await req.json();
renderStylerFunction(allData, obj);
} else {
alert("Unable to Load the Data");
Swal.fire({
title: 'Unable to Load the Data',
width:"25%",
background:"#243b55",
color:"red"
})
}
} catch (error) {
console.log(error.message);
alert("Unable to Load the Data");
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Bad Request 404',
width:"25%",
})
}
};

Expand Down Expand Up @@ -86,7 +93,12 @@ let renderStylerFunction = (allData, obj) => {

availablilityCheckerFunction(obj);
} else {
alert("please select date and time");
Swal.fire({
title: 'Please select Date and Time',
width:"25%",
background:"#243b55",
color:"red"
})
}
});
}
Expand All @@ -95,7 +107,7 @@ let renderStylerFunction = (allData, obj) => {


let availablilityCheckerFunction = (obj) => {
fetch("https://nice-pink-antelope-gear.cyclic.app/appointments/appointment", {
fetch("https://hair-salon-backend.onrender.com/appointments/appointment", {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand All @@ -117,29 +129,48 @@ let availablilityCheckerFunction = (obj) => {
});

if (newData.length != 0) {
alert("This slot is not available, Please choose another slot!");
Swal.fire({
title: 'This slot is not available, Please choose another slot !',
width:"26%",
background:"#243b55",
color:"red"
})
} else {
//sendMailFunction(obj);
createAppointmentFunction(obj);
}
})
.catch(() => {
alert("Unable to Load the Appointment Data");
Swal.fire({
title: 'Unable to Load the Appointment Data',
width:"26%",
background:"#243b55",
color:"red"
})
});
} else {
alert("Unable to Load the Appointment Data");
Swal.fire({
title: 'Unable to Load the Appointment Data',
width:"26%",
background:"#243b55",
color:"red"
})
}
})
.catch((error) => {
console.log(error.message);
alert("Unable to Load the Appointment Data");
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Bad Request 404',
width:"25%",
})
});
};

async function createAppointmentFunction(obj) {
try {
let add_req = await fetch(
`https://nice-pink-antelope-gear.cyclic.app/appointments/appointment/add`,
`https://hair-salon-backend.onrender.com/appointments/appointment/add`,
{
method: "POST",
headers: {
Expand All @@ -151,11 +182,20 @@ async function createAppointmentFunction(obj) {
if (add_req.ok) {
window.location.href = "./appointment.html";
} else {
alert("unable to add new appointment!");
Swal.fire({
title: 'Unable to add new appointment !',
width:"25%",
background:"#243b55",
color:"red"
})
}
} catch (error) {
console.log(error.message);
alert("unable to add new appointment!");
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Bad Request 404',
width:"25%",
})
}
}

Expand All @@ -170,7 +210,7 @@ window.onload = () => {
document.getElementById("logo-href").href = "../index.html";
document.getElementById("bookhref").href = "gender.html";
document.getElementById("viewhref").href = "appointment.html";
document.getElementById("contacthref").href = "../index.html";
document.getElementById("contacthref").href = "./feedbackForm.html";
// document.getElementById("loginhref").href =
// "../routes/loginSignup/login.html";
};
Expand Down

0 comments on commit c958150

Please sign in to comment.