diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-09-27 15:07:34 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-09-27 15:07:34 +0530 |
commit | cc5dd44de3d65e3c2cf189f1516d97c3641549aa (patch) | |
tree | aa0c066f06e79dd081dcdcbee1d57ef4ed7391e7 /src/components/tables/client-table.js | |
parent | af0ef4c190f3967d2def0c65cc3a1fce4511044e (diff) |
created very basic clients list
Diffstat (limited to 'src/components/tables/client-table.js')
-rw-r--r-- | src/components/tables/client-table.js | 99 |
1 files changed, 59 insertions, 40 deletions
diff --git a/src/components/tables/client-table.js b/src/components/tables/client-table.js index fda999d..8249003 100644 --- a/src/components/tables/client-table.js +++ b/src/components/tables/client-table.js @@ -15,8 +15,8 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import './scss/table.scss'; -import { deleteItem } from './../../classes/item'; +import './scss/client-table.scss'; +import { deleteClient } from './../../classes/client'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faPencil, faTrashCan } from '@fortawesome/free-solid-svg-icons' @@ -27,7 +27,7 @@ const ClientTable = (props) => { const handleDelete = (i) => { // TODO: add confirmation prompt - deleteItem(i.Id, handleDelSuccess, handleDelFail); + deleteClient(i.Id, handleDelSuccess, handleDelFail); } const handleDelSuccess = () => { @@ -39,43 +39,62 @@ const ClientTable = (props) => { } return ( - <table> - <thead> - <tr> - <th>S. No</th> - <th>Name</th> - <th>Description</th> - <th>Brand Name</th> - <th>UOM</th> - <th>HSN</th> - <th>Unit Price</th> - <th>GST %</th> - <th>Min Qty</th> - <th>Max Qty</th> - <th></th> - </tr> - </thead> - <tbody> - {props.items && props.items.map((i, id=id+1) => ( - <tr key={id}> - <td>{id+1}</td> - <td className={i.Name === "" ? "empty" : ""}>{i.Name}</td> - <td className={i.Description === "" ? "empty" : ""}>{i.Description}</td> - <td className={i.Brand.Name === "" ? "empty" : ""}>{i.Brand.Name}</td> - <td className={i.UnitOfMeasure === "" ? "empty" : ""}>{i.UnitOfMeasure}</td> - <td className={i.HSN === "" ? "empty" : ""}>{i.HSN}</td> - <td className={i.UnitPrice === 0.0 ? "empty" : ""}>{i.UnitPrice}</td> - <td className={i.GSTPercentage === 0.0 ? "empty" : ""}>{i.GSTPercentage}</td> - <td className={i.MinQuantity === 0.0 ? "empty" : ""}>{i.MinQuantity}</td> - <td className={i.MaxQuantity === 0.0 ? "empty" : ""}>{i.MaxQuantity}</td> - <td className={"buttons"}> - <FontAwesomeIcon icon={faPencil} onClick={() => handleEdit(i)}/> - <FontAwesomeIcon icon={faTrashCan} onClick={() => handleDelete(i)}/> - </td> - </tr> - ))} - </tbody> - </table> + <div className={"client-table"}> + {props.clients && props.clients.map((i, id) => ( + <div key={id} className={"client"}> + <p className={"client-title"}> + <span className={"client-name"}>{i.Name}</span> + <span className={"client-gstin"}> {i.GSTIN}</span> + </p> + + <div className={"paragraph-wrapper"}> + <div className={"contact-details"}> + <p><strong>Contact: </strong>{i.Contact.Name}</p> + <p> + <br/> + Phone Number{i.Contact.Phones.length === 1 ? '' : 's'}: + {i.Contact.Phones.map((j, id) => ` ${j}${id + 1 === i.Contact.Phones.length ? '' : ','}`)} + <br/> + Email Address{i.Contact.Emails.length === 1 ? '' : 'es'}: + {i.Contact.Emails.map((j, id) => ` ${j}${id + 1 === i.Contact.Emails.length ? '' : ','}`)} + <br/> + {i.Contact.Website.length > 0 && <a href={ + `${(i.Contact.Website.startsWith("https://") + || i.Contact.Website.startsWith("http://")) + ? i.Contact.Website : 'https://' + i.Contact.Website}`}>{i.Contact.Website}</a> + } + </p> + + </div> + + <div className={"billing-address"}> + <p><strong>Billing Address: </strong></p> + <p className={"multiline"}>{i.BillingAddress.Text}</p> + <p>{i.BillingAddress.City}, {i.BillingAddress.State} - {i.BillingAddress.PostalCode} ({i.BillingAddress.Country})</p> + </div> + {i.ShippingAddresses.length > 0 && // if billing address != shipping address + JSON.stringify(i.ShippingAddresses[0]) !== JSON.stringify(i.BillingAddress) && + <div className={"shipping-addresses"}> + {i.ShippingAddresses.map(j => + <div className={"shipping-address"}> + <p><strong>Shipping Address: </strong></p> + <p className={"multiline"}>{j.Text}</p> + <p>{j.City}, {j.State} - {j.PostalCode} ({j.Country})</p> + </div> + )} + </div> + } + </div> + + <div className={"buttons"}> + <FontAwesomeIcon icon={faPencil} onClick={() => handleEdit(i)}/> + <FontAwesomeIcon icon={faTrashCan} onClick={() => handleDelete(i)}/> + </div> + + <hr/> + </div> + ))} + </div> ); } |