-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ユーザーセッティング画面実装 #80
base: main
Are you sure you want to change the base?
ユーザーセッティング画面実装 #80
Changes from all commits
317d19b
c7a2ea8
e588edb
8102cb3
e548c42
a0cf8ad
cd83243
d84aa85
b7da2ce
fb8a282
fd3c32e
376d954
4b0a17e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
<template> | ||
<div> | ||
<h1>Settings</h1> | ||
<RouterView /> | ||
</div> | ||
</template> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,162 @@ | ||
<script setup lang="ts"></script> | ||
<script setup lang="ts"> | ||
import { ref, onMounted } from 'vue'; | ||
import axios from 'axios'; | ||
import SideMenuUserSetting from '@/components/Navigations/SideMenu/SideMenuUserSetting.vue'; | ||
import PrimaryButton from '@/components/Controls/PrimaryButton.vue'; | ||
import PlainTextbox from '@/components/Controls/Textbox/PlainTextbox.vue'; | ||
import PasswordTextbox from '@/components/Controls/Textbox/PasswordTextbox.vue'; | ||
import EmailTextbox from '@/components/Controls/Textbox/EmailTextbox.vue'; | ||
|
||
import GitHubIcon from '@/assets/service_icons/github.svg'; | ||
import GoogleIcon from '@/assets/service_icons/google.svg'; | ||
import traQIcon from '@/assets/service_icons/traq.svg'; | ||
|
||
import checkIcon from '@/assets/status_icons/check.svg'; | ||
|
||
const username = ref<string>(''); | ||
const email = ref<string>(''); | ||
const currentPassword = ref<string>(''); | ||
const newPassword = ref<string>(''); | ||
const confirmPassword = ref<string>(''); | ||
|
||
interface Service { | ||
name: string; | ||
linked: boolean; | ||
ID: string; | ||
icon: string; | ||
} | ||
|
||
const services = ref<Service[]>([ | ||
{ name: 'GitHub', linked: false, ID: '', icon: GitHubIcon }, | ||
{ name: 'Google', linked: false, ID: '', icon: GoogleIcon }, | ||
{ name: 'traQ', linked: false, ID: '', icon: traQIcon }, | ||
]); | ||
|
||
function toggleLink(service: Service) { | ||
console.log(`TODO: ${service.name} との連携を${service.linked ? '解除' : '開始'}する`); | ||
} | ||
|
||
function changeUsername() { | ||
console.log('TODO: ユーザー名の変更を反映する'); | ||
} | ||
|
||
function changeEmail() { | ||
console.log('TODO: メールアドレスの変更を反映する'); | ||
} | ||
|
||
function changePassword() { | ||
console.log('TODO: パスワードの変更を反映する'); | ||
} | ||
|
||
async function fetchUserData() { | ||
try { | ||
const response = await axios.get('/api/users/me'); | ||
console.log(response); | ||
const user = response.data; | ||
services.value = services.value.map(service => { | ||
switch (service.name) { | ||
case 'GitHub': | ||
console.log(user.githubId); | ||
service.linked = user.githubId !== null; | ||
service.ID = user.githubId; | ||
break; | ||
case 'traQ': | ||
console.log(user.traqId); | ||
service.linked = user.traqId !== null; | ||
service.ID = user.traqId; | ||
break; | ||
case 'Google': | ||
console.log('TODO: Google との連携状況を取得する'); | ||
break; | ||
default: | ||
break; | ||
} | ||
return service; | ||
}); | ||
} catch (error) { | ||
console.error('Error fetching user data:', error); | ||
} | ||
} | ||
|
||
onMounted(() => { | ||
fetchUserData(); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<h2>Settings Account</h2> | ||
<div class="flex gap-12 px-6 py-8" style="font-family: 'Open Sans', 'Noto Sans', sans-serif;"> | ||
<SideMenuUserSetting /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この部分のフォントスタイルはtailwind.config.jsに定義してあるので,そちらのカスタムクラスを利用するようにしてください! |
||
<div class="flex flex-col gap-6 p-3" style="width: 800px;"> | ||
<div class="flex flex-col gap-3 pb-3"> | ||
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">基本情報</h2> | ||
<div class="flex-col"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この部分のカラーコードはtailwind.config.jsに定義してあるので,そちらのカスタムクラスを利用するようにしてください!(他のカラーコードが直書きされている部分も同様に修正をお願いします。) |
||
<label class="text-sm font-medium" for="username">ユーザー名</label> | ||
<div class="flex items-center gap-2"> | ||
<PlainTextbox v-model="username" /> | ||
<PrimaryButton text="変更" @click="changeUsername" /> | ||
</div> | ||
</div> | ||
<div class="flex-col"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この辺りはネストを一つ落とせそうです。例えば下のように
他の類似部分もネストを減らしてもらえると良いと思います! |
||
<label class="text-sm font-medium" for="email">メールアドレス</label> | ||
<div class="flex items-center gap-2"> | ||
<EmailTextbox v-model="email" /> | ||
<PrimaryButton text="変更" @click="changeEmail" /> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="flex flex-col gap-3 pb-3"> | ||
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">パスワードの変更</h2> | ||
<form class="flex flex-col gap-2" @submit.prevent="changePassword"> | ||
<input v-model="username" type="text" autocomplete="username" hidden /> | ||
<div class="flex-col"> | ||
<label class="text-sm font-medium" for="current-password">現在のパスワード</label> | ||
<div class="flex items-center "> | ||
<PasswordTextbox v-model="currentPassword" autocomplete="current-password" /> | ||
</div> | ||
</div> | ||
<div class="flex-col"> | ||
Comment on lines
+111
to
+116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この部分も前述のようにネストが減らせそうなので,例えば以下のようにしてネストを減らしてもらえると助かります
他の類似部分も同様に修正をお願いいたします |
||
<label class="text-sm font-medium" for="new-password">新しいパスワード</label> | ||
<div class="flex items-center "> | ||
<PasswordTextbox v-model="newPassword" autocomplete="new-password" /> | ||
</div> | ||
</div> | ||
<div class="flex-col"> | ||
<label class="text-sm font-medium" for="confirm-password">新しいパスワード (確認)</label> | ||
<div class="flex items-center "> | ||
<PasswordTextbox v-model="confirmPassword" autocomplete="new-password" /> | ||
</div> | ||
</div> | ||
<div> | ||
<PrimaryButton text="変更" type="submit" /> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="flex flex-col gap-3 pb-3"> | ||
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">外部サービスとの連携</h2> | ||
<div> | ||
<div v-for="service in services" :key="service.name" class="flex-col border-b-2" style="border-color: #D8D8D8B2;"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. このdivはなくても支障がなさそうですので,削ってネストを浅くしてください |
||
<div class="flex h-12 items-center gap-2.5"> | ||
<div class="flex items-center gap-2"> | ||
<img :src="service.icon" alt="" width="20" height="20" /> | ||
<label class="w-32"> | ||
{{ service.name }} | ||
</label> | ||
</div> | ||
<span :style="[service.linked ? 'color: #16B179;' : 'color: #5F5F5F;']" class="flex w-32 gap-1"> | ||
{{ service.linked ? '連携済' : '未連携' }} | ||
<img v-if="service.linked" :src="checkIcon" alt="" width="16" height="16" /> | ||
</span> | ||
<span class="h-12 min-w-72 content-around text-base font-normal" style="color: #5F5F5F;"> | ||
{{ service.ID }} | ||
</span> | ||
<button class="mr-10 h-8 rounded border px-4 py-1 text-sm" style="border-color: #D8D8D8; color: #5F5F5F;" @click="toggleLink(service)"> | ||
{{ service.linked ? '連携解除' : '連携' }} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この辺り自前実装してくださってありがとうございます!ただ,APIの関数は基本的に
@/api/generated/apis/
以下に定義してある自動生成の関数がありますので,こちらを利用する形でお願いいたします:pray:API定義周りで若干の変更が入っているので,mainの変更をマージしてもらってから作業してもらえると良いと思います。
合わせて,コメントの方でいただいていた質問に回答しておきます。
これは
@/api/generated/models
で定義されています。(このコードであれば明示的にUser型を宣言せずともgetMeを呼び出すだけで事足りるとは思います。)本番用のリンクはまだ確定していないです:gomen:前述した通り,自動生成の関数を利用すれば自動的にベースが設定されますので,このコードを書く上では気にしなくても問題ないです。