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

checks for username and username in card overflow fix #8940

4 changes: 4 additions & 0 deletions src/components/ABDM/LinkAbhaNumber/CreateWithAadhaar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -682,18 +682,22 @@ function ChooseAbhaAddress({
{validateRule(
healthId.length >= 4,
t("abha_address_validation_length_error"),
false,
)}
{validateRule(
isNaN(Number(healthId[0])) && healthId[0] !== ".",
SwanandBhuskute marked this conversation as resolved.
Show resolved Hide resolved
t("abha_address_validation_start_error"),
false,
)}
{validateRule(
healthId[healthId.length - 1] !== ".",
t("abha_address_validation_end_error"),
false,
)}
{validateRule(
/^[0-9a-zA-Z._]+$/.test(healthId),
t("abha_address_validation_character_error"),
false,
)}
</div>

Expand Down
5 changes: 5 additions & 0 deletions src/components/Auth/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,22 @@ export const ResetPassword = (props: any) => {
{validateRule(
form.password?.length >= 8,
"Password should be atleast 8 characters long",
!form.password,
)}
{validateRule(
form.password !== form.password.toUpperCase(),
"Password should contain at least 1 lowercase letter",
!form.password,
)}
{validateRule(
form.password !== form.password.toLowerCase(),
"Password should contain at least 1 uppercase letter",
!form.password,
)}
{validateRule(
/\d/.test(form.password),
"Password should contain at least 1 number",
!form.password,
)}
</div>
)}
Expand All @@ -157,6 +161,7 @@ export const ResetPassword = (props: any) => {
validateRule(
form.confirm === form.password,
"Confirm password should match the entered password",
!form.password,
)}
SwanandBhuskute marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div className="grid p-4 sm:flex sm:justify-between">
Expand Down
4 changes: 3 additions & 1 deletion src/components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ export default function ManageUsers() {
id="name"
className="mt-2 flex items-center gap-3 text-2xl font-bold capitalize"
>
{formatName(user)}
<div className="max-w-full break-words">
{formatName(user)}
</div>

{user.last_login && cur_online ? (
<div
Expand Down
22 changes: 20 additions & 2 deletions src/components/Users/UserAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,25 @@ const getDate = (value: any) =>
export const validateRule = (
condition: boolean,
content: JSX.Element | string,
isInitialState: boolean,
) => {
return (
<div>
{condition ? (
{isInitialState ? (
<CareIcon icon="l-circle" className="text-xl text-gray-500" />
) : condition ? (
<CareIcon icon="l-check-circle" className="text-xl text-green-500" />
) : (
<CareIcon icon="l-times-circle" className="text-xl text-red-500" />
)}{" "}
<span
className={classNames(condition ? "text-primary-500" : "text-red-500")}
className={classNames(
isInitialState
? "text-black"
: condition
? "text-primary-500"
: "text-red-500",
)}
>
{content}
</span>
Expand Down Expand Up @@ -786,24 +795,28 @@ export const UserAdd = (props: UserProps) => {
{validateRule(
usernameInput.length >= 4 && usernameInput.length <= 16,
"Username should be 4-16 characters long",
!state.form.username,
)}
</div>
<div>
{validateRule(
/^[a-z0-9._-]*$/.test(usernameInput),
"Username can only contain lowercase letters, numbers, and . _ -",
!state.form.username,
)}
</div>
<div>
{validateRule(
/^[a-z0-9].*[a-z0-9]$/i.test(usernameInput),
"Username must start and end with a letter or number",
!state.form.username,
)}
</div>
<div>
{validateRule(
!/(?:[._-]{2,})/.test(usernameInput),
"Username can't contain consecutive special characters . _ -",
!state.form.username,
)}
</div>
</div>
Expand Down Expand Up @@ -835,18 +848,22 @@ export const UserAdd = (props: UserProps) => {
{validateRule(
state.form.password?.length >= 8,
"Password should be atleast 8 characters long",
!state.form.password,
)}
{validateRule(
state.form.password !== state.form.password.toUpperCase(),
"Password should contain at least 1 lowercase letter",
!state.form.password,
)}
{validateRule(
state.form.password !== state.form.password.toLowerCase(),
"Password should contain at least 1 uppercase letter",
!state.form.password,
)}
{validateRule(
/\d/.test(state.form.password),
"Password should contain at least 1 number",
!state.form.password,
)}
</div>
)}
Expand All @@ -867,6 +884,7 @@ export const UserAdd = (props: UserProps) => {
validateRule(
state.form.c_password === state.form.password,
"Confirm password should match the entered password",
!state.form.password,
)}
</div>
<TextFormField
Expand Down
5 changes: 5 additions & 0 deletions src/components/Users/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -907,20 +907,24 @@ export default function UserProfile() {
{validateRule(
changePasswordForm.new_password_1?.length >= 8,
"Password should be atleast 8 characters long",
!changePasswordForm.new_password_1,
SwanandBhuskute marked this conversation as resolved.
Show resolved Hide resolved
)}
{validateRule(
changePasswordForm.new_password_1 !==
changePasswordForm.new_password_1.toUpperCase(),
"Password should contain at least 1 lowercase letter",
!changePasswordForm.new_password_1,
)}
{validateRule(
changePasswordForm.new_password_1 !==
changePasswordForm.new_password_1.toLowerCase(),
"Password should contain at least 1 uppercase letter",
!changePasswordForm.new_password_1,
)}
{validateRule(
/\d/.test(changePasswordForm.new_password_1),
"Password should contain at least 1 number",
!changePasswordForm.new_password_1,
)}
</div>
</div>
Expand All @@ -944,6 +948,7 @@ export default function UserProfile() {
changePasswordForm.new_password_1 ===
changePasswordForm.new_password_2,
"Confirm password should match the new password",
!changePasswordForm.new_password_1,
)}
</div>
)}
Expand Down