npssurvey
v1.2.18
Published
NPS survey form
Downloads
126
Readme
npssurvey
Nps Survey is a Npm library for getting survey responses back. This also has an option to deal with follow-up questions in a particular option.
Installation (npm)
Use the package manager npm to install npssurvey.
npm i npssurvey
Installation (yarn)
Use the package manager yarn to install npssurvey.
yarn add npssurvey
Usage
//The package should be imported initially
import NpsSurvey from "npssurvey";
//This is how the data to the survey form should be passed
const json = [
{
"_id": "place your uuid here",
"question_type": "multiple_options",
"question_text": "1",
"multi_response": true,
"options": [
{
"_id": "place your uuid here",
"option_text": "a",
"custom_attribute": []
},
{
"_id": "place your uuid here",
"option_text": "b",
"custom_attribute": []
},
]
},
{
"_id": "place your uuid here",
"question_type": "true_false",
"question_text": "2",
"options": [
{
"_id": "place your uuid here",
"option_text": "True",
"custom_attribute": []
},
{
"_id": "place your uuid here",
"option_text": "False",
"custom_attribute": []
}
]
},
{
"_id": "place your uuid here",
"question_type": "text_based",
"question_text": "3",
"is_follow_up": true,
"options": []
},
{
"_id": "place your uuid here",
"question_type": "custom_attribute",
"question_text": "orders",
"selected_option": "Top 5 Orders",
"options": [
{
"_id": "place your uuid here",
"custom_attribute": [
{
"sku_name": "skuname goes here",
"sku_image": "image-url goes here",
"delivered_at": "date",
"_id": "place your uuid here"
},
{
"sku_name": "skuname goes here",
"sku_image": "image-url goes here",
"delivered_at": "date",
"_id": "place your uuid here"
},
]
}
]
},
{
"_id": "place your uuid here",
"question_type": "multiple_options",
"question_text": "5",
"options": [
{
"_id": "place your uuid here",
"option_text": "a",
"has_follow_up": true,
"follow_up_question": "place your followup uuid here",
"custom_attribute": []
},
{
"_id": "place your uuid here",
"option_text": "b",
"has_follow_up": true,
"follow_up_question": "place your followup uuid here",
"custom_attribute": []
}
]
},
{
"_id": "place your uuid here",
"question_type": "true_false",
"question_text": "6",
"is_follow_up": true,
"options": [
{
"_id": "place your uuid here",
"option_text": "True",
"custom_attribute": []
},
{
"_id": "place your uuid here",
"option_text": "False",
"custom_attribute": []
}
]
},
{
"_id": "place your uuid here",
"question_type": "custom_attribute",
"question_text": "skus",
"selected_option": "Top 10 SKUs",
"options": [
{
"_id": "place your uuid here",
"custom_attribute": [
{
"sku_name": "skuname goes here",
"sku_image": "image-url goes here",
"qty": "97",
"_id": "place your uuid here"
},
{
"sku_name": "skuname goes here",
"sku_image": "image-url goes here",
"qty": "18",
"_id": "place your uuid here"
},
]
}
]
}
];
//This is the driver code
const App = () => {
return (
<NpsSurvey
Survey={json}
surveyCompleted={(result) => {
alert("Survey completed Successfully! Data:", result);
}}
/>
);
};
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.