Skip to content

Commit

Permalink
Merge branch 'LIBS-517/login-components' into login-components-with-r…
Browse files Browse the repository at this point in the history
…untime
  • Loading branch information
tomzemp committed Aug 3, 2023
2 parents 0febf3d + 06d7c7e commit 9cad6a2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 44 deletions.
3 changes: 1 addition & 2 deletions components/login-forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"@dhis2/ui-constants": "8.13.6",
"@dhis2/ui-forms": "^8.13.14",
"classnames": "^2.3.1",
"prop-types": "^15.7.2",
"react-router-dom": "^6.12.1"
"prop-types": "^15.7.2"
},
"files": [
"build"
Expand Down
24 changes: 9 additions & 15 deletions components/login-forms/src/components/account-creation-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {
} from '@dhis2/ui-forms'
import PropTypes from 'prop-types'
import React, { useEffect } from 'react'
import { Link, useInRouterContext } from 'react-router-dom'
import { getIsRequired, removeHTMLTags } from '../helpers/index.js'
// import { useLoginSettings } from '../providers/use-login-settings.js'
import { BackToLoginButton } from './back-to-login-button.js'
// import "../styles.css";
import { FormNotice } from './form-notice.js'
import { FormSubtitle } from './form-subtitle.js'
import { Link } from './link.js'

export const CREATE_FORM_TYPES = {
create: 'create',
Expand Down Expand Up @@ -67,7 +67,6 @@ const InnerCreateAccountForm = ({
prepopulatedFields,
}) => {
const isRequired = getIsRequired(uiLocale)
const inRouterContext = useInRouterContext()

return (
<>
Expand Down Expand Up @@ -172,13 +171,11 @@ const InnerCreateAccountForm = ({
? i18n.t('Creating...', { lng: uiLocale })
: i18n.t('Create account', { lng: uiLocale })}
</Button>
{inRouterContext && (
<Link className="no-underline" to="/">
<Button secondary disabled={loading}>
{i18n.t('Cancel', { lng: uiLocale })}
</Button>
</Link>
)}
<Link className="no-underline" to="/">
<Button secondary disabled={loading}>
{i18n.t('Cancel', { lng: uiLocale })}
</Button>
</Link>
</div>
</form>
<style>
Expand Down Expand Up @@ -232,7 +229,6 @@ export const CreateAccount = ({
}) => {
// depends on https://dhis2.atlassian.net/browse/DHIS2-14615
const { applicationTitle, uiLocale } = useLoginSettings()
const inRouterContext = useInRouterContext()

useEffect(() => {
// we should scroll top top of the page when an error is registered, so user sees this
Expand Down Expand Up @@ -262,11 +258,9 @@ export const CreateAccount = ({
{i18n.t('Already have an account?', {
lng: uiLocale,
})}{' '}
{inRouterContext && (
<Link to="/">
{i18n.t('Log in.', { lng: uiLocale })}
</Link>
)}
<Link to="/">
{i18n.t('Log in.', { lng: uiLocale })}
</Link>
</p>
)}
</FormSubtitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ import { Button } from '@dhis2-ui/button'
import i18n from '@dhis2/d2-i18n'
import PropTypes from 'prop-types'
import React from 'react'
import { Link, useInRouterContext } from 'react-router-dom'
import { Link } from './link.js'

export const BackToLoginButton = ({ uiLocale, fullWidth }) => {
const inRouterContext = useInRouterContext()

if (!inRouterContext) {
return null
}

return (
<>
<div>
Expand Down
20 changes: 0 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4170,11 +4170,6 @@
"@react-hook/passive-layout-effect" "^1.2.0"
"@react-hook/resize-observer" "^1.2.1"

"@remix-run/router@1.6.3":
version "1.6.3"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.6.3.tgz#8205baf6e17ef93be35bf62c37d2d594e9be0dad"
integrity sha512-EXJysQ7J3veRECd0kZFQwYYd5sJMcq2O/m60zu1W2l3oVQ9xtub8jTOtYRE0+M2iomyG/W3Ps7+vp2kna0C27Q==

"@rollup/plugin-babel@^5.2.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.0.tgz#9cb1c5146ddd6a4968ad96f209c50c62f92f9879"
Expand Down Expand Up @@ -19700,14 +19695,6 @@ react-router-dom@^5.2.0:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"

react-router-dom@^6.12.1:
version "6.12.1"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.12.1.tgz#601fe7eb493071a33dc7573a20b920324a834606"
integrity sha512-POIZN9UDKWwEDga054LvYr2KnK8V+0HR4Ny4Bwv8V7/FZCPxJgsCjYxXGxqxzHs7VBxMKZfgvtKhafuJkJSPGA==
dependencies:
"@remix-run/router" "1.6.3"
react-router "6.12.1"

react-router@5.2.1, react-router@^5.2.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-5.2.1.tgz#4d2e4e9d5ae9425091845b8dbc6d9d276239774d"
Expand All @@ -19724,13 +19711,6 @@ react-router@5.2.1, react-router@^5.2.0:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"

react-router@6.12.1:
version "6.12.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.12.1.tgz#9e4126aa1139ec6b5d347e19576d5e940cd46362"
integrity sha512-evd/GrKJOeOypD0JB9e1r7pQh2gWCsTbUfq059Wm1AFT/K2MNZuDo19lFtAgIhlBrp0MmpgpqtvZC7LPAs7vSw==
dependencies:
"@remix-run/router" "1.6.3"

react-scripts@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-4.0.3.tgz#b1cafed7c3fa603e7628ba0f187787964cb5d345"
Expand Down

0 comments on commit 9cad6a2

Please sign in to comment.