How to use the cozy-client.withClient function in cozy-client

To help you get started, we’ve selected a few cozy-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cozy / cozy-ui / react / Viewer / ImageLoader.jsx View on Github external
}

ImageLoader.propTypes = {
  file: PropTypes.object.isRequired,
  render: PropTypes.func.isRequired,
  size: PropTypes.oneOf(['small', 'medium', 'large']),
  onError: PropTypes.func,
  renderFallback: PropTypes.func
}

ImageLoader.defaultProps = {
  size: 'small',
  onError: () => {}
}

export default withClient(ImageLoader)
github cozy / cozy-ui / react / Viewer / TextViewer.jsx View on Github external
) : (
            
          )}
        
      )
  }
}

TextViewer.propTypes = {
  client: PropTypes.object.isRequired,
  url: PropTypes.string.isRequired,
  file: FileDoctype.isRequired,
  renderFallbackExtraContent: PropTypes.func
}

export default withFileUrl(withClient(TextViewer))
github cozy / cozy-ui / react / ContactsListModal / AddContactButton.jsx View on Github external
{({ onClick, href }) => (
        
      )}
    
  )
}

const AddContactButton = withClient(DumbAddContactButton)

export default AddContactButton
github cozy / cozy-bar / examples / index.jsx View on Github external
check: () => Promise.resolve(false),
  start: resolve => resolve()
}

const isInitializedWithCozyClient = () => {
  const v = localStorage.getItem('init-without-cozy-client')
  return v === 'true' || v === null
}

const toggleCozyClientInitialization = () => {
  const v = isInitializedWithCozyClient()
  localStorage.setItem('init-without-cozy-client', v ? 'false' : 'true')
  window.location.reload()
}

const Index = withClient(({ client }) => {
  return (
    
      <main>
        <div>
          Initialized with CozyClient:{' '}
          {isInitializedWithCozyClient() ? 'yes' : 'no'}
          <button>toggle</button>
          <br>
          You are logged in on {client.stackClient.uri} !<br>
          Client options: <pre>{JSON.stringify(client.options, null, 2)}</pre>
        </div>
      </main>
    
  )
})
github cozy / cozy.github.io / en / cozy-banks / src / ducks / transactions / FileOpener.jsx View on Github external
onDismiss={() =&gt; {}}
        into="body"
        size="xxlarge"
      &gt;
        {children}
      
    )
  }
}

FileOpener.propTypes = {
  children: PropTypes.element.isRequired,
  fileId: PropTypes.string.isRequired
}

export default withClient(FileOpener)
github cozy / cozy-ui / react / AppIcon / index.jsx View on Github external
}

AppIcon.propTypes = {
  alt: PropTypes.string,
  /** Required if fetchIcon is not provided */
  app: PropTypes.oneOfType([AppDoctype, PropTypes.string]),
  /** Icon to fallback on error (optional), default cube icon */
  fallbackIcon: iconPropType,
  /** Custom implementation of how to fetch icon */
  fetchIcon: PropTypes.func,
  client: PropTypes.object.isRequired,
  className: PropTypes.string,
  onReady: PropTypes.func
}

export default withClient(AppIcon)
github cozy / cozy-ui / react / Viewer / NoViewer / DownloadButton.jsx View on Github external
const DownloadButton = ({ t, client, file }) =&gt; (
  <button> client.collection('io.cozy.files').download(file)}
    label={t('Viewer.download')}
  /&gt;
)

DownloadButton.propTypes = {
  t: PropTypes.func.isRequired,
  client: PropTypes.object.isRequired,
  file: FileDoctype
}

export default translate()(withClient(DownloadButton))
</button>
github cozy / cozy.github.io / en / cozy-banks / src / ducks / balance / KonnectorIcon.jsx View on Github external
fetchIcon() {
    const { client, slug, app } = this.props
    return client.stackClient.getIconURL({
      type: 'konnector',
      slug: slug || app.slug
    })
  }

  render() {
    const { className } = this.props

    return 
  }
}

export default withClient(KonnectorIcon)
github cozy / cozy.github.io / en / cozy-banks / src / components / UserActionRequired / index.jsx View on Github external
const tosUpdated = warnings.find(w =&gt; w.code === 'tos-updated')
    if (__TARGET__ === 'mobile' &amp;&amp; tosUpdated) {
      return (
        
      )
    }

    return this.props.children
  }
}

export default withClient(UserActionRequired)
github cozy / cozy-ui / react / Viewer / ViewerControls.jsx View on Github external
}
ViewerControls.propTypes = {
  client: PropTypes.object.isRequired,
  currentFile: PropTypes.object.isRequired,
  onClose: PropTypes.func.isRequired,
  hasPrevious: PropTypes.bool.isRequired,
  hasNext: PropTypes.bool.isRequired,
  onPrevious: PropTypes.func.isRequired,
  onNext: PropTypes.func.isRequired,
  isMobile: PropTypes.bool.isRequired,
  expanded: PropTypes.bool.isRequired,
  showToolbar: PropTypes.bool.isRequired,
  showNavigation: PropTypes.bool.isRequired,
  isMobileApp: PropTypes.bool.isRequired
}
export default translate()(withClient(ViewerControls))