In this post, I’m going to show you how to create a simple event sign up system. Since one of the goals is to create something quickly, we are going to use Corvid to build the application.

Corvid is a development platform from Wix, which allows you to concentrate on the logic of the application using JavaScript and not spend time on writing HTML/CSS to create the UI. Corvid is focused on helping teams dramatically decrease time spent on development and ship products faster.

You can find the complete documentation, tutorial videos, and examples here:

Creating the UI

First of all, we’re going to create a layout for our future page. Fun fact: it will take you from 10 to 25 minutes, depending on your familiarity with the platform.

Let’s assume we have the following user flow:

  • A user signs up for the event by filling out the form =>
  • A unique QR-code is generated based on their user id =>
  • The QR-code can be either saved as a picture or sent to email =>
  • On the day of the event, a user shows the QR-code at the entrance =>
  • Event administrators scan the code and submit the attendance

In the Wix Editor, login and choose to create a new site (“+Create New Site” in the upper right corner of the account dashboard). In this example, I’ve used a blank template, but you can choose any and customize it according to your own preferences.

You may also like:
Modeling Domain Events.

You’ll also need to enable Corvid Developer Tools to rename and manage your elements. If you feel confused about how to do this, check out this link:

We’ll need to create two pages: the first one will be public (for users to sign in), and another one is for admins to submit guests’ attendance. I’ve also created two lightboxes (pop-ups) to show success messages after completing the form and attendance submission. You can learn more about how to create pages and lightboxes here:

At this point, your Site Structure should look pretty much like this:

Site structure

Site structure
Let’s create a basic layout for our sign up
“HOME” page. We’ll need to create three user inputs: 
#email#phoneNumber, and a 
#signUpButton. I’ve put all three inputs in the 
#signInBox to make these elements easier to collapse. (You’ll see it later in the code.)

We’ll also add a default image, #qrCodeImage, for our future QR-code and a #sendToEmailButton button to the same page to avoid redirect (you still can put these elements on the other page if you have too many of them, but choose what works better for your project’s performance). Both #qrCodeImage and #sendToEmailButton are collapsed on load and shown to users only when they successfully sign up with the registration form.

In the end, your page should look something like this:

Sample output

Sample output

In the upper right corner, you can see the checkmark in the “Collapsed on load” field. That’s how we collapse #qrCodeImage and #sendToEmailButton when users first loads the page.

Note: there is a difference between “hide” and “collapse.” A collapsed element shifts all elements that are below it up when not visible, and a hidden one doesn’t affect the neighbor elements and reserves place for itself no matter if it’s visible or not. 

Now, when we’re done with our “HOME” page, let’s design the admin page. It will only have two elements: #guestName and #submitButton (nothing fancy).

Note: I’m keeping it simple in this example, but feel free to play around with the page design.

Don’t forget to add success messages to your lightboxes.

Adding a Database

To store our users’ data, we will use a built-in database. Let’s create one and call it “Participants” (the naming is up to you). The database needs to have six columns:

  1. title: (fieldType: Text).
  2. phone: (fieldType: Number).
  3. attended: (fieldType: Boolean).
  4. userId: (fieldType: Text).
  5. qrCodeLink: (fieldType: Url).
  6. email: (fieldType: Text).

If you’re not sure about how to create a database, check out this documentation page.

Writing Code

And now we’re coming to the most fun part: coding. We’re going to use the Corvid API and some custom JavaScript code to describe logics for our site. All API references and examples can be found here:

I’m going to break it into several feature-based parts:

  1. Signing up.
  2. Generating a QR-code.
  3. Submitting data to the database.
  4. Showing the QR-code to the user.
  5. Sending it to a user’s email.
  6. Attendance submission.

Signing Up

Let’s add an event to our #signUpButton. In this example, I’m adding all events inside the $w.onReady() function. First of all, I’m importing four built-in modules, which I’ll use to process data: uuid (to generate unique user id), wixData (to submit data to the database), wixLocation (for passing url to QRCode generator function), and wixWindow (to open the lightbox).

I’m also creating a new object with user data that will be passed from the inputs later and an obligatory _id field.

Generating QR-Code

Corvid supports some built-in npm packages which can be installed right from the editor. The complete list of currently supported modules and how to add them to your project can be found here (more modules will be added in the nearest future):

I’m using the module named “qrcode,” which makes it super easy to convert URLs to QR. The documentation for this module is on Github:

We must import all the npm modules to the backend, so, in the backend section of the project, I’ve created a jsw-module called “createUrl.jsw”.

Quick update on the site structure:

Updated file structure

Updated file structure

In this module, I import the npm-package and return the QR-code URL:

Submitting Data to the Database

Now, let’s receive the actual user’s data and on “Sign up” button click submit it to the database.

Showing the QR-Code to the User

Let’s get back to our “HOME” code. The API returns a promise, so chain .then() methods to process the result returned. I’m waiting until the end of database submission, passing the received URL as a source to #qrCodeImage, collapsing the form, and expanding the #qrCodeImage and #sendToEmailButton. Finally, I’m cleaning all the form’s values.

Sending a QR-Code to the User’s Email

The last thing we are going to finish before going to the admin’s page is sending a success email with a QR-code to the user. In Corvid, you can easily create triggered emails by adding your email template to the “Email marketing” tab in the Dashboard. 

To learn more, check out this link:

Response email

Response email

For this triggered email, I’ve created two variables: ${userName} and ${qrCodeLink} to pass custom data. 

Corvid provides you with ready-to-go snippets after clicking on the Save & Publish button. Let’s copy it to our code inside the Send to email button event:

Note: There is no Wix login required in this example, so before sending the email, we need to create a contact in the Wix CRM system.

I also open a lightbox with a success message and return the page to initial state after the email is sent.

Attendance Submission

The last part of this user journey will happen on the day of the actual event. A user shows the downloaded QR-code at the entrance, gets it scanned, and their attendance is submitted. 

Let’s add the following logic to the Attendance Admin page:

A unique userId is passed as a query in the URL from the QRcode, so we need to receive it using  wixLocation.query.userId.

After this id is received, we are able to receive the user’s data from the database, pass their name to the text field, #guestName on the page, and submit refreshed data with a changed “attended” field value back to the database.

Note: don’t forget to change permissions of the Attendance Admin page to make it only visible to admins. To learn more follow this link:

Further Reading

Source link

Write A Comment