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

Sc-13623 : make domain input editable #339

Merged
merged 6 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/beacon-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@radix-ui/react-dropdown-menu": "^2.0.2",
"@radix-ui/react-tooltip": "^1.0.5",
"@reduxjs/toolkit": "^1.9.2",
"@rotational/beacon-core": "^2.1.2",
"@rotational/beacon-core": "^2.1.3",
"@rotational/beacon-foundation": "^2.0.1",
"@sentry/react": "^7.37.1",
"@sentry/tracing": "^7.33.0",
Expand Down
33 changes: 26 additions & 7 deletions web/beacon-app/src/components/ui/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,37 @@ function Button(props: ButtonProps) {
const StyledButton = styled(AriaButton)((props) => ({
fontSize: '0.875rem',
lineHeight: '1.25rem',
'&:focus': {
outline: 'none',
},
...(props.isDisabled && {
background: 'rgb(233 236 239)',
color: 'rgb(206 212 218)',
}),
'&:hover': {
...(!props.isDisabled && {
...(props.variant === 'primary' && {
'&:hover': {
background: 'rgba(29,101,166, 0.8)!important',
borderColor: 'rgba(29,101,166, 0.8)!important',
},
'&:active': {
background: 'rgba(29,101,166, 0.8)!important',
}),
...(props.variant === 'secondary' &&
!props.isDisabled && {
background: 'rgba(230,104,9, 0.8)!important',
}),
borderColor: 'rgba(29,101,166, 0.8)!important',
},
}),
...(props.variant === 'secondary' && {
'&:hover': {
background: 'rgba(230,104,9, 0.8)!important',
borderColor: 'rgba(230,104,9, 0.8)!important',
},
'&:active': {
background: 'rgba(230,104,9, 0.8)!important',
borderColor: 'rgba(230,104,9, 0.8)!important',
},
}),
'&:disabled': {
background: 'rgb(233 236 239)',
color: 'rgb(206 212 218)',
pointer: 'not-allowed',
},
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const initialValues = {
privacy_agreement: false,
} satisfies NewUserAccount;

const DOMAIN_BASE = 'https://rotational.app/';

type RegistrationFormProps = {
onSubmit: (values: NewUserAccount, helpers: FormikHelpers<NewUserAccount>) => void;
};
Expand Down Expand Up @@ -59,11 +61,18 @@ function RegistrationForm({ onSubmit }: RegistrationFormProps) {

// if organization name is set then set domain to the slugified version of the organization name
useEffect(() => {
if (values.organization) {
if (touched.organization && !touched.domain) {
setFieldValue('domain', stringify_org(values.organization));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [values.organization]);
}, [touched.organization, touched.domain]);

useEffect(() => {
if (values.domain) {
setFieldValue('domain', stringify_org(values.domain));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [values.domain]);

return (
<FormikProvider value={formik}>
Expand All @@ -75,7 +84,6 @@ function RegistrationForm({ onSubmit }: RegistrationFormProps) {
data-testid="name"
fullWidth
errorMessage={touched.name && errors.name}
errorMessageClassName="py-1"
{...getFieldProps('name')}
/>
<TextField
Expand All @@ -84,7 +92,6 @@ function RegistrationForm({ onSubmit }: RegistrationFormProps) {
fullWidth
data-testid="email"
errorMessage={touched.email && errors.email}
errorMessageClassName="py-1"
{...getFieldProps('email')}
/>
<div className="relative">
Expand Down Expand Up @@ -115,7 +122,6 @@ function RegistrationForm({ onSubmit }: RegistrationFormProps) {
placeholder={`Password`}
data-testid="password"
errorMessage={touched.password && errors.password}
errorMessageClassName="py-1"
fullWidth
{...getFieldProps('password')}
onFocus={onFocus}
Expand All @@ -129,7 +135,6 @@ function RegistrationForm({ onSubmit }: RegistrationFormProps) {
fullWidth
data-testid="pwcheck"
errorMessage={touched.pwcheck && errors.pwcheck}
errorMessageClassName="py-1"
{...getFieldProps('pwcheck')}
/>
<TextField
Expand All @@ -154,14 +159,13 @@ function RegistrationForm({ onSubmit }: RegistrationFormProps) {
fullWidth
data-testid="organization"
errorMessage={touched.organization && errors.organization}
errorMessageClassName="py-1"
{...getFieldProps('organization')}
/>
<Fieldset>
<Span className="mt-[3px]">https://rotational.app/</Span>
<Span className="mt-[3px]">{DOMAIN_BASE}</Span>
<TextField
label={
<span className="-my-0 flex items-center gap-2">
<span className=" flex items-center gap-2">
<span>Domain</span>
<Tooltip
title={
Expand All @@ -177,9 +181,9 @@ function RegistrationForm({ onSubmit }: RegistrationFormProps) {
}
placeholder="organization name"
fullWidth
value={stringify_org(values.organization)}
errorMessageClassName="py-1"
className="mt-0"
data-testid="domain"
errorMessage={touched.domain && errors.domain}
{...getFieldProps('domain')}
/>
</Fieldset>
</div>
Expand Down Expand Up @@ -230,7 +234,6 @@ const Fieldset = styled.fieldset`
border-radius: 0.5rem;
padding-top: 25px;
padding-bottom: 17px;
overflow: hidden;
& div label {
position: absolute;
top: 0;
Expand All @@ -247,7 +250,7 @@ const Fieldset = styled.fieldset`
}
& div > div {
position: absolute;
bottom: 0;
bottom: -13px;
left: 0;
}
`;
Expand All @@ -268,6 +271,7 @@ const Span = styled.span`

// TODO: fix it in the design system
const CheckboxFieldset = styled.fieldset`
margin-top: 1rem;
label svg {
min-width: 23px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const validationSchema = Yup.object().shape({
.oneOf([Yup.ref('password'), null], 'The passwords must match.')
.required('The confirm password is required.'),
organization: Yup.string().required('The organization is required.'),
domain: Yup.string().notRequired(),
domain: Yup.string().required('The domain is required.'),
terms_agreement: Yup.boolean().required('The agreement is required.'),
}) satisfies Yup.SchemaOf<Omit<NewUserAccount, 'privacy_agreement'>>;

Expand Down
8 changes: 4 additions & 4 deletions web/beacon-app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3745,10 +3745,10 @@
estree-walker "^2.0.2"
picomatch "^2.3.1"

"@rotational/beacon-core@^2.1.2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@rotational/beacon-core/-/beacon-core-2.1.2.tgz#f4d7ccedd2264a25610543128f9941a48e1517df"
integrity sha512-v2jTDgX+QvfnQRLIH2vVp8p7VqNl/UrGwFw07tojXt9QEAdTyQpBmlyTNNm8A7Lym2ZagdCfC5Svgeg2d97+cQ==
"@rotational/beacon-core@^2.1.3":
version "2.1.3"
resolved "https://registry.yarnpkg.com/@rotational/beacon-core/-/beacon-core-2.1.3.tgz#d3ef8da596b7d507d1275d3d37da6e83b8e50c29"
integrity sha512-pqplEywUXB+SOtPj0WY8CTlPTuQDlSuhg09vcNFKc3QMI5LPTZ3OMDDfSR+ZJWW6ovYXLHRo0t9A+h1V5fXVpQ==
dependencies:
"@radix-ui/react-avatar" "^1.0.1"
"@radix-ui/react-toast" "^1.1.2"
Expand Down