Skip to content
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

chore: ロボットタイプの自動設定 #788

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

GaTo-Rfc
Copy link

@GaTo-Rfc GaTo-Rfc commented Dec 9, 2024

close #706
category変更時、robotTypeslengthが1であれば自動で選択するように関数を追加。

Copy link

cloudflare-workers-and-pages bot commented Dec 9, 2024

Deploying kcmsx with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4e92647
Status: ✅  Deploy successful!
Preview URL: https://8a365dca.kcmsx.pages.dev
Branch Preview URL: https://chore-706-auto-select-robott.kcmsx.pages.dev

View logs

@GaTo-Rfc GaTo-Rfc enabled auto-merge (squash) December 9, 2024 08:57
@GaTo-Rfc GaTo-Rfc self-assigned this Dec 9, 2024
Comment on lines +18 to +24
// カテゴリーが変更されたとき、ロボットタイプが自明な場合は自動で設定する
useEffect(() => {
if (config.department[category].robotTypes.length === 1) {
setRobotType(config.department[category].robotTypes[0]);
}
}, [category]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • useEffectは、避けられる場合は避けるべきフックです(詳細はReactのドキュメントを参照してください)。この場合L103にこれらの処理を足せば済むので、そうしてください。
  • これだと、変えた後に2つ以上の選択肢があると何も選ばれていない状態になってしまいます。「変えたカテゴリのrobotTypesに今のrobotTypeがあるか見て、なければ許可されるもののうちの0番目をsetする」のような感じはどうでしょうか?

@laminne laminne requested a review from tufusa December 9, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

chore:参加者登録でロボットのカテゴリが自明の時に自動的に選ぶようにする
3 participants