Skip to content

Commit

Permalink
Merge pull request #1567 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
devserver
  • Loading branch information
viraka authored Jun 14, 2024
2 parents d2b610a + bdb5242 commit 14fd7b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/modules/Dashboard/modules/ManageUsers/UserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,15 @@ const UserForm = forwardRef(
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;

setData(prevData => ({ ...prevData, [name]: value }));
if (name === "mobile" && value && !/^\+?\d{0,12}$/.test(value.trim())) {
setErrors(prevErrors => ({
...prevErrors,
mobile: "Invalid format"
}));
} else {
setErrors(prevErrors => ({ ...prevErrors, mobile: undefined }));
setData(prevData => ({ ...prevData, [name]: value.trim() || " " }));
}
};

const handleYearChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -373,7 +381,7 @@ const UserForm = forwardRef(
</div>
<div className={styles.inputContainer}>
<input
type="text"
type="tel"
name="mobile"
placeholder="Mobile"
value={data.mobile}
Expand Down
1 change: 1 addition & 0 deletions src/modules/Dashboard/modules/Wadhwani/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@
color: white;
padding: 0.5rem 1rem;
border-radius: 5px;
cursor: pointer;
}
17 changes: 13 additions & 4 deletions src/modules/Dashboard/modules/Wadhwani/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,17 @@ function getRootIdByTitle(titleToSearch: string): string {
console.log(course?.courseName + titleToSearch)
return course ? course.courseRootId : "null";
}

function stringSlice(inputString: string): string {
return inputString.substring(3, 200);
function stringSlice(inputString: string): string {
const secondPeriodIndex = inputString.indexOf(
".",
inputString.indexOf(".") + 1
);
if (secondPeriodIndex !== -1) {
return inputString.substring(0, secondPeriodIndex + 1).trim();
}
return inputString.substring(0, 200);
}

const CourseCard: React.FC<CourseCardProps> = ({ title, desc, duration, rootId }) => {
return (
<div className={styles.containercard}>
Expand All @@ -108,7 +115,9 @@ function getRootIdByTitle(titleToSearch: string): string {
</div>
);
};

if (isLoading) {
return <MuLoader />;
}
return (
<div className={styles.wrapper}>
<h1>Wadhwani Foundation Courses</h1>
Expand Down

0 comments on commit 14fd7b3

Please sign in to comment.