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

improve: allow creating teams first then time #291

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
"disNameReq": "Display name is required.",
"endReq": "End time is required",
"startReq": "Start time is required",
"teamReq": "Please Select Team(s).",
"teamNeed": "Needed Teams",
"timeAdd": "Add a Time",
"timeEdit": "Edit Time",
Expand Down
6 changes: 4 additions & 2 deletions src/plans/components/TimeEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Checkbox, SelectChangeEvent, TextField } from "@mui/material";
import { Checkbox, SelectChangeEvent, TextField, Typography } from "@mui/material";
import { ApiHelper, DateHelper, ErrorMessages, InputBox, Locale, TimeInterface } from "@churchapps/apphelper";

interface Props { time: TimeInterface, categories:string[], onUpdate: () => void }
Expand All @@ -26,6 +26,7 @@ export const TimeEdit = (props:Props) => {
if (!time.displayName) errors.push(Locale.label("plans.timeEdit.disNameReq"));
if (!time.startTime) errors.push(Locale.label("plans.timeEdit.startReq"));
if (!time.endTime) errors.push(Locale.label("plans.timeEdit.endReq"));
if (!time.teams || time.teams === "") errors.push(Locale.label("plans.timeEdit.teamReq"));
setErrors(errors);
if (errors.length === 0) ApiHelper.post("/times", [time], "DoingApi").then(props.onUpdate);
}
Expand Down Expand Up @@ -53,6 +54,7 @@ export const TimeEdit = (props:Props) => {
result.push(<div><Checkbox key={c} name="team" checked={checked} onChange={handleTeamCheck} value={c} /><label>{c}</label></div>);
});

if (result.length === 0) { return <Typography sx={{ fontSize: "13px", fontStyle: "italic" }}>Tip: Start with creating teams first. <a href="https://support.churchapps.org/chums/plans.html" target="_blank" rel="noopener noreferrer">Follow this guide</a></Typography> }
return result;
}

Expand All @@ -61,7 +63,7 @@ export const TimeEdit = (props:Props) => {

return (<>
<ErrorMessages errors={errors} />
<InputBox headerText={(props.time?.id) ? Locale.label("plans.timeEdit.timeEdit") : Locale.label("plans.timeEdit.timeAdd")} headerIcon="assignment" saveFunction={handleSave} cancelFunction={props.onUpdate} deleteFunction={(time.id) ? handleDelete : null }>
<InputBox headerText={(props.time?.id) ? Locale.label("plans.timeEdit.timeEdit") : Locale.label("plans.timeEdit.timeAdd")} headerIcon="assignment" saveFunction={handleSave} cancelFunction={props.onUpdate} deleteFunction={(time.id) ? handleDelete : null } isSubmitting={props.categories.length === 0}>
<TextField fullWidth label={Locale.label("plans.timeEdit.disName")} id="displayName" name="displayName" type="text" value={time.displayName} onChange={handleChange} />
<TextField fullWidth label={Locale.label("plans.timeEdit.timeStart")} id="startTime" name="startTime" type="datetime-local" value={DateHelper.formatHtml5DateTime(time.startTime)} onChange={handleChange} />
<TextField fullWidth label={Locale.label("plans.timeEdit.timeEnd")} id="endTime" name="endTime" type="datetime-local" value={DateHelper.formatHtml5DateTime(time.endTime)} onChange={handleChange} />
Expand Down
Loading