Skip to content

Commit

Permalink
SDP-981: Default Organization name from hostname prefix when possible (
Browse files Browse the repository at this point in the history
  • Loading branch information
ceciliaromao authored Dec 13, 2023
1 parent a9e6d9b commit 30b52b2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const LOCAL_STORAGE_SESSION_TOKEN = "sdp_session";
export const LOCAL_STORAGE_DEVICE_ID = "sdp_deviceID";
export const UI_STATUS_DISBURSEMENT = "STARTED,PAUSED,COMPLETED";
export const UI_STATUS_DISBURSEMENT_DRAFT = "DRAFT,READY";
export const ORG_NAME_INFO_TEXT =
"You can find your organization name in the invitation email";

export enum Routes {
MFA = "/mfa",
Expand Down
12 changes: 9 additions & 3 deletions src/pages/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
import { useNavigate } from "react-router-dom";

import { useForgotPasswordLink } from "apiQueries/useForgotPasswordLink";
import { RECAPTCHA_SITE_KEY } from "constants/settings";
import { RECAPTCHA_SITE_KEY, ORG_NAME_INFO_TEXT } from "constants/settings";
import { InfoTooltip } from "components/InfoTooltip";
import { getSdpTenantName } from "helpers/getSdpTenantName";

export const ForgotPassword = () => {
const {
Expand All @@ -25,7 +27,7 @@ export const ForgotPassword = () => {
const navigate = useNavigate();
const recaptchaRef = useRef<Recaptcha>(null);

const [organizationName, setOrganizationName] = useState("");
const [organizationName, setOrganizationName] = useState(getSdpTenantName());
const [email, setEmail] = useState("");
const [recaptchaToken, setRecaptchaToken] = useState("");

Expand Down Expand Up @@ -84,7 +86,11 @@ export const ForgotPassword = () => {
fieldSize="sm"
id="fp-organization-name"
name="fp-organization-name"
label="Organization name"
label={
<InfoTooltip infoText={ORG_NAME_INFO_TEXT}>
Organization name
</InfoTooltip>
}
onChange={(e) => setOrganizationName(e.target.value)}
value={organizationName}
type="text"
Expand Down
10 changes: 8 additions & 2 deletions src/pages/MFAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import {
USE_SSO,
RECAPTCHA_SITE_KEY,
LOCAL_STORAGE_DEVICE_ID,
ORG_NAME_INFO_TEXT,
} from "constants/settings";
import { useRedux } from "hooks/useRedux";
import { mfaAction, signInAction } from "store/ducks/userAccount";
import { getSdpTenantName } from "helpers/getSdpTenantName";
import { InfoTooltip } from "components/InfoTooltip";

export const MFAuth = () => {
const dispatch: AppDispatch = useDispatch();
Expand All @@ -30,7 +32,7 @@ export const MFAuth = () => {
const recaptchaRef = useRef<Recaptcha>(null);

const { userAccount } = useRedux("userAccount");
const [organizationName, setOrganizationName] = useState("");
const [organizationName, setOrganizationName] = useState(getSdpTenantName());
const [recaptchaToken, setRecaptchaToken] = useState("");
const [mfaCode, setMfaCode] = useState("");
const [rememberMe, setRememberMe] = useState(false);
Expand Down Expand Up @@ -132,7 +134,11 @@ export const MFAuth = () => {
fieldSize="sm"
id="2fa-organization-name"
name="2fa-organization-name"
label="Organization name"
label={
<InfoTooltip infoText={ORG_NAME_INFO_TEXT}>
Organization name
</InfoTooltip>
}
onChange={(e) => setOrganizationName(e.target.value)}
value={organizationName}
type="text"
Expand Down
11 changes: 9 additions & 2 deletions src/pages/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import {
} from "@stellar/design-system";
import { useNavigate } from "react-router-dom";

import { ORG_NAME_INFO_TEXT } from "constants/settings";
import { useResetPassword } from "apiQueries/useResetPassword";
import { validateNewPassword } from "helpers/validateNewPassword";
import { validatePasswordMatch } from "helpers/validatePasswordMatch";
import { getSdpTenantName } from "helpers/getSdpTenantName";
import { InfoTooltip } from "components/InfoTooltip";

export const ResetPassword = () => {
const { isSuccess, isLoading, error, mutateAsync, reset } =
useResetPassword();

const navigate = useNavigate();

const [organizationName, setOrganizationName] = useState("");
const [organizationName, setOrganizationName] = useState(getSdpTenantName());
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [confirmationToken, setConfirmationToken] = useState("");
Expand Down Expand Up @@ -114,7 +117,11 @@ export const ResetPassword = () => {
fieldSize="sm"
id="rp-organization-name"
name="rp-organization-name"
label="Organization name"
label={
<InfoTooltip infoText={ORG_NAME_INFO_TEXT}>
Organization name
</InfoTooltip>
}
onChange={(e) => setOrganizationName(e.target.value)}
value={organizationName}
type="text"
Expand Down
11 changes: 9 additions & 2 deletions src/pages/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import {
USE_SSO,
RECAPTCHA_SITE_KEY,
LOCAL_STORAGE_DEVICE_ID,
ORG_NAME_INFO_TEXT,
} from "constants/settings";
import { useRedux } from "hooks/useRedux";
import { signInRedirect } from "helpers/singleSingOn";
import { getSdpTenantName } from "helpers/getSdpTenantName";
import { InfoTooltip } from "components/InfoTooltip";

export const SignIn = () => {
const dispatch: AppDispatch = useDispatch();
Expand All @@ -30,7 +32,7 @@ export const SignIn = () => {
const recaptchaRef = useRef<Recaptcha>(null);

const { userAccount } = useRedux("userAccount");
const [organizationName, setOrganizationName] = useState("");
const [organizationName, setOrganizationName] = useState(getSdpTenantName());
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [recaptchaToken, setRecaptchaToken] = useState("");
Expand Down Expand Up @@ -135,8 +137,13 @@ export const SignIn = () => {
fieldSize="sm"
id="si-organization-name"
name="si-organization-name"
label="Organization name"
label={
<InfoTooltip infoText={ORG_NAME_INFO_TEXT}>
Organization name
</InfoTooltip>
}
onChange={(e) => setOrganizationName(e.target.value)}
value={organizationName}
type="text"
/>
<Input
Expand Down

0 comments on commit 30b52b2

Please sign in to comment.