-
-
Notifications
You must be signed in to change notification settings - Fork 253
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 #168 from bigcapitalhq/abouhuolia/big-30-create-a-…
…new-warehouse-transfer-broken fix(webapp): warehouses select component
- Loading branch information
Showing
5 changed files
with
38 additions
and
91 deletions.
There are no files selected for viewing
76 changes: 11 additions & 65 deletions
76
packages/webapp/src/components/Warehouses/WarehouseSelect.tsx
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 |
---|---|---|
@@ -1,75 +1,21 @@ | ||
// @ts-nocheck | ||
import React from 'react'; | ||
|
||
import { MenuItem, Button } from '@blueprintjs/core'; | ||
import { FSelect } from '../Forms'; | ||
|
||
/** | ||
* | ||
* @param {*} query | ||
* @param {*} warehouse | ||
* @param {*} _index | ||
* @param {*} exactMatch | ||
* @returns | ||
*/ | ||
const warehouseItemPredicate = (query, warehouse, _index, exactMatch) => { | ||
const normalizedTitle = warehouse.name.toLowerCase(); | ||
const normalizedQuery = query.toLowerCase(); | ||
|
||
if (exactMatch) { | ||
return normalizedTitle === normalizedQuery; | ||
} else { | ||
return ( | ||
`${warehouse.code}. ${normalizedTitle}`.indexOf(normalizedQuery) >= 0 | ||
); | ||
} | ||
}; | ||
|
||
/** | ||
* | ||
* @param {*} film | ||
* @param {*} param1 | ||
* Warehouse select field. | ||
* @param {*} param0 | ||
* @returns | ||
*/ | ||
const warehouseItemRenderer = ( | ||
warehouse, | ||
{ handleClick, modifiers, query }, | ||
) => { | ||
const text = `${warehouse.name}`; | ||
|
||
export function WarehouseSelect({ warehouses, ...rest }) { | ||
return ( | ||
<MenuItem | ||
active={modifiers.active} | ||
disabled={modifiers.disabled} | ||
label={warehouse.code} | ||
key={warehouse.id} | ||
onClick={handleClick} | ||
text={text} | ||
<FSelect | ||
valueAccessor={'id'} | ||
labelAccessor={'code'} | ||
textAccessor={'name'} | ||
popoverProps={{ minimal: true, usePortal: true, inline: false }} | ||
{...rest} | ||
items={warehouses} | ||
/> | ||
); | ||
}; | ||
|
||
const warehouseSelectProps = { | ||
itemPredicate: warehouseItemPredicate, | ||
itemRenderer: warehouseItemRenderer, | ||
valueAccessor: 'id', | ||
labelAccessor: 'name', | ||
}; | ||
|
||
/** | ||
* | ||
* @param {*} param0 | ||
* @returns | ||
*/ | ||
export function WarehouseSelect({ warehouses, ...rest }) { | ||
return <FSelect {...warehouseSelectProps} {...rest} items={warehouses} />; | ||
} | ||
|
||
/** | ||
* | ||
* @param {*} param0 | ||
* @returns | ||
*/ | ||
export function WarehouseSelectButton({ label, ...rest }) { | ||
return <Button text={label} />; | ||
} | ||
} |
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
de56946
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
bigcapital-webapp – ./
bigcapital-webapp-bigcapital.vercel.app
app.bigcapital.ly
bigcapital-webapp-git-main-bigcapital.vercel.app
bigcapital-webapp.vercel.app