{"size": 1647, "ext": "js", "max_stars_repo_path": "app/Controllers/Http/ToDoController.js", "max_stars_repo_name": "george-ij/the-manager", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/Controllers/Http/ToDoController.js", "max_issues_repo_name": "george-ij/the-manager", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/Controllers/Http/ToDoController.js", "max_forks_repo_name": "george-ij/the-manager", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.564516129, "max_line_length": 80, "alphanum_fraction": 0.6435944141}
'use strict'
const User = use('App/Models/User')
const Todo = use('App/Models/Todo')

class ToDoController {
  async createTodoForm({ view, auth }) {
    console.log(`Auth ID`, auth.user.id)

    return view.render('user/todo/create_todo', {
        profileID: auth.user.id
    })
}

async createTodo({ request, view, auth }) {
    const newTodo = new Todo()

    const title = request.input('title')
    const details = request.input('details')

    newTodo.user_id = auth.user.id
    newTodo.task_id = null
    newTodo.status_id = 3
    newTodo.title = title
    newTodo.details = details

    await newTodo.save()

    // const reportWriter = await User.find(newTodo.reportWriter)

    return view.render('user/todo/single', {
        todo: newTodo.toJSON()
    })
  }

  async singleView({ params, view }) {
    const project = await Project.find(params.id)
    await project.loadMany(['tasks', 'taskAssignedTo'])
    // const user = await User.all()

    console.log(`project and it's tasks =====>>>>`, project.toJSON())

    // const checkTeamMember = await TeamMember.query()
    // .where('project_id', project.id)
    // .fetch()

    // console.log(`Team: ${checkTeamMember}`)
    // const profile = await User.findBy('id', checkTeamMember.user_id)

    // console.log(`All team members: ${profile.toJSON()}`)
    // // console.log(`Found Members: ${profile.firstName} ${profile.lastName}`)

    return view.render('project/single', {
      project: project.toJSON(),
      // user: user.toJSON()
      // team_member: profile,
      // team_member_role: checkTeamMember.memberPermission_id
    })
  }
}

module.exports = ToDoController
