In this episode, we dive into building out the UI for adding notification email addresses in our app. Starting from scratch, we design a flexible container in the dashboard for different notification channels, but focus on emails for now. We use Tailwind to set up a neat grid layout and then extract the email part into its own component for better organization.
After structuring things, we wire up the frontend form with the necessary input fields and button, making use of existing UI components for consistency and faster development. We hook up the form to use Inertia for submitting data and set it up to post to a newly defined endpoint for storing emails related to a particular site. Along the way, we implement handy UX touches—like auto-resetting the form on success and keeping the scroll position with preserveScroll
so users aren't bounced to the top of the page.
On the backend, we prepare the necessary controller and route to accept and store the emails in a JSON array column. We make sure to handle email validation—including creating a unique rule to prevent duplicate addresses since we're dealing with an array inside a JSON column, not normal DB rows. We also cover authorization, setting up policies to ensure only permitted users can add notification channels to a site.
By the end of the video, you'll have a working feature where users can add, validate, and store notification email addresses for a site—all done via a clean UI, with the backend persisting everything safely and with the right rules. Next, we'll look at displaying these stored email addresses back to the user!