const about = require('../../models/about');
const helper = require('../../helper');
const express = require("express");
//const bodyParser = require("body-parser");
const router = express.Router();
const config = require("../../config")
//var jsonParser = bodyParser.json()
//var urlencodedParser = bodyParser.urlencoded({ extended: false })
const app = express();
app.use(express.json());

router.post("/about", async (req, res, next) => {
     if(helper.check_headers(req) == "True"){
        var section1_data = await about.get_feature()
        var section2 = await about.get_service_feature()
        
        var section1 = [];
        section1_data.map(function(val, index) {
            temp={
                'image': config.baxter_url+"uploads/about/"+val.image,
                'icon': config.baxter_url+"uploads/about/"+val.icon,
                'title': val.title,
                'description': val.description
            }
            
            section1.push(temp)
        });

        section2.image1 = config.baxter_url+"uploads/about/"+section2.image1
        section2.image2 = config.baxter_url+"uploads/about/"+section2.image2
        section2.image3 = config.baxter_url+"uploads/about/"+section2.image3
        section2.image4 = config.baxter_url+"uploads/about/"+section2.image4

        res.status(200).json({
            message: "Successfull",
            status: "True",
            data:{
                section1: section1,
                section2: section2
            }
        });
     }else{
        res.status(200).json({
            message: "Unauthorised request",
            status: "Fail"
        });
     }
});

module.exports = router;