Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / @skava/ui   js

Repository URL to install this package:

Version: 2.8.8 

/ src / components / presets / Address / AddressThemed.tsx

import React from 'react'
import { AddressProps } from 'abstractions/Address/typings'
import {
  PhysicalAddressProps,
  Name,
  AddressLine1,
  AddressLine2,
  Country,
  City,
  State,
  PostalCode,
} from 'molecules/PhysicalAddress'
import { Address } from './Address'
import { StyledTitle, StyledAddress } from './styled'
import { AddressPresetProps, AddressType } from './typings'

const createRenderProps = (data: AddressType) => {
  const renderTitle = (props: AddressProps) => {
    return <StyledTitle breedType="h3" content={data.title} />
  }
  const renderDetails = (props: PhysicalAddressProps) => {
    return (
      <React.Fragment>
        <Name>
          {data.firstName} {data.lastName}
        </Name>
        <AddressLine1 itemprop="streetAddress1">
          {data.addressLine1}
        </AddressLine1>
        <AddressLine2 itemprop="streetAddress2">
          {data.addressLine2}
        </AddressLine2>
        <Country itemprop="addressCountry">{data.country}</Country>
        <City itemprop="addressLocality">{data.city},</City>
        <State itemprop="addressRegion">{data.state}</State>
        <PostalCode itemprop="postalCode">{data.postalCode}</PostalCode>
      </React.Fragment>
    )
  }
  const renderAddress = (props: AddressProps) => {
    const attributes = {
      renderDetails,
    }
    return <StyledAddress {...attributes} />
  }

  return {
    renderTitle,
    renderAddress,
  }
}

class AddressThemed extends React.Component<AddressPresetProps> {
  render() {
    const { address, title } = this.props
    const { renderTitle, renderAddress } = createRenderProps({
      title,
      ...address,
    })

    const attributes = {
      renderTitle,
      renderAddress,
    }
    return <Address {...attributes} />
  }
}

export { AddressThemed }
export default AddressThemed