Skip to content

Commit

Permalink
Replace Service with Catalog.Product (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
DangoDev authored Mar 22, 2019
1 parent 96282de commit 16f78bc
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 36 deletions.
11 changes: 4 additions & 7 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import '@stencil/state-tunnel';
import {
Collection,
} from 'types/Collection';
import {
Service,
} from 'types/Service';
import {
Connection,
Env,
Expand Down Expand Up @@ -63,13 +60,13 @@ export namespace Components {
'collections': Collection[];
'featured'?: string;
'serviceLink'?: string;
'services': Service[];
'services': Catalog.Product[];
}
interface ManiTunnelAttributes extends StencilHTMLAttributes {
'collections'?: Collection[];
'featured'?: string;
'serviceLink'?: string;
'services'?: Service[];
'services'?: Catalog.Product[];
}

interface ManifoldConnection {
Expand Down Expand Up @@ -126,12 +123,12 @@ export namespace Components {
interface MarketplaceResults {
'featured'?: string;
'serviceLink'?: string;
'services': Service[];
'services': Catalog.Product[];
}
interface MarketplaceResultsAttributes extends StencilHTMLAttributes {
'featured'?: string;
'serviceLink'?: string;
'services'?: Service[];
'services'?: Catalog.Product[];
}

interface MfBadge {}
Expand Down
4 changes: 1 addition & 3 deletions src/components/mani-tunnel/mani-tunnel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Component, Prop } from '@stencil/core';

import { Service } from 'types/Service';
import { Collection } from 'types/Collection';

import Tunnel from '../../data/marketplace';
Expand All @@ -10,7 +8,7 @@ export class ManiTunnel {
@Prop() serviceLink?: string;
@Prop() featured?: string;
@Prop() collections: Collection[] = [];
@Prop() services: Service[];
@Prop() services: Catalog.Product[];

render() {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/mani-tunnel/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| `collections` | -- | | `Collection[]` | `[]` |
| `featured` | `featured` | | `string \| undefined` | `undefined` |
| `serviceLink` | `service-link` | | `string \| undefined` | `undefined` |
| `services` | -- | | `Service[]` | `undefined` |
| `services` | -- | | `Product[]` | `undefined` |


----------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/components/manifold-marketplace/manifold-marketplace.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, Prop, State, Element } from '@stencil/core';
import { Service } from 'types/Service';
import { Collection } from 'types/Collection';

import Tunnel from '../../data/connection';
Expand All @@ -12,7 +11,7 @@ export class ManifoldMarketplace {
@Prop() featured?: string;
@Prop() connection: Connection;
@Prop() collections: Collection[] = [];
@State() services: Service[] = [];
@State() services: Catalog.Product[] = [];

componentWillLoad() {
return fetch(`${this.connection.catalog}/products`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Component, Prop } from '@stencil/core';

import { Service } from 'types/Service';

import Tunnel, { State } from '../../data/marketplace';

@Component({ tag: 'marketplace-collection' })
Expand All @@ -22,7 +19,9 @@ export class Collection {
tagline={this.tagLine}
>
<marketplace-results
services={state.services.filter((s: Service) => this.labels.includes(s.body.label))}
services={state.services.filter((s: Catalog.Product) =>
this.labels.includes(s.body.label)
)}
/>
</service-category>
)}
Expand Down
3 changes: 1 addition & 2 deletions src/components/marketplace-results/marketplace-results.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Component, Prop } from '@stencil/core';
import { Service } from 'types/Service';

@Component({ tag: 'marketplace-results', styleUrl: 'marketplace-results.css' })
export class ManifoldMarketplace {
@Prop() featured?: string;
@Prop() serviceLink?: string;
@Prop() services: Service[];
@Prop() services: Catalog.Product[];

private formatHref(label: string): string {
if (typeof label !== 'string') return '';
Expand Down
2 changes: 1 addition & 1 deletion src/components/marketplace-results/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
| ------------- | -------------- | ----------- | --------------------- | ----------- |
| `featured` | `featured` | | `string \| undefined` | `undefined` |
| `serviceLink` | `service-link` | | `string \| undefined` | `undefined` |
| `services` | -- | | `Service[]` | `undefined` |
| `services` | -- | | `Product[]` | `undefined` |


----------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/data/marketplace.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { createProviderConsumer } from '@stencil/state-tunnel';
import { Service } from 'types/Service';
import { Collection } from 'types/Collection';

export interface State {
collections: Collection[];
services: Service[];
services: Catalog.Product[];
serviceLink?: string;
featured?: string;
}
Expand Down
9 changes: 0 additions & 9 deletions src/types/Service.ts

This file was deleted.

8 changes: 3 additions & 5 deletions src/utils/marketplace.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Service } from 'types/Service';

export type CategoryMap = {
[category: string]: Service[];
[category: string]: Catalog.Product[];
};
export function formatCategoryLabel(tag: string): string {
switch (tag) {
Expand All @@ -14,7 +12,7 @@ export function formatCategoryLabel(tag: string): string {
}
}

export function categories(services?: Service[]): CategoryMap {
export function categories(services?: Catalog.Product[]): CategoryMap {
const categoryMap: CategoryMap = {};

if (Array.isArray(services)) {
Expand All @@ -32,7 +30,7 @@ export function categories(services?: Service[]): CategoryMap {
return categoryMap;
}

export function filteredServices(filter: string, services?: Service[]) {
export function filteredServices(filter: string, services?: Catalog.Product[]) {
if (!filter || !services) {
return [];
}
Expand Down

0 comments on commit 16f78bc

Please sign in to comment.