Skip to content

Commit

Permalink
styling and adding button for manual address input
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-odonovan committed Sep 28, 2023
1 parent 9d104eb commit 7a856ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
25 changes: 18 additions & 7 deletions src/components/Molecules/PostcodeLookup/PostcodeLookup.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { isValid, toNormalised } from 'postcode';
import axios from 'axios';
import Lookup from '../Lookup/Lookup';
import ButtonAsLink from '../../Atoms/ButtonAsLink/ButtonAsLink';
import StyledButtonWrapper from './PostcodeLookup.style';

const validatePostcode = postcode => {
const trimmed = typeof postcode === 'string' ? postcode.trim() : '';
Expand Down Expand Up @@ -36,8 +38,12 @@ const addressFetcher = async postcode => {
}
};

const PostcodeLookup = ({ onSelect, ...rest }) => {
const showAddressInputs = false;
export default function PostcodeLookup({ onSelect, ...rest }) {
const [showAddressInputs, setShowAddressInputs] = useState(false);
const line1 = false;
const town = true;
const postcode = true;

return (
<>
<Lookup
Expand All @@ -51,15 +57,20 @@ const PostcodeLookup = ({ onSelect, ...rest }) => {
onSelect={onSelect}
{...rest}
/>
{!showAddressInputs && (
{showAddressInputs && (
<div>address inputs</div>
)}
<StyledButtonWrapper>
<ButtonAsLink onClick={() => setShowAddressInputs(true)}>
{(line1 && town && postcode)
? 'Edit address'
: 'Or enter address manually'}
</ButtonAsLink>
</StyledButtonWrapper>
</>
);
};
}

PostcodeLookup.propTypes = {
onSelect: PropTypes.func.isRequired
};

export default PostcodeLookup;
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import styled from 'styled-components';
import spacing from '../../../theme/shared/spacing';

import Link from '../../Atoms/Link/Link';

const Item = styled(Link)`
/* blah blah */
const StyledButtonWrapper = styled.div`
margin-top: ${spacing('md')};
`;

export { Item };
export default StyledButtonWrapper;

0 comments on commit 7a856ec

Please sign in to comment.