|
| 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 | +' |
0 commit comments