Merge pull request 'Renamed variable "check" to "description" in "CreateActivity" and "UpdateActivity" components' (#36) from Ashutosh_Bug#94_Rename_CheckList_Variable into Issues_April_4W

Reviewed-on: #36
This commit is contained in:
Vikas Nale 2025-04-20 06:44:08 +00:00
commit c3faca41e2
2 changed files with 18 additions and 18 deletions

View File

@ -14,7 +14,7 @@ const schema = z.object({
checkList: z checkList: z
.array( .array(
z.object({ z.object({
check: z.string().min(1, { message: "Checklist item cannot be empty" }), description: z.string().min(1, { message: "descriptionlist item cannot be empty" }),
isMandatory: z.boolean().default(false), isMandatory: z.boolean().default(false),
id: z.any().default(0), id: z.any().default(0),
}) })
@ -82,18 +82,18 @@ const CreateActivity = ({ onClose }) => {
const lastIndex = checkListItems.length - 1; const lastIndex = checkListItems.length - 1;
if ( if (
checkListItems.length > 0 && checkListItems.length > 0 &&
(!values?.[lastIndex] || values[lastIndex].check.trim() === "") (!values?.[lastIndex] || values[lastIndex].description.trim() === "")
) { ) {
setError(`checkList.${lastIndex}.check`, { setError(`checkList.${lastIndex}.description`, {
type: "manual", type: "manual",
message: "Please fill this checklist item before adding another.", message: "Please fill this checklist item before adding another.",
}); });
return; return;
} }
clearErrors(`checkList.${lastIndex}.check`); clearErrors(`checkList.${lastIndex}.description`);
append({ append({
id: 0, id: 0,
check: "", description: "",
isMandatory: false, isMandatory: false,
}); });
}; };
@ -167,19 +167,19 @@ const CreateActivity = ({ onClose }) => {
{...register(`checkList.${index}.id`)} {...register(`checkList.${index}.id`)}
></input> ></input>
<input <input
{...register(`checkList.${index}.check`)} {...register(`checkList.${index}.description`)}
className="form-control form-control-sm" className="form-control form-control-sm"
placeholder={`Checklist item ${index + 1}`} placeholder={`Checklist item ${index + 1}`}
onChange={(e) => onChange={(e) =>
handleChecklistChange(index, e.target.value) handleChecklistChange(index, e.target.value)
} }
/> />
{errors.checkList?.[index]?.check && ( {errors.checkList?.[index]?.description && (
<small <small
style={{ fontSize: "10px" }} style={{ fontSize: "10px" }}
className="danger-text" className="danger-text"
> >
{errors.checkList[index]?.check?.message} {errors.checkList[index]?.description?.message}
</small> </small>
)} )}
</td> </td>

View File

@ -14,7 +14,7 @@ const schema = z.object({
.array( .array(
z.object({ z.object({
id: z.any().default(0), id: z.any().default(0),
check: z.string().min(1, { message: "Checklist item cannot be empty" }), description: z.string().min(1, { message: "Checklist item cannot be empty" }),
isMandatory: z.boolean().default(false), isMandatory: z.boolean().default(false),
}) })
) )
@ -106,17 +106,17 @@ const UpdateActivity = ({ activityData, onClose }) => {
if ( if (
checkListItems.length > 0 && checkListItems.length > 0 &&
(!values?.[lastIndex] || values[lastIndex].check.trim() === "") (!values?.[lastIndex] || values[lastIndex].description.trim() === "")
) { ) {
setError(`checkList.${lastIndex}.check`, { setError(`checkList.${lastIndex}.description`, {
type: "manual", type: "manual",
message: "Please fill this checklist item before adding another.", message: "Please fill this checklist item before adding another.",
}); });
return; return;
} }
clearErrors(`checkList.${lastIndex}.check`); clearErrors(`checkList.${lastIndex}.description`);
append({ id: 0, check: "", isMandatory: false }); append({ id: 0, description: "", isMandatory: false });
}; };
const removeChecklistItem = (index) => { const removeChecklistItem = (index) => {
@ -178,19 +178,19 @@ const UpdateActivity = ({ activityData, onClose }) => {
{...register(`checkList.${index}.id`)} {...register(`checkList.${index}.id`)}
></input> ></input>
<input <input
{...register(`checkList.${index}.check`)} {...register(`checkList.${index}.description`)}
className="form-control form-control-sm" className="form-control form-control-sm"
placeholder={`Checklist item ${index + 1}`} placeholder={`Checklist item ${index + 1}`}
onChange={(e) => onChange={(e) =>
handleChecklistChange(index, e.target.value) handleChecklistChange(index, e.target.value)
} }
/> />
{errors.checkList?.[index]?.check && ( {errors.checkList?.[index]?.description && (
<small <small
style={{ fontSize: "10px" }} style={{ fontSize: "10px" }}
className="danger-text" className="danger-text"
> >
{errors.checkList[index]?.check?.message} {errors.checkList[index]?.description?.message}
</small> </small>
)} )}
</td> </td>
@ -208,7 +208,7 @@ const UpdateActivity = ({ activityData, onClose }) => {
onClick={() => removeChecklistItem(index)} onClick={() => removeChecklistItem(index)}
className="btn btn-xs btn-icon btn-text-secondary" className="btn btn-xs btn-icon btn-text-secondary"
> >
<i class="bx bxs-minus-circle text-danger"></i> <i className="bx bxs-minus-circle text-danger"></i>
</button> </button>
</td> </td>
</tr> </tr>
@ -223,7 +223,7 @@ const UpdateActivity = ({ activityData, onClose }) => {
className="btn btn-xs btn-primary mt-2" className="btn btn-xs btn-primary mt-2"
onClick={addChecklistItem} onClick={addChecklistItem}
> >
<i class="bx bx-plus-circle"></i> <i className="bx bx-plus-circle"></i>
</button> </button>
</div> </div>