-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #510 from evershopcommerce/dev
Dev
- Loading branch information
Showing
115 changed files
with
3,117 additions
and
1,875 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nts/admin/oms/shippingSetting/Methods.jsx → ...dmin/checkout/shippingSetting/Methods.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
packages/evershop/src/components/admin/checkout/shippingSetting/PriceBasedPrice.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Field } from '@components/common/form/Field'; | ||
|
||
export default function PriceBasedPrice({ lines }) { | ||
// This is a table with 3 columns: Min Price, Shipping Cost, and Action | ||
const [rows, setRows] = React.useState( | ||
lines.map((line) => ({ | ||
...line, | ||
key: Math.random().toString(36).substring(7) | ||
})) | ||
); | ||
return ( | ||
<div className="my-2"> | ||
<table className="border-collapse divide-y"> | ||
<thead> | ||
<tr> | ||
<th className="border-none">Min Price</th> | ||
<th className="border-none">Shipping Cost</th> | ||
<th className="border-none">Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{rows.map((row, index) => ( | ||
// Create a random key for each row | ||
<tr key={row.key} className="border-divider py-2"> | ||
<td className="border-none"> | ||
<Field | ||
name={`price_based_cost[${index}][min_price]`} | ||
placeholder="Min Price" | ||
type="text" | ||
value={row.minPrice?.value} | ||
validationRules={['notEmpty', 'number']} | ||
/> | ||
</td> | ||
<td className="border-none"> | ||
<Field | ||
name={`price_based_cost[${index}][cost]`} | ||
placeholder="Shipping Cost" | ||
type="text" | ||
value={row.cost?.value} | ||
validationRules={['notEmpty', 'number']} | ||
/> | ||
</td> | ||
<td className="border-none"> | ||
<a | ||
href="#" | ||
onClick={() => { | ||
setRows(rows.filter((r) => r.key !== row.key)); | ||
}} | ||
className="text-critical" | ||
> | ||
Delete | ||
</a> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
<tfoot> | ||
<tr> | ||
<td colSpan="3" className="border-none"> | ||
<a | ||
href="#" | ||
className="text-interactive" | ||
onClick={() => { | ||
setRows([ | ||
...rows, | ||
{ | ||
min_price: '', | ||
shipping_cost: '', | ||
key: Math.random().toString(36).substring(7) | ||
} | ||
]); | ||
}} | ||
> | ||
+ Add Line | ||
</a> | ||
</td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</div> | ||
); | ||
} | ||
|
||
PriceBasedPrice.propTypes = { | ||
lines: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
minPrice: PropTypes.shape({ | ||
value: PropTypes.number.isRequired | ||
}), | ||
cost: PropTypes.shape({ | ||
value: PropTypes.number.isRequired | ||
}) | ||
}) | ||
) | ||
}; | ||
|
||
PriceBasedPrice.defaultProps = { | ||
lines: [] | ||
}; |
Oops, something went wrong.