Reformat all project files to use the prettier config file.
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
import { HeartOutlined } from '@ant-design/icons';
|
||||
import { Select, Space, Tag } from 'antd';
|
||||
import React, { forwardRef, useEffect, useState } from 'react';
|
||||
import PhoneNumberFormatter from '../../utils/PhoneFormatter';
|
||||
import { HeartOutlined } from "@ant-design/icons";
|
||||
import { Select, Space, Tag } from "antd";
|
||||
import React, { forwardRef, useEffect, useState } from "react";
|
||||
import PhoneNumberFormatter from "../../utils/PhoneFormatter";
|
||||
|
||||
const { Option } = Select;
|
||||
|
||||
//To be used as a form element only.
|
||||
|
||||
const VendorSearchSelect = (
|
||||
{ value, onChange, options, onSelect, disabled, preferredMake, showPhone },
|
||||
ref
|
||||
) => {
|
||||
const VendorSearchSelect = ({ value, onChange, options, onSelect, disabled, preferredMake, showPhone }, ref) => {
|
||||
const [option, setOption] = useState(value);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -21,10 +18,7 @@ const VendorSearchSelect = (
|
||||
|
||||
const favorites =
|
||||
preferredMake && options
|
||||
? options.filter(
|
||||
(o) =>
|
||||
o.favorite.filter((f) => f.toLowerCase() === preferredMake.toLowerCase()).length > 0
|
||||
)
|
||||
? options.filter((o) => o.favorite.filter((f) => f.toLowerCase() === preferredMake.toLowerCase()).length > 0)
|
||||
: [];
|
||||
|
||||
return (
|
||||
@@ -33,13 +27,13 @@ const VendorSearchSelect = (
|
||||
showSearch
|
||||
value={option}
|
||||
style={{
|
||||
width: '100%',
|
||||
width: "100%"
|
||||
}}
|
||||
labelRender={({ label, value, ...rest }) => {
|
||||
if (!value || !options) return label;
|
||||
const discount = options?.find((o) => o.id === value)?.discount;
|
||||
return (
|
||||
<div className="imex-flex-row" style={{ width: '100%' }}>
|
||||
<div className="imex-flex-row" style={{ width: "100%" }}>
|
||||
<div style={{ flex: 1 }}>{label}</div>
|
||||
|
||||
{discount && discount !== 0 ? <Tag color="green">{`${discount * 100}%`}</Tag> : null}
|
||||
@@ -51,19 +45,17 @@ const VendorSearchSelect = (
|
||||
optionFilterProp="name"
|
||||
onSelect={onSelect}
|
||||
disabled={disabled || false}
|
||||
optionLabelProp={'name'}
|
||||
optionLabelProp={"name"}
|
||||
>
|
||||
{favorites
|
||||
? favorites.map((o) => (
|
||||
<Option key={`favorite-${o.id}`} value={o.id} name={o.name} discount={o.discount}>
|
||||
<div className="imex-flex-row">
|
||||
<div style={{ flex: 1 }}>{o.name}</div>
|
||||
<Space style={{ marginLeft: '1rem' }}>
|
||||
<HeartOutlined style={{ color: 'red' }} />
|
||||
<Space style={{ marginLeft: "1rem" }}>
|
||||
<HeartOutlined style={{ color: "red" }} />
|
||||
{o.phone && showPhone && <PhoneNumberFormatter>{o.phone}</PhoneNumberFormatter>}
|
||||
{o.discount && o.discount !== 0 ? (
|
||||
<Tag color="green">{`${o.discount * 100}%`}</Tag>
|
||||
) : null}
|
||||
{o.discount && o.discount !== 0 ? <Tag color="green">{`${o.discount * 100}%`}</Tag> : null}
|
||||
</Space>
|
||||
</div>
|
||||
</Option>
|
||||
@@ -72,14 +64,12 @@ const VendorSearchSelect = (
|
||||
{options
|
||||
? options.map((o) => (
|
||||
<Option key={o.id} value={o.id} name={o.name} discount={o.discount}>
|
||||
<div className="imex-flex-row" style={{ width: '100%' }}>
|
||||
<div className="imex-flex-row" style={{ width: "100%" }}>
|
||||
<div style={{ flex: 1 }}>{o.name}</div>
|
||||
|
||||
<Space style={{ marginLeft: '1rem' }}>
|
||||
<Space style={{ marginLeft: "1rem" }}>
|
||||
{o.phone && showPhone && <PhoneNumberFormatter>{o.phone}</PhoneNumberFormatter>}
|
||||
{o.discount && o.discount !== 0 ? (
|
||||
<Tag color="green">{`${o.discount * 100}%`}</Tag>
|
||||
) : null}
|
||||
{o.discount && o.discount !== 0 ? <Tag color="green">{`${o.discount * 100}%`}</Tag> : null}
|
||||
</Space>
|
||||
</div>
|
||||
</Option>
|
||||
|
||||
Reference in New Issue
Block a user