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

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

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: {
                slug: project.slug,
                title: project.title,
                description: project.description,
                objectives: project.objectives,
              },
            },
          },
        })
        .then(() => {
          this.$router.push('/portfolio');
        });
    },
  },
};
</script>
