import { Request, Response } from "express";
import express from "express";
import { createReport } from ".";
import { RequestData } from "./types";

const app = express();
const port = 5000;
const TIMETRACK_ID = "REPORT_CREATION";

const _data: RequestData = {
  type: "Employee",
  params: {
    header: [
      { name: "Michael Black" },
      { jobRole: "Software engineer" },
      { organization: "Thrive" },
      { assesedDate: "12/12/2022" },
    ],
    competencies: {
      strength: [
        {
          skill: "Expertise",
          marked: true,
          text: "This assessment measures your logical thinking ability and consequently your inductive reasoning. Inductive reasoning is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        },
        {
          skill: "Influence",
          marked: false,
          text: "This assessment measures your logical thinking ability and consequently your inductive reasoning. Inductive reasoning is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        },
        {
          skill: "Innovation",
          marked: false,
          text: "This assessment measures your logical thinking ability and consequently your inductive reasoning. Inductive reasoning is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        },
      ],
      weakness: [
        {
          skill: "Leadership",
          marked: false,
          text: "This assessment measures your logical thinking ability and consequently your inductive reasoning. Inductive reasoning is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        },
        {
          skill: "Teamwork",
          marked: false,
          text: "This assessment measures your logical thinking ability and consequently your inductive reasoning. Inductive reasoning is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        },
        {
          skill: "Initiative & Responsbility",
          marked: false,
          text: "This assessment measures your logical thinking ability and consequently your inductive reasoning. Inductive reasoning is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        },
      ],
    },
    //16 personalities
    personality: [
      {
        skill: "Drive & Focus",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Teamwork",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
      {
        skill: "Teamwork",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Teamwork",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
      {
        skill: "Drive & Focus",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Teamwork",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
      {
        skill: "Drive & Focus",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Drive & Focus",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
      {
        skill: "Result Focus",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Teamwork",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
      {
        skill: "Drive & Focus",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Teamwork",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
      {
        skill: "Drive & Focus",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Teamwork",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
      {
        skill: "Drive & Focus",
        marked: true,
        result: "Well above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 89,
      },
      {
        skill: "Drive & Focus",
        marked: false,
        result: "Above average",
        text: "This assessment measures basic numeracy on the basis of the four basic arithmetic operations. A conscientious handling with numbers and a confident mastery of the four basic arithmetic operations is vitally important in certain occupational areas. Compared to other participants, it is easier for you to handle the tasks in this assessment successfully.",
        barValue: 67,
      },
    ],
    waysToDevelop: [
      {
        skill: "Vision & Strategy",
        marked: true,
        texts: [
          "Set yourself targets and specific goals. These might be small daily goals, or longer-term achievements that you are working towards.",
          "Try to envision the path to achieving your goals, anticipating any obstacles and considering how you might overcome these Set a schedule for your week and day, including realistic targets, timings and deadlines for task completion.",
          "Identify tangible rewards to help keep you focused and motivated. For example, having a 15 minute break to watch your favourite show once you've completed an important task, before moving on to the next.",
        ],
      },
      {
        skill: "Commercial Growth",
        marked: true,
        texts: [
          "Set yourself targets and specific goals. These might be small daily goals, or longer-term achievements that you are working towards.",
          "Try to envision the path to achieving your goals, anticipating any obstacles and considering how you might overcome these Set a schedule for your week and day, including realistic targets, timings and deadlines for task completion.",
          "Identify tangible rewards to help keep you focused and motivated. For example, having a 15 minute break to watch your favourite show once you've completed an important task, before moving on to the next.",
        ],
      },
      {
        skill: "Vision & Strategy",
        marked: false,
        texts: [
          "Set yourself targets and specific goals. These might be small daily goals, or longer-term achievements that you are working towards.",
          "Try to envision the path to achieving your goals, anticipating any obstacles and considering how you might overcome these Set a schedule for your week and day, including realistic targets, timings and deadlines for task completion.",
          "Identify tangible rewards to help keep you focused and motivated. For example, having a 15 minute break to watch your favourite show once you've completed an important task, before moving on to the next.",
        ],
      },
      {
        skill: "Commercial Growth",
        marked: false,
        texts: [
          "Set yourself targets and specific goals. These might be small daily goals, or longer-term achievements that you are working towards.",
          "Try to envision the path to achieving your goals, anticipating any obstacles and considering how you might overcome these Set a schedule for your week and day, including realistic targets, timings and deadlines for task completion.",
          "Identify tangible rewards to help keep you focused and motivated. For example, having a 15 minute break to watch your favourite show once you've completed an important task, before moving on to the next.",
        ],
      },
    ],
  },
};

app.get("/", async (_: Request, res: Response) => {
  console.time(TIMETRACK_ID);

  try {
    const buffer = await createReport(_data, _data.type);

    res.set({
      "Content-Disposition": "attachment; filename=Employee.pdf",
      "Content-Type": "application/pdf; charset=utf-8",
    });
    res.write(buffer);
    res.end();
    console.timeEnd(TIMETRACK_ID);
  } catch (e) {
    console.error(e);
  }
});

app.listen(port, () => {
  console.log(`Test server listening on port ${port}`);
});
