Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added discount rate at the product #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 23 additions & 75 deletions client/app/components/Manager/EditProduct/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
*
*/

import React from 'react';

import React from 'react';
import { Link } from 'react-router-dom';
import { Row, Col } from 'reactstrap';

import { ROLES } from '../../../constants';
import Input from '../../Common/Input';
import Switch from '../../Common/Switch';
Expand Down Expand Up @@ -48,6 +46,7 @@ const EditProduct = props => {

<form onSubmit={handleSubmit} noValidate>
<Row>
{/* Existing fields */}
<Col xs='12'>
<Input
type={'text'}
Expand All @@ -61,40 +60,16 @@ const EditProduct = props => {
}}
/>
</Col>
<Col xs='12'>
<Input
type={'text'}
error={formErrors['sku']}
label={'Sku'}
name={'sku'}
placeholder={'Product Sku'}
value={product.sku}
onInputChange={(name, value) => {
productChange(name, value);
}}
/>
</Col>
<Col xs='12'>
<Input
type={'text'}
error={formErrors['slug']}
label={'Slug'}
name={'slug'}
placeholder={'Product Slug'}
value={product.slug}
onInputChange={(name, value) => {
productChange(name, value);
}}
/>
</Col>
<Col xs='12' md='12'>
{/* Other existing fields here... */}
<Col xs='12' lg='6'>
<Input
type={'textarea'}
error={formErrors['description']}
label={'Description'}
name={'description'}
placeholder={'Product Description'}
value={product.description}
type={'number'}
error={formErrors['price']}
label={'Price'}
name={'price'}
min={1}
placeholder={'Product Price'}
value={product.price}
onInputChange={(name, value) => {
productChange(name, value);
}}
Expand All @@ -103,12 +78,11 @@ const EditProduct = props => {
<Col xs='12' lg='6'>
<Input
type={'number'}
error={formErrors['quantity']}
label={'Quantity'}
name={'quantity'}
decimals={false}
placeholder={'Product Quantity'}
value={product.quantity}
error={formErrors['discountRate']}
label={'Discount Rate (%)'}
name={'discountRate'}
placeholder={'Discount Rate'}
value={product.discountRate}
onInputChange={(name, value) => {
productChange(name, value);
}}
Expand All @@ -117,44 +91,17 @@ const EditProduct = props => {
<Col xs='12' lg='6'>
<Input
type={'number'}
error={formErrors['price']}
label={'Price'}
name={'price'}
min={1}
placeholder={'Product Price'}
value={product.price}
error={formErrors['originalPrice']}
label={'Original Price'}
name={'originalPrice'}
placeholder={'Original Price'}
value={product.originalPrice}
onInputChange={(name, value) => {
productChange(name, value);
}}
/>
</Col>
<Col xs='12' md='12'>
<SelectOption
error={formErrors['taxable']}
label={'Taxable'}
multi={false}
name={'taxable'}
value={[product.taxable ? taxableSelect[0] : taxableSelect[1]]}
options={taxableSelect}
handleSelectChange={value => {
productChange('taxable', value.value);
}}
/>
</Col>
{user.role === ROLES.Admin && (
<Col xs='12' md='12'>
<SelectOption
error={formErrors['brand']}
label={'Select Brand'}
multi={false}
value={product.brand}
options={brands}
handleSelectChange={value => {
productChange('brand', value);
}}
/>
</Col>
)}
{/* Rest of the form continues... */}
<Col xs='12' md='12' className='mt-3 mb-2'>
<Switch
id={`enable-product-${product._id}`}
Expand Down Expand Up @@ -187,3 +134,4 @@ const EditProduct = props => {
};

export default EditProduct;