Creating a scheduling app with React, Nodejs and EmailJS 🧨

A scheduling app is a software tool that helps individuals or organizations manage and organize appointments, meetings, and tasks efficiently by providing a centralized platform to schedule, view, and modify schedules.

Author:Nevo David
Nevo David

What is this article about?

In this article, you’ll learn how to build a scheduling application that allows you to set your availability and share your profile links to enable others to book an appointment with you. You will also be notified via email when someone schedules an appointment.

Novu – the first open-source notification infrastructure

Just a quick background about us. Novu is the first open-sourceĀ notification infrastructure. We basically help to manage all the product notifications. It can beĀ In-AppĀ (the bell icon like you have in Facebook – Websockets), Emails, SMSs and so on.

I would be super happy if you could give us a star! And let me also know in the comments ā¤ļø https://github.com/novuhq/novu

Project Setup

Here, I’ll guide you through creating the project environment for the scheduling application.

Create the project folder for the scheduling application by running the code below:

mkdir scheduling-app
cd scheduling-app
mkdir client server

Setting up the Node.js server

Navigate into the server folder and create aĀ package.jsonĀ file.

cd server & npm init -y

Install Express, Nodemon, and the CORS library.

npm install express cors nodemon

ExpressJSĀ is a fast, minimalist framework that provides several features for building web applications in Node.js,Ā CORSĀ is a Node.js package that allows communication between different domains, andĀ NodemonĀ is a Node.js tool that automatically restarts the server after detecting file changes.

Create anĀ index.jsĀ file – the entry point to the web server.

touch index.js

Set up a Node.js server using Express.js. The code snippet below returns a JSON object when you visit theĀ http://localhost:4000/apiĀ in your browser.

//\ud83d\udc47\ud83c\udffbindex.js
const express = require("express");
const app = express();
const PORT = 4000;

app.use(express.urlencoded({ extended: true }));
app.use(express.json());

app.get("/api", (req, res) => {
    res.json({
        message: "Hello world",
    });
});

app.listen(PORT, () => {
    console.log(`Server listening on ${PORT}`);
});

We’ll create the various API routes later in this tutorial. For now, let’s design the user interface for the application.

Setting up the React application

Here, I’ll guide you through creating the application’s user interface with React.js.

Navigate into the client folder via your terminal and create a new React.js project.

cd client
npx create-react-app ./

Install React Router, React-Toastify, and the React Timezone Select.

npm install react-toastify react-router-dom react-timezone-select

React RouterĀ is a JavaScript library that enables us to navigate between pages in a React application, andĀ Ā React ToastifyĀ is used to display colourful notifications to the users.Ā React Timezone SelectĀ is a simple library that provides various available timezones per location.

Delete the redundant files, such as the logo and the test files from the React app, and update theĀ App.jsĀ file to display Hello World as below.

function App() {
    return (
        
            Hello World!</p>
        </div>
    );
}
export default App;

Copy the CSS file required for styling the projectĀ hereĀ into theĀ src/index.cssĀ file.

Building the user interface

In this section, I’ll walk you through creating the various components required to build the application.

Update theĀ App.jsĀ file to render the following components below:

import React from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
//\ud83d\udc47\ud83c\udffb component
import Dashboard from "./components/Dashboard";
import Login from "./components/Login";
import Signup from "./components/Signup";
import Profile from "./components/Profile";
import BookUser from "./components/BookUser";
//\ud83d\udc47\ud83c\udffb React-Toastify configuration
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

const App = () => {
    return (
        
            
                
                    } />
                    } />
                    } />
                    } />
                    } />
                </Routes>
            </BrowserRouter>
            
        </div>
    );
};

export default App;

From the code snippet above, I imported theĀ Login,Ā Signup,Ā Dashboard,Ā Profile, andĀ BookUserĀ components. Create a components folder containing the files as done below:

cd client
mkdir components
cd components
touch Login.js Signup.js Dashboard.js Profile.js BookUser.js
  • The Login and Signup components are the authentication routes.
  • The Dashboard component is the homepage displayed to authenticated users – where they can set their availability.
  • The Profile component displays the availability to the user, and the BookUser component allows others to schedule an appointment with them.

The Authentication components – Login and Signup

Copy the code below into theĀ Login.jsĀ file to accept the user’s username and password.

import React, { useState } from "react";
import { useNavigate, Link } from "react-router-dom";

const Login = () => {
    const [username, setUsername] = useState("");
    const [password, setPassword] = useState("");
    const navigate = useNavigate();

    const handleSubmit = (e) => {
        if (username.trim() && password.trim()) {
            e.preventDefault();
            console.log({ username, password });
            setPassword("");
            setUsername("");
        }
    };

    return (
        
            
                Log into your account</h2>
                Username</label>
                 setUsername(e.target.value)}
                    className='username'
                />
                Password</label>
                 setPassword(e.target.value)}
                    className='password'
                />
                LOG IN</button>
                
                    Don't have an account?{" "}
                    
                        Create one
                    </Link>
                </p>
            </form>
        </main>
    );
};

export default Login;

Update theĀ Signup.jsĀ component to allow users to create an account using their username, email, and password.

import React, { useState } from "react";
import { useNavigate, Link } from "react-router-dom";
import { handleRegister } from "../utils/resource";

const Signup = () => {
    const [username, setUsername] = useState("");
    const [password, setPassword] = useState("");
    const [email, setEmail] = useState("");
    const navigate = useNavigate();

    const handleSubmit = (e) => {
        e.preventDefault();
        if (username.trim() && password.trim() && email.trim()) {
            console.log(email, username, password);
            setPassword("");
            setUsername("");
            setEmail("");
        }
    };

    return (
        
            
                Create an account</h2>
                Email Address</label>
                 setEmail(e.target.value)}
                />
                Username</label>
                 setUsername(e.target.value)}
                />
                Password</label>
                 setPassword(e.target.value)}
                />
                REGISTER</button>
                
                    Already have an account?{" "}
                    
                        Sign in
                    </Link>
                </p>
            </form>
        </main>
    );
};

export default Signup;

The Dashboard component

Here, we’ll create a user interface that allows users to set their availability according to their location or preferred timezone.Ā React Timezone SelectĀ enables us to select from a list of time zones per location.

Update theĀ Dashboard.jsĀ component as done below:

import React, { useState, useEffect } from "react";
import TimezoneSelect from "react-timezone-select";
import { useNavigate } from "react-router-dom";

const Dashboard = () => {
    const [selectedTimezone, setSelectedTimezone] = useState({});
    const navigate = useNavigate();

    //\ud83d\udc47\ud83c\udffb Runs when a user sign out
    const handleLogout = () => {
        localStorage.removeItem("_id");
        localStorage.removeItem("_myEmail");
        navigate("/");
    };

    return (
        
            
                BookMe</h2>
                
                    Log out
                </button>
            </nav>
            
                Select your availability</h2>

                
                    Pick your timezone</p>
                    
                </div>
            </main>
        </div>
    );
};

The code snippet above displays the component, as shown in the image below. TheĀ handleLogoutĀ function logs a user out of the application by removing the email and id from the local storage.

Below the time zone selection field, we need to create a group of input fields that allow users to set their availability or working hours for each day.

To do this, create a state within the Dashboard component that holds the schedule for each day.

const [schedule, setSchedule] = useState([
    { day: "Sun", startTime: "", endTime: "" },
    { day: "Mon", startTime: "", endTime: "" },
    { day: "Tue", startTime: "", endTime: "" },
    { day: "Wed", startTime: "", endTime: "" },
    { day: "Thu", startTime: "", endTime: "" },
    { day: "Fri", startTime: "", endTime: "" },
    { day: "Sat", startTime: "", endTime: "" },
]);

Create aĀ utilsĀ folder containing aĀ resource.jsĀ file. The file will contain the asynchronous functions needed to make API requests to the server.

cd src
mkdir utils
cd utils
touch resource.js

Create a list of possible working hours from which users can select.

export const time = [
    { id: "null", t: "Select" },
    { id: "7", t: "7:00am" },
    { id: "8", t: "8:00am" },
    { id: "9", t: "9:00am" },
    { id: "10", t: "10:00am" },
    { id: "11", t: "11:00am" },
    { id: "12", t: "12:00pm" },
    { id: "13", t: "13:00pm" },
    { id: "14", t: "14:00pm" },
    { id: "15", t: "15:00pm" },
    { id: "16", t: "16:00pm" },
    { id: "17", t: "17:00pm" },
    { id: "18", t: "18:00pm" },
    { id: "19", t: "19:00pm" },
];

Update theĀ Dashboard.jsĀ file to display the list of working hours for each day.

import { time } from "../utils/resource";
import { toast } from "react-toastify";

const Dashboard = () => {
    const [selectedTimezone, setSelectedTimezone] = useState({})
    //\ud83d\udc47\ud83c\udffb This updates the schedule array with the start and end time.
    const handleTimeChange = (e, id) => {
        const { name, value } = e.target;
        if (value === "Select") return;
        const list = [...schedule];
        list[id][name] = value;
        setSchedule(list);
    };
    //\ud83d\udc47\ud83c\udffb Logs the user's schedule to the console after setting the availability
    const handleSaveSchedules = () => {
        if (JSON.stringify(selectedTimezone) !== "{}") {
            console.log(schedule);
        } else {
            toast.error("Select your timezone");
        }
    };
    return (
        
            
                BookMe</h2>
                
                    Log out
                </button>
            </nav>
            
                Select your availability</h2>
                
                    Pick your timezone</p>
                    

                    {schedule.map((sch, id) => (
                        
                            {sch.day}</p>
                            
                                Start Time</label>
                                 handleTimeChange(e, id)}
                                >
                                    {time.map((t) => (
                                        
                                            {t.t}
                                        </option>
                                    ))}
                                </select>
                            </div>
                            
                                End Time</label>
                                 handleTimeChange(e, id)}
                                >
                                    {time.map((t) => (
                                        
                                            {t.t}
                                        </option>
                                    ))}
                                </select>
                            </div>
                        </div>
                    ))}
                </div>

                
                    SAVE SCHEDULES</button>
                </div>
            </main>
        </div>
    );
};

The Profile component

The Profile component is a simple component that displays the user’s schedule as shown below:

Copy the code below into theĀ Profile.jsĀ file. Later in the tutorial, we’ll fetch its data from the server.

import React from "react";
import { useParams } from "react-router-dom";

const Profile = () => {
    //\ud83d\udc47\ud83c\udffb The ID is the URL parameter for fetching the user's details.
    const { id } = useParams();

    return (
        
            
                Hey, nevodavid</h2>
                Here is your schedule: WAT</p>
                
                    
                        
                            MON</td>
                            8:00am</td>
                            10:00pm</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </main>
    );
};

export default Profile;

The BookUser component

This page shows a user’s availability according to the username from the URL and allows people to book a session with the user.

Copy the code below into theĀ BookUser.jsĀ component.

import React, { useState } from "react";
import { useParams } from "react-router-dom";

const BookUser = () => {
    const [fullName, setFullName] = useState("");
    const [email, setEmail] = useState("");
    const [message, setMessage] = useState("");
    const { user } = useParams();

    //\ud83d\udc47\ud83c\udffb logs the user's details to the console
    const handleSubmit = (e) => {
        e.preventDefault();
        console.log(email, fullName, message);
        setFullName("");
        setMessage("");
    };

    return (
        
            Book a session with {user}</h2>
            
                Full Name</label>
                 setFullName(e.target.value)}
                />
                Email Address</label>
                 setEmail(e.target.value)}
                />

                Any important note? (optional)</label>
                 setMessage(e.target.value)}
                />

                
                    Select your preferred session - GMT+2 Jerusalem
                </label>

                SEND</button>
            </form>
        </div>
    );
};

export default BookUser;

The code snippet above displays a booking form that accepts the client’s full name, email, and message. Later in this tutorial, we’ll improve the component to book a session with a user and send a confirmation email to the user.

The ErrorPage component

This component is displayed to users when an error occurs.

import React from "react";
import { Link } from "react-router-dom";

const ErrorPage = ({ error }) => {
    return (
        
            {error}</h2>
            Go Home</Link>
        </div>
    );
};

export default ErrorPage;

User authentication with React and Node.js

Here, I’ll guide you through authenticating users and how to allow only authorized users to access protected pages within the web application.

Creating new users

Add a register POST route on the server that accepts the user’s username, email, and password from the React application.

app.post("/register", (req, res) => {
    const { username, email, password } = req.body;
    console.log(req.body);
});

Create an asynchronous function within theĀ utils/resource.jsĀ file that accepts the user’s credentials.

export async function handleRegister(email, username, password, navigate) {
    //...data
}

Import theĀ handleRegisterĀ function into theĀ SignupĀ component and pass in the required parameters.

import { handleRegister } from "../utils/resource";
import { useNavigate } from "react-router-dom";

const navigate = useNavigate();

const handleSubmit = (e) => {
    e.preventDefault();
    if (username.trim() && password.trim() && email.trim()) {
        handleRegister(email, username, password, navigate);
        setPassword("");
        setUsername("");
        setEmail("");
    }
};

Update theĀ handleRegisterĀ function to make a POST request to the server.

export async function handleRegister(email, username, password, navigate) {
    try {
        const request = await fetch("http://localhost:4000/register", {
            method: "POST",
            body: JSON.stringify({
                email,
                username,
                password,
            }),
            headers: {
                Accept: "application/json",
                "Content-Type": "application/json",
            },
        });
        const data = await request.json();
        if (data.error_message) {
            toast.error(data.error_message);
        } else {
            toast.success(data.message);
            navigate("/");
        }
    } catch (err) {
        console.error(err);
        toast.error("Account creation failed");
    }
}

Accept the user’s credentials and create an account on the server.

//\ud83d\udc47\ud83c\udffb array representing the data
const database = [];
//\ud83d\udc47\ud83c\udffb generates a random string as ID
const generateID = () => Math.random().toString(36).substring(2, 10);

app.post("/register", (req, res) => {
    const { username, email, password } = req.body;
    //\ud83d\udc47\ud83c\udffb checks if the user does not exist
    let result = database.filter(
        (user) => user.email === email || user.username === username
    );
    //\ud83d\udc47\ud83c\udffb creates the user's data structure on the server
    if (result.length === 0) {
        database.push({
            id: generateID(),
            username,
            password,
            email,
            timezone: {},
            schedule: [],
        });
        return res.json({ message: "Account created successfully!" });
    }
    //\ud83d\udc47\ud83c\udffb returns an error
    res.json({ error_message: "User already exists!" });
});

Logging users into the application

Add a login POST route on the server that accepts the username and password from the React application.

app.post("/login", (req, res) => {
    const { username, password } = req.body;
    console.log(req.body);
});

Create an asynchronous function that accepts the username and password from the user within theĀ utils/resource.jsĀ file.

export async function handleLogin(username, password, navigate) {
    //...data
}

Import theĀ handleLoginĀ function into the Login component as follows:

import { handleLogin } from "../utils/resource";
import { useNavigate } from "react-router-dom";

const navigate = useNavigate();

//\ud83d\udc47\ud83c\udffb The Login button function
const handleSubmit = (e) => {
    if (username.trim() && password.trim()) {
        e.preventDefault();
        //\ud83d\udc47\ud83c\udffb accepts the user's password and email
        handleLogin(username, password, navigate);
        setPassword("");
        setUsername("");
    }
};

Update theĀ handleLoginĀ function to make a POST request to the server.

export async function handleLogin(username, password, navigate) {
    try {
        const request = await fetch("http://localhost:4000/login", {
            method: "POST",
            body: JSON.stringify({
                username,
                password,
            }),
            headers: {
                Accept: "application/json",
                "Content-Type": "application/json",
            },
        });
        const data = await request.json();
        if (data.error_message) {
            toast.error(data.error_message);
        } else {
            //\ud83d\udc47\ud83c\udffbIf login successful
            toast.success(data.message);
            //\ud83d\udc47\ud83c\udffb saves the email and id for identification
            localStorage.setItem("_id", data.data._id);
            localStorage.setItem("_myEmail", data.data._email);
            navigate("/dashboard");
        }
    } catch (err) {
        console.error(err);
    }
}

Accept and verify the user’s credentials on the server.

app.post("/login", (req, res) => {
    const { username, password } = req.body;
    let result = database.filter(
        (user) => user.username === username && user.password === password
    );
    //\ud83d\udc47\ud83c\udffb user doesn't exist
    if (result.length !== 1) {
        return res.json({
            error_message: "Incorrect credentials",
        });
    }
    //\ud83d\udc47\ud83c\udffb user exists
    res.json({
        message: "Login successfully",
        data: {
            _id: result[0].id,
            _email: result[0].email,
        },
    });
});

Since we’ll be making requests that require authentication on the server, add the code snippet below to theĀ DashboardĀ andĀ ProfileĀ components.

useEffect(() => {
    if (!localStorage.getItem("_id")) {
        navigate("/");
    }
}, [navigate]);

Creating schedules

In this section, I’ll walk you through creating the process of schedules and displaying them to the user.

Add a POST route on the server that allows users to create a new schedule.

app.post("/schedule/create", (req, res) => {
    const { userId, timezone, schedule } = req.body;
    console.log(req.body);
});

Create aĀ handleCreateScheduleĀ function within theĀ utils/resource.jsĀ file that accepts the user’s timezone and schedule.

export async function handleCreateSchedule(
    selectedTimezone,
    schedule,
    navigate
) {
    //..other data
}

Import theĀ handleCreateScheduleĀ function within the Dashboard component.

import { handleCreateSchedule } from "../utils/resource";

const handleSaveSchedules = () => {
//\ud83d\udc47\ud83c\udffb ensures the user's timezone has been selected
    if (JSON.stringify(selectedTimezone) !== "{}") {
        handleCreateSchedule(selectedTimezone, schedule, navigate);
    } else {
        toast.error("Select your timezone");
    }
};

Update theĀ handleCreateScheduleĀ function to make a POST request containing the schedules and the timezone.

export async function handleCreateSchedule(
    selectedTimezone,
    schedule,
    navigate
) {
    try {
        await fetch("http://localhost:4000/schedule/create", {
            method: "POST",
            body: JSON.stringify({
                userId: localStorage.getItem("_id"),
                timezone: selectedTimezone,
                schedule,
            }),
            headers: {
                Accept: "application/json",
                "Content-Type": "application/json",
            },
        });
        //\ud83d\udc47\ud83c\udffb navigates to the profile page
        navigate(`/profile/${localStorage.getItem("_id")}`);
    } catch (err) {
        console.error(err);
    }
}

Update the POST route on the server to accept the data from the React app and create a new schedule for the user.

app.post("/schedule/create", (req, res) => {
    const { userId, timezone, schedule } = req.body;
    //\ud83d\udc47\ud83c\udffb filters the database via the id
    let result = database.filter((db) => db.id === userId);
    //\ud83d\udc47\ud83c\udffb updates the user's schedule and timezone
    result[0].timezone = timezone;
    result[0].schedule = schedule;
    res.json({ message: "OK" });
});

Congratulations! šŸŽ‰ We’ve been able to update the user’s schedule and timezone.

Displaying the schedules

Here, I will walk you through fetching the user’s schedules from the server.

Add a GET route on the server that retrieves the user’s data from the database array.

app.get("/schedules/:id", (req, res) => {
    const { id } = req.params;
    //\ud83d\udc47\ud83c\udffb filters the array via the ID
    let result = database.filter((db) => db.id === id);
    //\ud83d\udc47\ud83c\udffb returns the schedule, time and username
    if (result.length === 1) {
        return res.json({
            message: "Schedules successfully retrieved!",
            schedules: result[0].schedule,
            username: result[0].username,
            timezone: result[0].timezone,
        });
    }
    //\ud83d\udc47\ud83c\udffb if user not found
    return res.json({ error_message: "Sign in again, an error occured..." });
});

Create a function within theĀ Profile.jsĀ file that sends a request to the GET route when the page is loaded.

const [schedules, setSchedules] = useState([]);
const [loading, setLoading] = useState(true);
const [username, setUsername] = useState("");
const [timezone, setTimezone] = useState("");

useEffect(() => {
    function getUserDetails() {
        if (id) {
            fetch(`http://localhost:4000/schedules/${id}`)
                .then((res) => res.json())
                .then((data) => {
                    setUsername(data.username);
                    setSchedules(data.schedules);
                    setTimezone(data.timezone.label);
                    setLoading(false);
                })
                .catch((err) => console.error(err));
        }
    }
    getUserDetails();
}, [id]);

And display the data as shown below:

return (
    
        {loading ? (
            Loading...</p>
        ) : (
            
                Hey, {username}</h2>
                Here is your schedule: - {timezone}</p>
                
                    
                        {schedules.map((sch) => (
                            
                                {sch.day.toUpperCase()}</td>
                                {sch.startTime || "Unavailable"}</td>
                                {sch.endTime || "Unavailable"}</td>
                            </tr>
                        ))}
                    </tbody>
                </table>
            </div>
        )}
    </main>
);

Booking appointments with EmailJS

In this section, you’ll learn how to send email notifications via EmailJS when clients book an appointment with a user.

EmailJSĀ is a JavaScript library that enables us to send emails via client-side technologies only – without a server. With EmailJS, you can send texts and email templates and add attachments to the emails.

Create a POST route on the server that fetches the user’s data.

app.post("/schedules/:username", (req, res) => {
    const { username } = req.body;
    //\ud83d\udc47\ud83c\udffb filter the databse via the username
    let result = database.filter((db) => db.username === username);
    if (result.length === 1) {
        const scheduleArray = result[0].schedule;
        //\ud83d\udc47\ud83c\udffb return only the selected schedules
        const filteredArray = scheduleArray.filter((sch) => sch.startTime !== "");
        //return the schedules and other information
        return res.json({
            message: "Schedules successfully retrieved!",
            schedules: filteredArray,
            timezone: result[0].timezone,
            receiverEmail: result[0].email,
        });
    }
    return res.json({ error_message: "User doesn't exist" });

Add aĀ fetchBookingDetailsĀ function within theĀ resource.jsĀ file.

export function fetchBookingDetails(
    user,
    setError,
    setTimezone,
    setSchedules,
    setReceiverEmail
) {
    //...data
}

Import the function into theĀ BookUser.jsĀ component and call it with its necessary parameters on page load.

const [schedules, setSchedules] = useState([]);
const [timezone, setTimezone] = useState("");
const [error, setError] = useState(false);
const [receiverEmail, setReceiverEmail] = useState("");

useEffect(() => {
    fetchBookingDetails(
        user,
        setError,
        setTimezone,
        setSchedules,
        setReceiverEmail
    );
}, [user]);

if (error) {
    return ;
}

Update theĀ fetchBookingDetailsĀ function to retrieve the information from the server and update the state parameters.

export function fetchBookingDetails(
    user,
    setError,
    setTimezone,
    setSchedules,
    setReceiverEmail
) {
    fetch(`http://localhost:4000/schedules/${user}`, {
        method: "POST",
        body: JSON.stringify({
            username: user,
        }),
        headers: {
            Accept: "application/json",
            "Content-Type": "application/json",
        },
    })
        .then((res) => res.json())
        .then((data) => {
            if (data.error_message) {
                toast.error(data.error_message);
                setError(true);
            } else {
                setTimezone(data.timezone.label);
                setSchedules(data.schedules);
                setReceiverEmail(data.receiverEmail);
            }
        })
        .catch((err) => console.error(err));
}

Render the schedule within the form to enable users to select their preferred appointment time.

setDuration(e.target.value)}>
    {schedules.map((schedule) => (
        {`${schedule.day} - ${schedule.startTime} : ${schedule.endTime}`}</option>
    ))}
</select>

Sending email notifications with EmailJS

Here, I’ll guide you through adding EmailJS to the React.js application and how to send emails to users whenever someone books an appointment with them.

Install EmailJS to the React application by running the code below:

npm install @emailjs/browser

Create an EmailJS accountĀ hereĀ and add an email service provider to your account.

Add an email template as done in the image below:

The words in curly brackets represent variables that can hold dynamic data.

Import EmailJS into theĀ utils/resource.jsĀ file and create a function that sends an email notification to the user.

import emailjs from "@emailjs/browser";

export const sendEmail = (
    receiverEmail,
    email,
    fullName,
    message,
    duration
) => {
    emailjs
        .send(
            "YOUR_SERVICE_ID",
            "YOUR_TEMPLATE_ID",
            {
                to_email: receiverEmail,
                from_email: email,
                fullName,
                message,
                duration,
            },
            "YOUR_PUBLIC_KEY"
        )
        .then(
            (result) => {
                console.log(result.text);
                toast.success("Session booked successfully!");
            },
            (error) => {
                console.log(error.text);
                toast.error(error.text);
            }
        );
};

You can get your EmailJS Public key from the Account section of your EmailJS dashboard.

Add theĀ sendEmailĀ function into theĀ BookUserĀ component to send an email to the user containing the booking information whenever the form is submitted.

const handleSubmit = (e) => {
    e.preventDefault();
    sendEmail(receiverEmail, email, fullName, message, duration);
    setFullName("");
    setMessage("");
};

Congratulations! šŸŽ‰ You’ve completed the project for this tutorial.

Conclusion

So far, you’ve learnt how to create a scheduling application that enables users to set their availability and get notified via EmailJS when they have an appointment.

This tutorial walks you through a mini project you can build using React and Node.js. You can improve the application by adding an authentication library and storing the data in a database.

The source code for this tutorial is available here:

https://github.com/novuhq/blog/tree/main/scheduling-app-with-react-nodejs-emailjs

Thank you for reading!

Help me out!

If you feel like this article helped you understand WebSockets better! I would be super happy if you could give us a star! And let me also know in the comments ā¤ļø https://github.com/novuhq/novu

https://github.com/novuhq/blog/tree/main/scheduling-app-with-react-nodejs-emailjs

Read More

You’re five minutes away from your first Novu-backed notification

Create a free account, send your first notification, all before your coffee gets cold... no credit card required.