Skip to content

Secret Santa Generator is a simple and easy application that lets users create anonymous gift giver and gift receiver pairs by SMS. Built with React, JavaScript, HMLT, CSS.

Notifications You must be signed in to change notification settings

nickdraper8/secret-santa

Repository files navigation

Secret Santa Generator

Secret Santa Generator is a simple and easy application that lets users create anonymous gift giver and gift reciever pairs by SMS.

About

Have you ever been annoyed with other online secret santa generators that make you login, signup, do this and that when all you want is something that will handle some simple logic and keep things anonymous? Look no further! This Secret Santa Generator takes all the unessesary bs away from something that should really be very simple. Here is how it works.

First, you are shown a page where you can view the directions if you aren't familiar with the app, or head straight into adding participants onto your event.

firstpage

Once finished, head to the review page where you can review the information you entered, and if the creator wants, they can view the pairings the app generated. If the creator is involved in the secret santa event and wants to keep it anonymous, just click the finish button and send out the SMS messages!

secondpage

Each participant will recieve a message briefly letting them know who their gift recipient is. No further emails, text messages, or anything will bother anyone. That's it, it's that simple!

phonegif

Code Snippets

Creating the gift giver - gift reciever relationships

In order to create a randomized set of relationships for each of the participants, I decided creating a structure similar to a looped singly-linked list. First, however, I would need to randomize the list of participants. To do this, I used the Durstenfeld shuffle, an optimized version of the Fisher-Yates array shuffle algorithm.

// src/util/array_utility.js
export function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    };
};

Next, I iterate through the suffled array, assigning the current participant the next participant in the list. Once I reach the last the participant, I assign them the first participant in the list. Here is a diagram of what the array looks like and how it works, as well as the code that generates it.

phonegif

// src/util/array_utility.js
export function makeAssignments(array) {
    let assignments = [];
    for (let i = 0; i < array.length; i++) {
        if (i === array.length-1) {
            assignments.push([array[i], array[0]])
        } else {
            assignments.push([array[i], array[i+1]])
        }
    }
    return assignments
}

About

Secret Santa Generator is a simple and easy application that lets users create anonymous gift giver and gift receiver pairs by SMS. Built with React, JavaScript, HMLT, CSS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published