Skip to content

Commit 35b2c4a

Browse files
committed
make new contest page
1 parent 367ef55 commit 35b2c4a

File tree

4 files changed

+167
-19
lines changed

4 files changed

+167
-19
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script lang="ts" setup>
2+
import RequiredChip from '/@/components/UI/Required.vue'
3+
interface Props {
4+
label: string
5+
required?: boolean
6+
}
7+
defineProps<Props>()
8+
</script>
9+
10+
<template>
11+
<div>
12+
<div :class="$style.labelContainer">
13+
<label :class="$style.label">{{ label }}</label>
14+
<required-chip v-if="required" />
15+
</div>
16+
<div :class="$style.form">
17+
<slot />
18+
</div>
19+
</div>
20+
</template>
21+
22+
<style lang="scss" module>
23+
.labelContainer {
24+
display: flex;
25+
align-items: center;
26+
gap: 0.5rem;
27+
margin-bottom: 0.5rem;
28+
}
29+
.label {
30+
font-weight: bold;
31+
font-size: 20px;
32+
}
33+
.form {
34+
margin-left: 0.5rem;
35+
}
36+
</style>

src/pages/ContestCreate.vue

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/pages/ContestNew.vue

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<script lang="ts" setup>
2+
import ContentHeader from '/@/components/Layout/ContentHeader.vue'
3+
import PageContainer from '/@/components/Layout/PageContainer.vue'
4+
import BaseButton from '/@/components/UI/BaseButton.vue'
5+
import apis from '/@/lib/apis'
6+
import { RouterLink } from 'vue-router'
7+
import { reactive, ref } from 'vue'
8+
import LabeledForm from '/@/components/Form/LabeledForm.vue'
9+
import FormInput from '/@/components/UI/FormInput.vue'
10+
import FormTextArea from '/@/components/UI/FormTextArea.vue'
11+
12+
const userId = ref('c714a848-2886-4c10-a313-de9bc61cb2bb')
13+
// todo: get meが実装されたらそれを使う
14+
const formValues = reactive({
15+
name: '',
16+
link: '',
17+
description: '',
18+
duration: {
19+
since: '',
20+
until: ''
21+
}
22+
})
23+
const isSending = ref(false)
24+
const createContest = async () => {
25+
isSending.value = true
26+
try {
27+
await apis.createContest(formValues)
28+
//eslint-disable-next-line no-console
29+
console.log('追加しました') // todo:トーストとかに変えたい
30+
} catch {
31+
//eslint-disable-next-line no-console
32+
console.log('追加に失敗しました')
33+
}
34+
isSending.value = false
35+
}
36+
</script>
37+
38+
<template>
39+
<page-container>
40+
<div :class="$style.headerContainer">
41+
<content-header
42+
icon-name="mdi:trophy-outline"
43+
:header-texts="[
44+
{ title: 'Contests', url: '/contests' },
45+
{ title: 'New', url: '/contests/new' }
46+
]"
47+
detail="コンテストを作成します。"
48+
:class="$style.header"
49+
/>
50+
</div>
51+
<form>
52+
<labeled-form label="コンテスト名" required :class="$style.labeledForm">
53+
<form-input
54+
v-model="formValues.name"
55+
placeholder="コンテスト名を入力"
56+
/>
57+
</labeled-form>
58+
<labeled-form label="開催日時" required :class="$style.labeledForm">
59+
<!--dateコンポーネントができたら使う-->
60+
</labeled-form>
61+
<labeled-form label="リンク" :class="$style.labeledForm">
62+
<form-input
63+
v-model="formValues.link"
64+
placeholder="https://"
65+
has-anchor
66+
/>
67+
</labeled-form>
68+
<labeled-form label="説明" :class="$style.labeledForm">
69+
<form-text-area
70+
v-model="formValues.description"
71+
placeholder="説明を入力"
72+
:rows="3"
73+
/>
74+
</labeled-form>
75+
</form>
76+
<div :class="$style.buttonContainer">
77+
<router-link to="/contests" :class="$style.link">
78+
<base-button
79+
:class="$style.backButton"
80+
type="secondary"
81+
icon="mdi:arrow-left"
82+
>
83+
Back
84+
</base-button>
85+
</router-link>
86+
<base-button
87+
:is-disabled="isSending"
88+
:class="$style.createButton"
89+
type="primary"
90+
icon="mdi:plus"
91+
@click="createContest"
92+
>
93+
Create
94+
</base-button>
95+
</div>
96+
</page-container>
97+
</template>
98+
99+
<style lang="scss" module>
100+
.headerContainer {
101+
display: flex;
102+
justify-content: space-between;
103+
align-items: center;
104+
}
105+
.header {
106+
margin: 4rem 0 2rem;
107+
}
108+
.labeledForm {
109+
margin-bottom: 2rem;
110+
}
111+
.prPermittedForm {
112+
display: flex;
113+
align-items: center;
114+
gap: 0.5rem;
115+
}
116+
.link {
117+
text-decoration: none;
118+
color: inherit;
119+
}
120+
.buttonContainer {
121+
display: flex;
122+
justify-content: space-between;
123+
align-items: center;
124+
margin-top: 4rem;
125+
}
126+
</style>
127+
'

src/router/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Events = () => import('/@/pages/Events.vue')
99
const Event = () => import('/@/pages/Event.vue')
1010
const Contests = () => import('/@/pages/Contests.vue')
1111
const Contest = () => import('/@/pages/Contest.vue')
12-
const ContestCreate = () => import('/@/pages/ContestCreate.vue')
12+
const ContestNew = () => import('/@/pages/ContestNew.vue')
1313

1414
const routes = [
1515
{
@@ -48,9 +48,9 @@ const routes = [
4848
component: Contest
4949
},
5050
{
51-
path: '/contests/create',
52-
name: 'ContestCreate',
53-
component: ContestCreate
51+
path: '/contests/new',
52+
name: 'ContestNew',
53+
component: ContestNew
5454
},
5555
{
5656
path: '/users',

0 commit comments

Comments
 (0)