-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
28 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
85 changes: 64 additions & 21 deletions
85
.../SIL.AppBuilder.Portal.Frontend/src/ui/routes/project-directory/show/details/products.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,40 +1,83 @@ | ||
import * as React from 'react'; | ||
import { compose } from 'recompose'; | ||
import { withData as withOrbit } from 'react-orbitjs'; | ||
import { useOrbit } from 'react-orbitjs'; | ||
import { compareVia, isEmpty } from '@lib/collection'; | ||
|
||
import { ProjectResource, ProductResource } from '@data'; | ||
import { useTranslations } from '@lib/i18n'; | ||
|
||
import { ProjectResource, ProductResource, attributesFor } from '@data'; | ||
|
||
import { withTranslations, i18nProps } from '@lib/i18n'; | ||
import ProductArtifact from '@ui/components/product-artifact'; | ||
|
||
interface IOwnProps { | ||
project: ProjectResource; | ||
products: ProductResource[]; | ||
} | ||
|
||
type IProps = IOwnProps & i18nProps; | ||
|
||
class Products extends React.Component { | ||
render() { | ||
const { products } = this.props; | ||
export default function Products({ project }: IProps) { | ||
const { t } = useTranslations(); | ||
const { dataStore } = useOrbit(); | ||
|
||
return ( | ||
<div data-test-products> | ||
{products.map((product, i) => { | ||
return <ProductArtifact key={product.id} product={product} />; | ||
})} | ||
const products = dataStore.cache.query((q) => q.findRelatedRecords(project, 'products')); | ||
let productList; | ||
if (isEmpty(products)) { | ||
productList = ( | ||
<div | ||
className='flex align-items-center justify-content-center | ||
m-b-lg p-t-md p-b-md round-border-8 thin-border' | ||
> | ||
<span data-test-products-empty-text>{t('project.products.empty')}</span> | ||
</div> | ||
); | ||
} else { | ||
const sortedProducts = products.sort( | ||
compareVia((product) => attributesFor(product).dateCreated, false) | ||
); | ||
productList = sortedProducts.map((product) => <div>{product.id}</div>); | ||
} | ||
return <div className='m-b-lg'>{productList}</div>; | ||
} | ||
|
||
export default compose( | ||
withTranslations, | ||
withOrbit((passedProps: IProps) => { | ||
const { project } = passedProps; | ||
// class Products extends React.Component { | ||
// render() { | ||
// const { products } = this.props; | ||
// const { t } = useTranslations(); | ||
|
||
// let productList; | ||
|
||
// if (isEmpty(products)) { | ||
// productList = ( | ||
// <div | ||
// className='flex align-items-center justify-content-center | ||
// m-b-lg p-t-md p-b-md round-border-8 thin-border' | ||
// > | ||
// <span data-test-products-empty-text>{t('project.products.empty')}</span> | ||
// </div> | ||
// ); | ||
// } else { | ||
// const sortedProducts = products.sort( | ||
// compareVia((product) => attributesFor(product).dateCreated, false) | ||
// ); | ||
// productList = sortedProducts.map((product) => <div></div>); | ||
// } | ||
// return ( | ||
// <div data-test-products> | ||
// {products.map((product, i) => { | ||
// return <ProductArtifact key={product.id} product={product} />; | ||
// })} | ||
// </div> | ||
// ); | ||
// } | ||
// } | ||
|
||
// export default compose( | ||
// withTranslations, | ||
// withOrbit((passedProps: IProps) => { | ||
// const { project } = passedProps; | ||
|
||
return { | ||
products: (q) => q.findRelatedRecords(project, 'products'), | ||
}; | ||
}) | ||
)(Products); | ||
// return { | ||
// products: (q) => q.findRelatedRecords(project, 'products'), | ||
// }; | ||
// }) | ||
// )(Products); |
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