-
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
project duration直した #288
project duration直した #288
Conversation
/help |
PR Agent Walkthrough 🤖Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more. Here is a list of tools you can use to interact with the PR Agent:
(1) Note that each tool be triggered automatically when a new PR is opened, or called manually by commenting on a PR. (2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the |
/review |
PR Reviewer Guide 🔍
|
/improve |
PR Code Suggestions ✨Latest suggestions up to b2c66f3
Previous suggestionsSuggestions up to commit b2c66f3
Suggestions
|
メモ |
:kan: |
...options.value | ||
]) | ||
const sinceOptions = computed(() => | ||
props.sinceRequired ? options.value : untilOptions.value |
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.
どういう構造になってるか分からないけどsinceがrequiredじゃないときってある?(このpropいる?の意味)
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.
確かにこれ命名よくないですね、sinceがrequiredというかuntilがoptionalかどうかのpropsです
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.
それで言うとuntilも常にoptionalかも
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.
確かにsince-required指定してないところなかったのでpropsごと消しちゃいます
// 出力。stringをオブジェクトに変換して出力 | ||
const handleInput = (value: string | undefined, dateType: DateType) => { | ||
const [year, semester] = value?.split(' ') ?? [undefined, undefined] | ||
const newValue = { | ||
year: Number(year), | ||
semester: Number(semester) as Semester | ||
} | ||
|
||
const handleInput = ( | ||
value: YearWithSemester | undefined, | ||
dateType: DateType | ||
) => { | ||
model.value = { | ||
since: dateType === 'since' ? value : model.value.since, | ||
until: dateType === 'until' ? value : model.value.until | ||
since: | ||
dateType === 'since' | ||
? value !== undefined | ||
? newValue | ||
: undefined | ||
: model.value.since, | ||
until: | ||
dateType === 'until' | ||
? value !== undefined | ||
? newValue | ||
: undefined | ||
: model.value.until | ||
} |
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.
ここDateTypeを使ってるのが分かりにくくなってそうだからstring->objectの部分だけ関数に切り出して@update:model-value=""
の中に直接書くのが読みやすそうに見えます
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.
ついでにobject->stringも関数で書くとコメントじゃなくてコードで伝わりそう
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.
なんかめっちゃ簡単にできました:kansya_kansya:
再度動作確認お願いします:pray:
/improve |
/improve |
year: Number(year), | ||
semester: Number(semester) as Semester | ||
// ラベルとして表示する文字列 | ||
const objectToString = (value: YearWithSemester | undefined) => { |
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.
流石に関数名抽象的過ぎるけどいい代替が思いつかない
encodeYearWithSemester
decodeYearWithSemester
とか
最悪yearWithSemesterToString
とかでもいいけど
if (value === undefined) { | ||
return undefined | ||
} |
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.
undefined受け取ってるのにundefinedが来たらundefined返すのちょっと違和感ある
ここは変に関数に閉じ込め過ぎずに変更前と同じように↓くらいの方が個人的に見やすいです
逆操作の方も同様
:model-value="model.since ? objectToString(model.since) : undefined"
label: `${(currentYear - i).toString()} 後期`, | ||
value: `${currentYear - i} ${Semester.second}` |
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.
toStringなくてよさそう
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.
👍🏻
煩雑になってしまったけどしょうがないかも