Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: ws schedule top-down restriction#2008

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
greyscaled merged 1 commit intomainfromvapurrmaid/gh-1958
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,6 +57,22 @@ describe("validationSchema", () => {
expect(validate).toThrowError(Language.errorNoDayOfWeek)
})

it("disallows empty startTime when at least one day is set", () => {
const values: WorkspaceScheduleFormValues = {
...valid,
sunday: false,
monday: true,
tuesday: false,
wednesday: false,
thursday: false,
friday: false,
saturday: false,
startTime: "",
}
const validate = () => validationSchema.validateSync(values)
expect(validate).toThrowError(Language.errorNoTime)
})

it("allows startTime 16:20", () => {
const values: WorkspaceScheduleFormValues = {
...valid,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,7 @@ dayjs.extend(timezone)

export const Language = {
errorNoDayOfWeek: "Must set at least one day of week",
errorNoTime: "Start time is required",
errorTime: "Time must be in HH:mm format (24 hours)",
errorTimezone: "Invalid timezone",
daysOfWeekLabel: "Days of Week",
Expand DownExpand Up@@ -93,6 +94,25 @@ export const validationSchema = Yup.object({

startTime: Yup.string()
.ensure()
.test("required-if-day-selected", Language.errorNoTime, function (value) {
const parent = this.parent as WorkspaceScheduleFormValues

const isDaySelected = [
parent.sunday,
parent.monday,
parent.tuesday,
parent.wednesday,
parent.thursday,
parent.friday,
parent.saturday,
].some((day) => day)

if (isDaySelected) {
return value !== ""
} else {
return true
}
})
.test("is-time-string", Language.errorTime, (value) => {
if (value === "") {
return true
Expand DownExpand Up@@ -192,7 +212,7 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
</Link>
</>,
)}
disabled={isLoading || !form.values.startTime}
disabled={isLoading}
InputLabelProps={{
shrink: true,
}}
Expand All@@ -210,7 +230,7 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
control={
<Checkbox
checked={checkbox.value}
disabled={!form.values.startTime ||isLoading}
disabled={isLoading}
onChange={form.handleChange}
name={checkbox.name}
color="primary"
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp