Skip to content

Commit

Permalink
fixes: login methods UI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Chakravarthy7102 committed Mar 18, 2024
1 parent 03289c3 commit c773176
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"editor.trimAutoWhitespace": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
},
"files.exclude": {
"**/.DS_Store": true,
Expand Down
1 change: 1 addition & 0 deletions src/ui/components/copyText/CopyText.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
max-width: 100%;
.copy-text-text {
@include text-ellipsis(100%);
max-width: 180px;
flex: 1;
padding-right: 4px;
}
Expand Down
8 changes: 6 additions & 2 deletions src/ui/components/phoneNumber/PhoneNumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const PhoneNumberTextField: FC<PhoneNumberTextFieldProps> = forwardRef(
PhoneNumberTextField.displayName = "PhoneNumberTextField";

export const PhoneNumberInput: FC<PhoneNumberInputProps> = (props: PhoneNumberInputProps) => {
const { onChange, value, error, forceShowError } = props;
const { onChange, value, error, forceShowError, disabled } = props;
const [isTouched, setIsTouched] = useState(false);

// call the `onChange` and set form as touched
Expand All @@ -252,13 +252,17 @@ export const PhoneNumberInput: FC<PhoneNumberInputProps> = (props: PhoneNumberIn
);

return (
<div>
<div
style={{
pointerEvents: disabled ? "none" : "all",
}}>
<label htmlFor={props.name}>{props.label}</label>
<PhoneInputWithCountrySelect
className={`phone-input ${error !== undefined ? "phone-input-error" : ""}`}
value={value}
onChange={handleChange}
international={true}
focusInputOnCountrySelection={false}
addInternationalOption={false}
withCountryCallingCode={false}
countryCallingCodeEditable={true}
Expand Down
14 changes: 3 additions & 11 deletions src/ui/components/userDetail/loginMethods/LoginMethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ const Methods: React.FC<MethodProps> = ({
const [emailError, setEmailError] = useState("");
const { getUserEmailVerificationStatus } = useVerifyUserEmail();

const trim = (val: string) => {
const len = val.length;
return val.substring(0, Math.floor(len / 7)) + "..." + val.substring(6 * Math.floor(len / 7), len);
};

const sendUserEmailVerification = useCallback(
async (userId: string, tenantId: string | undefined) => {
const res = await getUserEmailVerificationStatus(userId);
Expand Down Expand Up @@ -245,11 +240,8 @@ const Methods: React.FC<MethodProps> = ({
<UserRecipePill {...loginMethod} />
<span className="user-id-span">
User ID:
<span className="copy-text-wrapper resp">
<CopyText copyVal={loginMethod.recipeUserId}>{trim(loginMethod.recipeUserId)}</CopyText>
</span>
<span className="copy-text-wrapper">
<CopyText>{loginMethod.recipeUserId}</CopyText>
<CopyText copyVal={loginMethod.recipeUserId}>{loginMethod.recipeUserId}</CopyText>
</span>
</span>
</div>
Expand Down Expand Up @@ -285,7 +277,7 @@ const Methods: React.FC<MethodProps> = ({
<div>
<EditableInput
label={"Email ID"}
val={loginMethod.email ?? ""}
val={send.email ?? ""}
edit={loginMethod.recipeId === "thirdparty" ? false : isEditing}
type={"email"}
error={emailError}
Expand Down Expand Up @@ -340,7 +332,7 @@ const Methods: React.FC<MethodProps> = ({
<div>
<EditableInput
label={"Phone Number"}
val={loginMethod.phoneNumber ?? ""}
val={send.phone ?? ""}
edit={isEditing}
type={"phone"}
onChange={(val) => setSend({ ...send, phone: val })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
display: flex;
justify-content: flex-start;
align-items: baseline;

@media (max-width: 340px) {
flex-direction: column;
}
}

.input-field-container {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useEffect, useState } from "react";
import InputField from "../../../inputField/InputField";
import "./editableInput.scss";
import { PhoneNumberInput } from "../../../phoneNumber/PhoneNumberInput";
import phoneNumber from "../../../phoneNumber/PhoneNumber";
import "./editableInput.scss";

export type EditableInputProps = {
label: string;
Expand All @@ -14,35 +12,29 @@ export type EditableInputProps = {
};

export const EditableInput = ({ label, val, edit, type, onChange, error }: EditableInputProps) => {
if (!edit) {
return (
<span>
{label}:<b>{val == "" ? "-" : val}</b>
</span>
);
} else {
return (
<span className="input">
{label}:&nbsp;{" "}
{type === "email" && (
<InputField
type="email"
name="email"
error={error ?? ""}
value={val}
handleChange={({ target }) => {
onChange(target.value);
}}
/>
)}
{type === "phone" && (
<PhoneNumberInput
value={val}
name="Phone Number"
onChange={onChange}
/>
)}
</span>
);
}
return (
<span className="input">
{label}:&nbsp;{" "}
{type === "email" && (
<InputField
disabled={!edit}
type="email"
name="email"
error={error ?? ""}
value={val}
handleChange={({ target }) => {
onChange(target.value);
}}
/>
)}
{type === "phone" && (
<PhoneNumberInput
disabled={!edit}
value={val}
name="Phone Number"
onChange={onChange}
/>
)}
</span>
);
};
43 changes: 24 additions & 19 deletions src/ui/components/userDetail/loginMethods/loginMethods.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
align-items: baseline;
justify-content: space-between;

.right {
display: flex;
gap: 4px;
}

.left {
display: flex;
align-items: baseline;
Expand All @@ -25,13 +30,16 @@
margin-left: 15px;
color: #6e6a65;

display: flex;
flex-wrap: wrap;
gap: 6px;

.copy-text-wrapper {
border-radius: 3px;
border: 1px solid #d9d9d9;
color: #d65078;
font-size: 13px;
padding: 5px;
margin-left: 10px;
}
}

Expand All @@ -44,12 +52,8 @@
.user-id-span {
margin-left: 0;

.copy-text-wrapper {
display: none;
}
.copy-text-wrapper.resp {
display: inline-block;
margin-left: 0;
}
}
}
Expand All @@ -62,7 +66,7 @@
grid-template-columns: 1fr 1fr;
gap: 10px;

@media screen and (max-width: 900px) {
@media screen and (max-width: 800px) {
grid-template-columns: 1fr;
}

Expand All @@ -74,10 +78,10 @@
display: flex;
align-items: center;
height: 50px;
}

@media screen and (max-width: 900px) {
height: 37px;
}
.phone-input {
width: 200px !important;
}

b {
Expand All @@ -103,6 +107,12 @@
}
}

@media (max-width: 638px) {
.left {
flex-direction: column;
}
}

@media (max-width: 480px) {
.method {
.method-header {
Expand All @@ -111,10 +121,6 @@
.method-body {
padding: 18px 8px;
}

.left {
flex-direction: column;
}
}
}

Expand Down Expand Up @@ -147,11 +153,12 @@
}

.not-verified {
border-radius: 22px;
border-radius: 16px;
border: 1px solid #d2d2d2;
background: #ececec;
font-size: 12px;
padding: 4px 10px;
font-size: 10px;
padding: 5px;

color: #252728;
text-align: center;
}
Expand All @@ -174,7 +181,6 @@

&:hover {
text-decoration: underline;
font-weight: 500;
}
}

Expand Down Expand Up @@ -208,7 +214,6 @@
}

.cancel {
margin: 0.25rem !important;
padding: 6px 12px !important;
padding: 7px 12px !important;
font-weight: 500;
}
1 change: 0 additions & 1 deletion src/ui/styles/uikit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ button.button-error-outline {
margin: 0px;
color: var(--color-button-error);
@include gap-horizontal(8px);
font-size: inherit;
box-shadow: none;
transition: background-color 0.3s;

Expand Down

0 comments on commit c773176

Please sign in to comment.