<template>
  <project-form
    :project="project"
    @save="updateProject"
  />
</template>

<script>
  import ProjectForm from '@/components/portfolio/ProjectForm';

  import UPDATE_PROJECT_MUTATION from '@/graphql/gql/mutations/updateProject.gql';

  export default {
    props: ['project'],

    components: {
      ProjectForm
    },

    methods: {
      updateProject(project) {
        this.$apollo.mutate({
          mutation: UPDATE_PROJECT_MUTATION,
          variables: {
            input: {
              project: {
                id: project.id,
                title: project.title,
                description: project.description,
                objectives: project.objectives
              }
            }
          }
        }).then(() => {
          this.$router.push('/portfolio');
        });
      }
    },
  };
</script>
