function buildPayload(personality,benchmarks,communication,skill,name) {
const r = personality.filter(d => d.Person === name)[0];
const b = benchmarks.filter(r => r.Group === "Personality");
const c = communication.filter(d => d.Person === name)[0];
const s = skill.filter(d => d.Person === name)[0];
const b2 = benchmarks.filter(r => r.Group === "Skill");
const overallSkill = Object.values(s).filter(value => typeof value === 'number').reduce((acc, val, _, arr) => acc + val / arr.length, 0).toFixed(0) + '%';
const summary = JSON.stringify(c.Summary);
return JSON.parse(`{
"main template datasheet container": {
"p1-dot-plot": [
[ "Personality Trait", "color", "${name}" ],
[ "Assertive", "score", "${r.Assertive}" ],
[ "Resilient", "score", "${r.Resilient}" ],
[ "Adaptable", "score", "${r.Adaptable}" ],
[ "Empathetic", "score", "${r.Empathetic}" ],
[ "Creative", "score", "${r.Creative}" ],
[ "Proactive", "score", "${r.Proactive}" ],
[ "Analytical", "score", "${r.Analytical}" ],
[ "Meticulous", "score", "${r.Meticulous}" ],
[ "Emotionally intelligent", "score", "${r['Emotionally intelligent']}" ],
[ "Reliable", "score", "${r.Reliable}" ],
[ "Organized", "score", "${r.Organized}" ],
[ "Diplomatic", "score", "${r.Diplomatic}" ],
[ "Inspirational", "score", "${r.Inspirational}" ],
[ "Ethical", "score", "${r.Ethical}" ],
[ "Inclusive", "score", "${r.Inclusive}" ],
[ "Assertive", "BM", "${b.filter(r => r.Characteristic === 'Assertive')[0].Benchmark}" ],
[ "Resilient", "BM", "${b.filter(r => r.Characteristic === 'Resilient')[0].Benchmark}" ],
[ "Adaptable", "BM", "${b.filter(r => r.Characteristic === 'Adaptable')[0].Benchmark}" ],
[ "Empathetic", "BM", "${b.filter(r => r.Characteristic === 'Empathetic')[0].Benchmark}" ],
[ "Creative", "BM", "${b.filter(r => r.Characteristic === 'Creative')[0].Benchmark}" ],
[ "Proactive", "BM", "${b.filter(r => r.Characteristic === 'Proactive')[0].Benchmark}" ],
[ "Analytical", "BM", "${b.filter(r => r.Characteristic === 'Analytical')[0].Benchmark}" ],
[ "Meticulous", "BM", "${b.filter(r => r.Characteristic === 'Meticulous')[0].Benchmark}" ],
[ "Emotionally intelligent", "BM", "${b.filter(r => r.Characteristic === 'Emotionally intelligent')[0].Benchmark}" ],
[ "Reliable", "BM", "${b.filter(r => r.Characteristic === 'Reliable')[0].Benchmark}" ],
[ "Organized", "BM", "${b.filter(r => r.Characteristic === 'Organized')[0].Benchmark}" ],
[ "Diplomatic", "BM", "${b.filter(r => r.Characteristic === 'Diplomatic')[0].Benchmark}" ],
[ "Inspirational", "BM","${b.filter(r => r.Characteristic === 'Inspirational')[0].Benchmark}" ],
[ "Ethical", "BM", "${b.filter(r => r.Characteristic === 'Ethical')[0].Benchmark}" ],
[ "Inclusive", "BM", "${b.filter(r => r.Characteristic === 'Inclusive')[0].Benchmark}" ]
],
"p2-pie-top": [
[ "category", "${name}" ],
[ "Graphic", "${c.Graphic}" ],
[ "Data-driven", "${c['Data driven']}" ],
[ "Storytelling", "${c.Storytelling}" ]
],
"p2-pie right": [
[ "category", "${name}" ],
[ "Direct", "${c.Direct}" ],
[ "Diplomatic", "${c.Diplomatic}" ],
[ "Expressive", "${c.Expressive}" ]
],
"p2-pie left": [
[ "category", "${name}" ],
[ "Formal", "${c.Formal}" ],
[ "Informal", "${c.Informal}" ]
],
"p3-left": [
[ "Category", "Capacity to effectively persuade and influence", "Skill in handling sensitive or delicate situations tactfully", "Skill in building and maintaining professional relationships", "Capacity to work effectively in a team environment", "Ability to manage and resolve conflicts in a constructive manner", "Skill in presenting compelling arguments and supporting evidence" ],
[ "benchmark", "${b2.filter(r =>r.Characteristic === 'Persuasion')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Tactfulness')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Relationship building')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Teamwork')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Conflict resolution')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Argumentation')[0].Benchmark}" ],
[ "score", "${s.Persuasion}", "${s.Tactfulness}", "${s['Relationship building']}", "${s.Teamwork}", "${s['Conflict resolution']}", "${s.Argumentation}" ]
],
"p3-right": [
[ "Category", "Skill in negotiating and finding mutually beneficial solutions", "Willingness to share knowledge and resources with colleagues", "Ability to see situations from different perspectives", "Ability to provide appropriate feedback and ask relevant questions", "Ability to leverage networks for personal and organizational growth", "Ability to build consensus and gain support for ideas or initiatives" ],
[ "benchmark", "${b2.filter(r =>r.Characteristic === 'Persuasion')[0].Negotiation}", "${b2.filter(r =>r.Characteristic === 'Collaboration')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Empathy')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Inquiry')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Networking')[0].Benchmark}", "${b2.filter(r =>r.Characteristic === 'Consensus building')[0].Benchmark}" ],
[ "score", "${s.Negotiation}", "${s.Collaboration}", "${s.Empathy}", "${s.Inquiry}", "${s.Networking}", "${s['Consensus building']}" ]
],
"Text": [
[ "Employee", "Year", "Job Match", "Top pie label", "Left Pie label", "Right pie label", "Communication Styles", "Interpersonal skills" ],
[ "${name}", "2023", "${overallSkill}", "Visual", "Verbal", "Written", ${summary} ],
[ "", "", "", "", "", "", "", "" ],
[ "", "", "", "", "", "", "", "" ]
]
}
}`);
}