Skip to content

Commit

Permalink
projectの作成ページの作成
Browse files Browse the repository at this point in the history
  • Loading branch information
mehm8128 committed Aug 17, 2023
1 parent b18cf56 commit 23cb1cc
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
135 changes: 135 additions & 0 deletions src/pages/ProjectNew.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<script lang="ts" setup>
import ContentHeader from '/@/components/Layout/ContentHeader.vue'
import PageContainer from '/@/components/Layout/PageContainer.vue'
import BaseButton from '/@/components/UI/BaseButton.vue'
import apis from '/@/lib/apis'
import { RouterLink } from 'vue-router'
import { reactive, ref } from 'vue'
import LabeledForm from '/@/components/Form/LabeledForm.vue'
import FormInput from '/@/components/UI/FormInput.vue'
import FormTextArea from '/@/components/UI/FormTextArea.vue'
import FormDuration from '/@/components/UI/FormDuration.vue'
const userId = ref('c714a848-2886-4c10-a313-de9bc61cb2bb')
// todo: get meが実装されたらそれを使う
const formValues = reactive({
name: '',
link: '',
description: '',
duration: {
since: {
year: 0,
semester: 0
},
until: {
year: 0,
semester: 0
}
}
})
const isSending = ref(false)
const createProject = async () => {
isSending.value = true
try {
await apis.createProject(formValues)
//eslint-disable-next-line no-console
console.log('追加しました') // todo:トーストとかに変えたい
} catch {
//eslint-disable-next-line no-console
console.log('追加に失敗しました')
}
isSending.value = false
}
</script>

<template>
<page-container>
<div :class="$style.headerContainer">
<content-header
icon-name="mdi:clipboard-file-outline"
:header-texts="[
{ title: 'Projects', url: '/projects' },
{ title: 'New', url: '/projects/new' }
]"
detail="プロジェクトを作成します。"
:class="$style.header"
/>
</div>
<form>
<labeled-form label="プロジェクト名" required :class="$style.labeledForm">
<form-input
v-model="formValues.name"
placeholder="プロジェクト名を入力"
/>
</labeled-form>
<labeled-form label="期間" :class="$style.labeledForm">
<!--コンポーネントができたら使う-->
</labeled-form>
<labeled-form label="リンク" :class="$style.labeledForm">
<form-input
v-model="formValues.link"
placeholder="https://"
has-anchor
/>
</labeled-form>
<labeled-form label="説明" :class="$style.labeledForm">
<form-text-area
v-model="formValues.description"
placeholder="説明を入力"
:rows="3"
:limit="256"
/>
</labeled-form>
</form>
<div :class="$style.buttonContainer">
<router-link to="/projects" :class="$style.link">
<base-button
:class="$style.backButton"
type="secondary"
icon="mdi:arrow-left"
>
Back
</base-button>
</router-link>
<base-button
:is-disabled="isSending"
:class="$style.createButton"
type="primary"
icon="mdi:plus"
@click="createProject"
>
Create
</base-button>
</div>
</page-container>
</template>

<style lang="scss" module>
.headerContainer {
display: flex;
justify-content: space-between;
align-items: center;
}
.header {
margin: 4rem 0 2rem;
}
.labeledForm {
margin-bottom: 2rem;
}
.prPermittedForm {
display: flex;
align-items: center;
gap: 0.5rem;
}
.link {
text-decoration: none;
color: inherit;
}
.buttonContainer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 4rem;
}
</style>
'
6 changes: 6 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const UserAccounts = () => import('/@/pages/UserAccounts.vue')
const UserAccountNew = () => import('/@/pages/UserAccountNew.vue')
const Projects = () => import('/@/pages/Projects.vue')
const Project = () => import('/@/pages/Project.vue')
const ProjectNew = () => import('/@/pages/ProjectNew.vue')
const Events = () => import('/@/pages/Events.vue')
const Event = () => import('/@/pages/Event.vue')
const Contests = () => import('/@/pages/Contests.vue')
Expand All @@ -30,6 +31,11 @@ const routes = [
name: 'Project',
component: Project
},
{
path: '/projects/new',
name: 'ProjectNew',
component: ProjectNew
},
{
path: '/events',
name: 'Events',
Expand Down

0 comments on commit 23cb1cc

Please sign in to comment.