JSFiddle - React, Tailwind, and code Playground
by igalst
JavaScript
// On load, GET /userDetails
// User details:
const userDetailsResponse = {
isLoggedIn: true, // or false
wishlist: [{
productId,
source
}, /*...*/ ]
}
// manifest with object and handler for next step that gets an object of all the data
// contains questionId (UUID), answerId (UUID)
const aQuestion = (title, options, onSelect) =>
({
id: getUUIDV4(),
title,
options,
onSelect
});
const anOption = (title, image) => ({
id: getUUIDV4(),
title,
image
});
const quizeManifest = [
aQuestion(
'Hey Ronald, I\'m a computer.How would you define yourself ? ', [
anOption('Female', femaleImageRef),
anOption('Male', maleImageRef),
// etc.
],
(answers) => answers[GENDER_QUESTION_ID] === GENDER_FEMALE_OPTION_ID ? ART_LOCATION_QUESTION_ID : false
),
aQuestion( /* ..... */ ),
// etc.
];
const createUser = {
fullName: 'string',
email: 'string',
quiz: {
'questionId1': 'answerId',
'questionId2': 'answerId',
'questionId3': 'answerId'
}
};
// Crate User In db
// get userId
// repsonse: set-cookie: 'token=JWT.encode(UserId)'
// GET /feed
// (next pages would trigger same request, no need for page index)
const feedResponse = [{
productId,
source
}, /*...*/ ];