
const ProjectTopic = require("../../models").project_topics

exports.Submit = async (req, res) => {
    try {
        const {
            projectType,
            projectTopics,
            user_id,
            lecturer_id,
            cbo_username,
            cbo_otp
        } = req.body;
        // const checkOtp = await CafeOTP.findOne({where:{username:cbo_username,otp_code:cbo_otp,status:false}});
        // if(!checkOtp)
        // return res.status(200).send({success:false, message:"Invalid Authorization Code"})
        projectTopics.forEach(async data => {
            result = await ProjectTopic.create({
                project_type_id: 1,
                student_user_id: user_id,
                supervisor_name: lecturer_id,
                topic: data,
                approval_comment:"Approve",
                active:true,
                is_approved:true
            })
        });
        // await CafeOTP.update({status:true},{where:{username:cbo_username,otp_code:cbo_otp,}})
    return res.status(200).send({success:true})
    } catch (e) {
        console.log(e)
        res.status(500).send({
            statusCode: "500",
            success: false,
            message: "Error",
            error: e.message
        })
    }
}
exports.delete = async (req, res) => {
    const {id} = req.params
    await ProjectTopic.destroy({where:{id}});
    return res.redirect('/topic-submission');
};


