lodash#isEmpty JavaScript Examples

The following examples show how to use lodash#isEmpty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.js    From hzero-front with Apache License 2.0 7 votes vote down vote up
/**
 * getUploadElement - 获取 Upload 的 render
 * @param {Object} field - 字段
 */
function getUploadElement({ field, organizationId }) {
  if (isEmpty(field.lovCode)) {
    return getInputElement({ field });
  } else {
    const props = dealFieldProps(field);
    return <Upload {...props} organizationId={organizationId} />;
  }
}
Example #2
Source File: router-utils.js    From ThreatMapper with Apache License 2.0 7 votes vote down vote up
function omitDefaultValues(urlState) {
  // A couple of cases which require special handling because their URL state
  // default values might be in different format than their Redux defaults.
  if (!urlState.controlPipe) {
    urlState = omit(urlState, 'controlPipe');
  }
  if (isEmpty(urlState.nodeDetails)) {
    urlState = omit(urlState, 'nodeDetails');
  }
  if (isEmpty(urlState.topologyOptions)) {
    urlState = omit(urlState, 'topologyOptions');
  }

  // Omit all the fields which match their initial Redux state values.
  return omitBy(urlState, (value, key) => (
    isDeepEqual(fromJS(value), initialRootState.get(key))
  ));
}
Example #3
Source File: index.js    From strapi-plugin-config-sync with MIT License 6 votes vote down vote up
ActionButtons = () => {
  const dispatch = useDispatch();
  const toggleNotification = useNotification();
  const [modalIsOpen, setModalIsOpen] = useState(false);
  const [actionType, setActionType] = useState('');
  const partialDiff = useSelector((state) => state.getIn(['config', 'partialDiff'], Map({}))).toJS();

  const closeModal = () => {
    setActionType('');
    setModalIsOpen(false);
  };

  const openModal = (type) => {
    setActionType(type);
    setModalIsOpen(true);
  };

  return (
    <ActionButtonsStyling>
      <Button disabled={isEmpty(partialDiff)} onClick={() => openModal('import')}>Import</Button>
      <Button disabled={isEmpty(partialDiff)} onClick={() => openModal('export')}>Export</Button>
      {!isEmpty(partialDiff) && (
        <h4 style={{ display: 'inline' }}>{Object.keys(partialDiff).length} {Object.keys(partialDiff).length === 1 ? "config change" : "config changes"}</h4>
      )}
      <ConfirmModal
        isOpen={modalIsOpen}
        onClose={closeModal}
        type={actionType}
        onSubmit={() => actionType === 'import' ? dispatch(importAllConfig(partialDiff, toggleNotification)) : dispatch(exportAllConfig(partialDiff, toggleNotification))}
      />
    </ActionButtonsStyling>
  );
}
Example #4
Source File: CustModal.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
// 还原
  @Bind()
  reset() {
    const { modifyConfig = {}, activeUnitCode } = this.state;
    const { config = {} } = modifyConfig[activeUnitCode];
    this.setState({ resetLoading: true });
    if (!isEmpty(config)) {
      resetUserCustConfig({
        unitId: config.unitId,
      }).then((res) => {
        if (!isNil(res)) {
          notification.success();
          this.fetchUserCustConfig(activeUnitCode);
        }
        this.setState({ resetLoading: false });
      });
    }
  }
Example #5
Source File: index.js    From strapi-plugin-react-editorjs with MIT License 6 votes vote down vote up
Wysiwyg = ({
  name,
  className,
  error,
  description,
  intlLabel,
  required,
  onChange,
  style,
  value,
  disabled,
}) => {
  const { formatMessage } = useIntl();

  return (
    <Wrapper size={1} className={`${cn(!isEmpty(className) && className)}`} style={style}>            
      <Box>
        <Typography variant="pi" fontWeight="bold">
          {formatMessage(intlLabel)}
        </Typography>
        {required && (
          <Typography variant="pi" fontWeight="bold" textColor="danger600">
            *
          </Typography>
        )}
      </Box>
      <Editor onChange={onChange} value={value} name={name} disabled={disabled} />
      {error && (
        <Typography variant="pi" textColor="danger600">
          {formatMessage({ id: error, defaultMessage: error })}
        </Typography>
      )}
      {description && (
        <Typography variant="pi">{formatMessage(description)}</Typography>
      )}
      
    </Wrapper>
  )
}
Example #6
Source File: Table.jsx    From kube-design with MIT License 6 votes vote down vote up
render() {
    const {
      title,
      footer,
      loading,
      className,
      emptyText,
      ...rest
    } = this.props;
    return (
      <TableContext.Provider value={{ ...rest, ...this.state }}>
        <Loading spinning={loading}>
          <div
            className={classNames(
              "table",
              {
                "table-has-selected": this.hasSelected,
                "table-multi-heads": this.state.heads.length > 1,
              },
              className
            )}
          >
            {title && <div className="table-title">{title}</div>}
            <div className="table-body">
              <table>
                <ColGroup />
                <Thead />
                <Tbody />
              </table>
            </div>
            {isEmpty(rest.dataSource) && (
              <div className="table-placeholder">{emptyText}</div>
            )}
            {footer && <div className="table-footer">{footer}</div>}
          </div>
        </Loading>
      </TableContext.Provider>
    );
  }
Example #7
Source File: reducerInjectors.js    From hackchat-client with Do What The F*ck You Want To Public License 6 votes vote down vote up
/**
 * Add target reducer
 * @param {Store} store Target redux store context
 * @param {boolean} isValid Validation has already happened
 */
export function injectReducerFactory(store, isValid) {
  return function injectReducer(key, reducer) {
    if (!isValid) checkStore(store);

    invariant(
      isString(key) && !isEmpty(key) && isFunction(reducer),
      '(app/utils...) injectReducer: Expected `reducer` to be a reducer function',
    );

    if (
      Reflect.has(store.injectedReducers, key) &&
      store.injectedReducers[key] === reducer
    )
      return;

    store.injectedReducers[key] = reducer; // eslint-disable-line no-param-reassign
    store.replaceReducer(createReducer(store.injectedReducers));
  };
}
Example #8
Source File: CreateRecordsForm.js    From ui-plugin-create-inventory-records with Apache License 2.0 6 votes vote down vote up
validate = (values) => {
  const instance = validateInstance(values.instance);
  const holding = validateHolding(values.holding);
  const item = validateItem(values.item);

  if (isEmpty(instance) &&
    isEmpty(holding) &&
    isEmpty(item)) {
    return {};
  }

  return {
    instance,
    holding,
    item,
  };
}
Example #9
Source File: MappingProfilesFormContainer.js    From ui-data-export with Apache License 2.0 6 votes vote down vote up
isValidRecordTypesMatching = (selectedTransformations = [], selectedRecordTypes = []) => {
  const isOnlySrsSelected = selectedRecordTypes.length === 1 && selectedRecordTypes[0] === FOLIO_RECORD_TYPES.SRS.type;

  if (isEmpty(selectedTransformations) && !isOnlySrsSelected) {
    return false;
  }

  const recordTypesInTransformations = uniq(selectedTransformations.map(({ recordType }) => recordType));

  const validatedRecords = selectedRecordTypes.filter(recordType => recordType !== FOLIO_RECORD_TYPES.SRS.type);

  return isEmpty(difference(recordTypesInTransformations, validatedRecords))
    && isEmpty(difference(validatedRecords, recordTypesInTransformations));
}
Example #10
Source File: render.jsx    From volto-slate with MIT License 6 votes vote down vote up
Element = ({ element, attributes = {}, extras, ...rest }) => {
  const { slate } = config.settings;
  const { elements } = slate;
  const El = elements[element.type] || elements['default'];

  const out = Object.assign(
    element.styleName ? { className: element.styleName } : {},
    ...Object.keys(attributes || {}).map((k) =>
      !isEmpty(attributes[k]) ? { [k]: attributes[k] } : {},
    ),
  );

  return (
    <El
      element={element}
      {...omit(rest, OMITTED)}
      attributes={out}
      extras={extras}
    />
  );
}
Example #11
Source File: string-utils.js    From ThreatMapper with Apache License 2.0 6 votes vote down vote up
export function getHostNameWithoutSemicolon(string) {
  if (!isEmpty(string)) {
    return string.split(';')[0];
  }
  return '';
}
Example #12
Source File: save.js    From gutenberg-forms with GNU General Public License v2.0 6 votes vote down vote up
function save(props) {

    const formId = props.attributes.formId;
    const shortCode = `[gutenberg_form id=${formId}]`

    const shouldRender = !isEmpty(formId);

    return shouldRender ? <RawHTML>{shortCode}</RawHTML> : null;

}
Example #13
Source File: reducerInjectors.js    From QiskitFlow with Apache License 2.0 6 votes vote down vote up
export function injectReducerFactory(store, isValid) {
  return function injectReducer(key, reducer) {
    if (!isValid) checkStore(store);

    invariant(
      isString(key) && !isEmpty(key) && isFunction(reducer),
      '(app/utils...) injectReducer: Expected `reducer` to be a reducer function',
    );

    // Check `store.injectedReducers[key] === reducer` for hot reloading when a key is the same but a reducer is different
    if (
      Reflect.has(store.injectedReducers, key) &&
      store.injectedReducers[key] === reducer
    )
      return;

    store.injectedReducers[key] = reducer; // eslint-disable-line no-param-reassign
    store.replaceReducer(createReducer(store.injectedReducers));
  };
}
Example #14
Source File: index.js    From datapass with GNU Affero General Public License v3.0 6 votes vote down vote up
isEmailValid = (email) => {
  if (!isString(email) || isEmpty(email)) {
    return false;
  }

  const parts = email.split('@').filter((part) => part);

  // The email address contains two parts, separated with an @ symbol.
  // => these parts are non empty strings
  // => there are two and only two parts
  if (parts.length !== 2) {
    return false;
  }

  // The email address does not contain dangerous characters
  // => the postgres connector is taking care of this

  // The domain part contains only letters, numbers, hyphens (-) and periods (.)
  const domain = parts[1];
  if (domain.match(/^[a-zA-Z0-9.-]*$/) === null) {
    return false;
  }

  // The local part (before the @) should be no more than 63 characters.
  const localPart = parts[0];
  if (localPart.length > 63) {
    return false;
  }

  // The total length should be no more than 254 characters.
  if (email.length > 254) {
    return false;
  }

  return true;
}
Example #15
Source File: FormButtons.js    From user-preferences-frontend with Apache License 2.0 6 votes vote down vote up
FormButtons = ({
  dirtyFieldsSinceLastSubmit,
  submitSucceeded,
  pristine,
}) => {
  const { reset } = useFormApi();
  const noChanges =
    isEmpty(dirtyFieldsSinceLastSubmit) || (!submitSucceeded && pristine);
  return (
    <ActionGroup>
      <Button
        className="pref-email__form-button"
        type="submit"
        ouiaId="user-pref-primary-button"
        isDisabled={noChanges}
        variant="primary"
      >
        Save
      </Button>
      <Button
        variant="link"
        ouiaId="user-pref-reset-button"
        isDisabled={noChanges}
        onClick={() => reset()}
      >
        Cancel
      </Button>
    </ActionGroup>
  );
}
Example #16
Source File: checkout.js    From haven with MIT License 6 votes vote down vote up
parseVariantInfo = (variantInfo, options) => {
  if (isEmpty(variantInfo)) {
    return [];
  }
  const { variantCombo } = variantInfo;
  if (isEmpty(variantCombo)) {
    return [];
  }
  const retVal = variantCombo.map((val, idx) => ({
    name: options[idx].name,
    value: options[idx].variants[val].name,
  }));
  return retVal;
}
Example #17
Source File: index.js    From gutenberg-forms with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find the root form block.
 *
 * @param {string} clientId The id of the block of which we are finding the root
 * @param {string} asRoot Whether to use the given clientId as the root of the search.
 */
export function getRootFormBlock(clientId, asRoot = false) {
	//this functions will return the root form through which the given field is nested
	//excepting all of the cases;
	const rootId = asRoot ? clientId : getBlockHierarchyRootClientId(clientId);
	const rootBlock = getBlock(rootId); //getting the root block;

	if (isEmpty(rootBlock)) return {}; // null exception

	//checking if the root block is "cwp/gutenberg-forms" or it is nested inside of this root block
	// for example "cwp/cover" can furthur nest our "cwp/gutenberg-forms" block

	if (rootBlock.name === "cwp/block-gutenberg-forms") {
		// if this condition is satisfied then our form is not nested inside
		// any other block, so we can simply return the root form

		return rootBlock;
	}

	// The  above condition didn't succeed, so our form block is nested somewhere
	// so we need to find our root form inside this block

	let rootForm;

	for (const childBlock of rootBlock.innerBlocks) {
		// our root form block is nested somewhere here...

		if (childBlock.name === "cwp/block-gutenberg-forms") {
			// if this condition is satisfied, This should be our block...

			rootForm = childBlock;

			break;
		} else if (has(childBlock, "innerBlocks")) {
			// Try to find the form block within this child. Make sure it's treated as the search root.
			let nestedSearch = getRootFormBlock(childBlock.clientId, true);

			if (!isEmpty(nestedSearch)) {
				rootForm = nestedSearch;
			}
		}
	}

	return rootForm;
}
Example #18
Source File: shippingAddress.js    From haven with MIT License 5 votes vote down vote up
render() {
    const { routeName } = this.props.navigation.state;
    const {
      shippingAddresses, selected, shippingOptions,
    } = this.state;
    return (
      <View style={screenWrapper.wrapper}>
        <Header
          left={<NavBackButton />}
          onLeft={() => {
            this.props.navigation.dispatch(NavigationActions.back());
          }}
          title="Shipping"
          right={<LinkText text="Done" color={linkTextColor} />}
          onRight={() => {
            this.toNextScreen();
          }}
        />
        <ScrollView>
          <Text>{isEmpty(shippingOptions)}</Text>
          <InputGroup title="Ship To">
            {isEmpty(shippingAddresses) ? (
              <Text style={styles.noShipping}>No shipping address</Text>
            ) : (
              <RadioGroup
                alignTop
                options={shippingAddresses}
                selected={selected}
                onChange={this.handleAddressIndexChange}
                renderItem={this.renderShippingAddress}
                showSeparator
              />
            )}
            <TouchableWithoutFeedback onPress={this.onNewAddress}>
              <View>
                <Text style={styles.newAddress}>+ Add new address</Text>
              </View>
            </TouchableWithoutFeedback>
          </InputGroup>
          {routeName === 'CheckoutShippingAddress' && this.renderShippingOptions()}
        </ScrollView>
        <OBActionSheet
          ref={this.setActionSheet}
          onPress={this.handleChange}
          options={['Edit', 'Delete', 'Cancel']}
          cancelButtonIndex={2}
          destructiveButtonIndex={1}
        />
      </View>
    );
  }
Example #19
Source File: index.js    From gutenberg-forms with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param {Client if of the block which sibling will be returned} clientId
 * @param {filter the siblings by thier slugs} slug
 */

export function getSiblings(clientId, slug = null) {
	const rootBlock = getRootFormBlock(clientId); //i.e = gutenberg-forms;

	if (isEmpty(rootBlock)) return []; //null exception

	if (
		rootBlock.name !== "cwp/block-gutenberg-forms" &&
		has(rootBlock, "innerBlocks")
	)
		return false;

	let siblingValues = [];

	rootBlock.innerBlocks.forEach((v) => {
		const breaked = v.name.split("/");

		const conditions = {
			isCakewpBlock: v.name.startsWith("cwp/"), //ensuring that this is our block!
			isFieldBlock: myAttrs.includes(breaked[breaked.length - 1]), //ensuring that it is a gutenberg-form field;
			isLayoutBlock: layoutBlocks.includes(v.name), //ensuring that it is not a layout block
			currentBlock: v.clientId === clientId, //ensuring that this is not the block
			miscBlocks: miscBlocks.includes(v.name),
		};

		if (
			conditions.isCakewpBlock &&
			conditions.isFieldBlock &&
			!conditions.isLayoutBlock &&
			!conditions.currentBlock &&
			!conditions.miscBlock
		) {
			if (slug === null) {
				siblingValues.push(v.attributes);
			} else if (slug === v.name) {
				//for specified block fields
				siblingValues.push(v.attributes);
			}
		} else if (conditions.isLayoutBlock) {
			siblingValues.push(...getChildAttributes(v.clientId, slug)); //getting inner fields in layout blocks with slug filter
		}
	});

	return siblingValues;
}
Example #20
Source File: OrderRating.js    From haven with MIT License 5 votes vote down vote up
render() {
    const { rating } = this.props;
    return isEmpty(rating) ? this.renderEmpty() : this.renderReviews();
  }
Example #21
Source File: helper.js    From gutenberg-forms with GNU General Public License v2.0 5 votes vote down vote up
export function get_admin_id(adminId) {
	if (isEmpty(adminId.value)) {
		return adminId.default;
	} else {
		return adminId.value;
	}
}
Example #22
Source File: OrderDispute.js    From haven with MIT License 5 votes vote down vote up
renderDisputePayout() {
    const { orderDetails, localLabelFromBCH, orderType } = this.props;
    const { contract, state } = orderDetails;
    const { buyerOrder, disputeResolution, disputeAcceptance } = contract;
    const buyerValue = get(disputeResolution, 'payout.buyerOutput.bigAmount');
    const sellerValue = get(disputeResolution, 'payout.vendorOutput.bigAmount');
    const moderatorValue = get(disputeResolution, 'payout.moderatorOutput.bigAmount');
    const memo = get(disputeResolution, 'resolution');
    const coin = get(buyerOrder, 'payment.amountCurrency.code');
    const amIBuyer = orderType === 'purchases';
    return (
      <InputGroup
        title="Dispute payout"
        actionTitle={timeSince(new Date(disputeResolution.timestamp))}
        actionStyle={styles.timestamp}
      >
        {!isEmpty(memo) && (
          <View style={styles.memoContainer}>
            <Text style={styles.memo}>{decode(memo)}</Text>
          </View>
        )}
        <Text style={styles.memoComment}>
          <Text style={styles.payoutMainAmount}>
            {localLabelFromBCH((amIBuyer ? buyerValue : sellerValue) || 0, coin)}
          </Text>
          {' will be issued to you.'}
        </Text>
        <Text style={[styles.serviceFee, state !== 'DECIDED' && { marginBottom: 18 }]}>
          {'Moderator takes '}
          <Text style={styles.payoutAmount}>{localLabelFromBCH(moderatorValue || 0, coin)}</Text>
          {'. '}
          {amIBuyer ? 'Seller takes ' : 'Buyer takes '}
          <Text style={styles.payoutAmount}>
            {localLabelFromBCH((amIBuyer ? sellerValue : buyerValue) || 0, coin)}
          </Text>
          .
        </Text>
        {state === 'DECIDED' && !disputeAcceptance && (
          <TouchableWithoutFeedback onPress={this.handleAcceptPayout}>
            <View style={styles.acceptButton} >
              <Text style={styles.acceptText}>Accept payout</Text>
            </View>
          </TouchableWithoutFeedback>
        )}
      </InputGroup>
    );
  }
Example #23
Source File: edit.js    From gutenberg-forms with GNU General Public License v2.0 5 votes vote down vote up
function edit(props) {
	const [disabled, setDisabled] = useState(false);

	const { setAttributes } = props;
	const { label, hideStep } = props.attributes;

	useEffect(() => {
		const root = getRootFormBlock(props.clientId);

		if (!isEmpty(root)) {
			let root_type = get(root, "attributes.formType");

			root_type === "standard" ? setDisabled(true) : null; // checking if the root form is a multistep
		}
	}, []);

	return [
		props.isSelected && !disabled && (
			<InspectorControls>
				<PanelBody initialOpen={true} title={__("Step Settings", "cwp-gutenberg-forms")}>
					<TextControl
						placeholder={__("Form Step", "cwp-gutenberg-forms")}
						label={__("Label", "cwp-gutenberg-forms")}
						value={label}
						onChange={(label) => setAttributes({ label })}
					/>
				</PanelBody>
			</InspectorControls>
		),
		null,
		<div className="cwp-form-step">
			{disabled ? (
				<Notice status="warning" isDismissible={false}>
					This is to be used only within the Multi-Step Form.
				</Notice>
			) : (
				<div
					className="cwp-add-step-appender"
					style={{ display: hideStep ? "none" : "block" }}
				>
					<InnerBlocks template={[["core/paragraph", {}]]} />
				</div>
			)}
		</div>,
	];
}
Example #24
Source File: InputSearch.jsx    From kube-design with MIT License 5 votes vote down vote up
render() {
    const { value } = this.state;
    const {
      name,
      placeholder,
      disabled,
      className,
      style,
      onSearch,
      ...rest
    } = this.props;

    return (
      <div
        className={classNames(
          "has-icons-left",
          "has-icons-right",
          "input-search",
          className
        )}
        style={style}
      >
        <Icon className="is-left" name="magnifier" />
        <Input
          type="text"
          placeholder={placeholder}
          onChange={this.handleChange}
          onKeyUp={this.handleKeyUp}
          name={name}
          disabled={disabled}
          {...rest}
          value={value || ""}
        />
        {!isEmpty(value) && (
          <Icon
            className="is-right"
            name="close"
            clickable
            onClick={this.handleClear}
          />
        )}
      </div>
    );
  }
Example #25
Source File: ProductRating.js    From haven with MIT License 5 votes vote down vote up
render() {
    if (isEmpty(this.state.ratingData)) {
      return null;
    }
    const { profile, ratingData } = this.state;
    const {
      review,
      overall,
      quality,
      description,
      deliverySpeed,
      customerService,
      timestamp: { seconds },
      vendorSig: { metadata: listing },
    } = ratingData;
    const {
      peerID, inDetail, bigPadding, onPress, isForStore,
    } = this.props;
    const borderStyle = { borderBottomWidth: inDetail ? 1 : 0, borderColor: '#c8c7c7' };
    return (
      <TouchableWithoutFeedback onPress={onPress}>
        <View style={[styles.wrapper, borderStyle, bigPadding ? { padding: 16 } : {}]}>
          {isForStore ? (
            <ListingReview
              peerID={peerID}
              profile={profile}
              review={review}
              overall={overall}
              listing={listing}
              past={timeSince(new Date(seconds * 1000))}
            />
          ) : (
            <BuyerReview
              profile={profile}
              review={review}
              overall={overall}
              past={timeSince(new Date(seconds * 1000))}
              inDetail={inDetail}
            />
          )}
          {inDetail && (
            <View style={styles.scoreWrapper}>
              <Rating title="Quality" value={quality} />
              <Rating title="As advertised" value={description} />
              <Rating title="Delivery" value={deliverySpeed} />
              <Rating title="Service" value={customerService} />
            </View>
          )}
        </View>
      </TouchableWithoutFeedback>
    );
  }
Example #26
Source File: index.js    From strapi-plugin-wysiwyg-toastui with MIT License 5 votes vote down vote up
render() {
    const {
      autoFocus,
      className,
      deactivateErrorHighlight,
      disabled,
      error: inputError,
      inputClassName,
      inputDescription,
      inputStyle,
      label,
      name,
      onBlur: handleBlur,
      onChange,
      placeholder,
      resetProps,
      style,
      tabIndex,
      validations,
      value,
      ...rest
    } = this.props;

    return (
      <Error
        inputError={inputError}
        name={name}
        type="text"
        validations={validations}
      >
        {({ canCheck, onBlur, error, dispatch }) => {
          const hasError = error && error !== null;

          return (
            <Wrapper
              className={`${cn(!isEmpty(className) && className)} ${
                hasError ? 'bordered' : ''
              }`}
              style={style}
            >
              <Label htmlFor={name}>{label}</Label>
              <Editor
                {...rest}
                autoFocus={autoFocus}
                className={inputClassName}
                disabled={disabled}
                deactivateErrorHighlight={deactivateErrorHighlight}
                error={hasError}
                name={name}
                onBlur={isFunction(handleBlur) ? handleBlur : onBlur}
                onChange={e => {
                  if (!canCheck) {
                    dispatch({
                      type: 'SET_CHECK',
                    });
                  }

                  dispatch({
                    type: 'SET_ERROR',
                    error: null,
                  });
                  onChange(e);
                }}
                placeholder={placeholder}
                resetProps={resetProps}
                style={inputStyle}
                tabIndex={tabIndex}
                value={value}
              />
              {!hasError && inputDescription && (
                <Description>{inputDescription}</Description>
              )}
              {hasError && <ErrorMessage>{error}</ErrorMessage>}
            </Wrapper>
          );
        }}
      </Error>
    );
  }
Example #27
Source File: ProductListItem.js    From haven with MIT License 5 votes vote down vote up
render() {
    const {
      freeShipping,
      thumbnail,
      amount,
      currencyCode,
      averageRating,
      ratingCount,
      title,
      style,
      localLabelFromBCH,
      hideSellerName,
    } = this.props;
    const freeShippingText = isEmpty(freeShipping) ? '' : 'FREE SHIPPING';
    return (
      <TouchableWithoutFeedback onPress={this.onPressListing}>
        <View style={[styles.wrapper, style]}>
          <FastImage
            style={styles.image}
            source={getImageSourceWithDefault(thumbnail)}
            resizeMode={FastImage.resizeMode.cover}
          />
          <View style={styles.textWrapper}>
            <View>
              <Text style={styles.title} numberOfLines={2}>
                {decode(title)}
              </Text>
              {!hideSellerName && (
                <Text style={styles.fromText} numberOfLines={1}>
                  {decode(this.getStoreName())}
                </Text>
              )}
            </View>
            <View style={styles.priceWrapper}>
              <Text style={priceStyle}>{`${localLabelFromBCH(amount, currencyCode)}  `}</Text>
              {!isEmpty(freeShipping) && (
                <View style={styles.shippingTextWrapper}>
                  <Text style={[priceStyle, styles.shipping]}>{` ${freeShippingText} `}</Text>
                </View>
              )}
            </View>
            <Text style={styles.rating}>
              <Ionicons name="md-star" size={16} color={starRatingColor} />
              &nbsp;
              {`${averageRating.toFixed(1)} (${ratingCount})`}
            </Text>
          </View>
        </View>
      </TouchableWithoutFeedback>
    );
  }
Example #28
Source File: validation.js    From ui-data-export with Apache License 2.0 5 votes vote down vote up
requiredArray = values => {
  return !isEmpty(values) ? undefined : <FormattedMessage id="stripes-data-transfer-components.validation.enterValue" />;
}
Example #29
Source File: sagaInjectors.js    From hackchat-client with Do What The F*ck You Want To Public License 5 votes vote down vote up
checkKey = (key) =>
  invariant(
    isString(key) && !isEmpty(key),
    '(app/utils...) injectSaga: Expected `key` to be a non empty string',
  )