This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
2999e10
commit f676474
Showing
20 changed files
with
684 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { A, EmptyState } from '@commercelayer/app-elements' | ||
|
||
interface Props { | ||
scope?: 'history' | 'userFiltered' | 'presetView' | 'noSKUs' | 'noBundles' | ||
} | ||
|
||
export function ListEmptyState({ scope = 'history' }: Props): JSX.Element { | ||
if (scope === 'presetView') { | ||
return ( | ||
<EmptyState | ||
title='All good here' | ||
description={ | ||
<div> | ||
<p>There are no promotions for the current list.</p> | ||
</div> | ||
} | ||
/> | ||
) | ||
} | ||
|
||
if (scope === 'userFiltered') { | ||
return ( | ||
<EmptyState | ||
title='No promotions found!' | ||
description={ | ||
<div> | ||
<p> | ||
We didn't find any promotions matching the current filters | ||
selection. | ||
</p> | ||
</div> | ||
} | ||
/> | ||
) | ||
} | ||
|
||
if (scope === 'noSKUs') { | ||
return ( | ||
<EmptyState | ||
title='No SKUs found!' | ||
description={ | ||
<div> | ||
<p> | ||
We didn't find any SKU matching the current filters selection. | ||
</p> | ||
</div> | ||
} | ||
/> | ||
) | ||
} | ||
|
||
if (scope === 'noBundles') { | ||
return ( | ||
<EmptyState | ||
title='No bundles found!' | ||
description={ | ||
<div> | ||
<p> | ||
We didn't find any bundle matching the current filters selection. | ||
</p> | ||
</div> | ||
} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<EmptyState | ||
title='No orders yet!' | ||
description={ | ||
<div> | ||
<p>Add an order with the API, or use the CLI.</p> | ||
<A | ||
target='_blank' | ||
href='https://docs.commercelayer.io/core/v/api-reference/orders' | ||
rel='noreferrer' | ||
> | ||
View API reference. | ||
</A> | ||
</div> | ||
} | ||
/> | ||
) | ||
} |
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,34 @@ | ||
import { makePercentageDiscountPromotion } from '#mocks' | ||
import { ResourceListItem, navigateTo } from '@commercelayer/app-elements' | ||
import type { Promotion } from '@commercelayer/sdk' | ||
import { useLocation } from 'wouter' | ||
|
||
interface Props { | ||
resource?: Promotion | ||
isLoading?: boolean | ||
delayMs?: number | ||
} | ||
|
||
export function ListItemPromotion({ | ||
resource = makePercentageDiscountPromotion() as unknown as Promotion, | ||
isLoading, | ||
delayMs | ||
}: Props): JSX.Element { | ||
const [, setLocation] = useLocation() | ||
|
||
return ( | ||
<ResourceListItem | ||
resource={resource} | ||
isLoading={isLoading} | ||
delayMs={delayMs} | ||
tag='a' | ||
{...navigateTo({ | ||
setLocation, | ||
destination: { | ||
app: 'promotions', | ||
resourceId: resource.id | ||
} | ||
})} | ||
/> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import type { FiltersInstructions } from '@commercelayer/app-elements' | ||
|
||
export const instructions: FiltersInstructions = [ | ||
{ | ||
label: 'Status', | ||
type: 'options', | ||
sdk: { | ||
predicate: 'status_in', | ||
defaultOptions: ['prospect', 'acquired', 'repeat'] | ||
}, | ||
render: { | ||
component: 'inputToggleButton', | ||
props: { | ||
mode: 'multi', | ||
options: [ | ||
{ value: 'prospect', label: 'Prospect' }, | ||
{ value: 'acquired', label: 'Acquired' }, | ||
{ value: 'repeat', label: 'Repeat' } | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
label: 'Type', | ||
type: 'options', | ||
sdk: { | ||
predicate: 'password_present', | ||
parseFormValue: (value) => | ||
Array.isArray(value) && value.length === 1 | ||
? value[0] === 'registered' | ||
: undefined | ||
}, | ||
render: { | ||
component: 'inputToggleButton', | ||
props: { | ||
mode: 'multi', | ||
options: [ | ||
{ value: 'guest', label: 'Guest' }, | ||
{ value: 'registered', label: 'Registered' } | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
label: 'Groups', | ||
type: 'options', | ||
sdk: { | ||
predicate: 'customer_group_id_in' | ||
}, | ||
render: { | ||
component: 'inputResourceGroup', | ||
props: { | ||
fieldForLabel: 'name', | ||
fieldForValue: 'id', | ||
resource: 'customer_groups', | ||
searchBy: 'name_cont', | ||
sortBy: { attribute: 'name', direction: 'asc' }, | ||
previewLimit: 5 | ||
} | ||
} | ||
}, | ||
{ | ||
label: 'Tags', | ||
type: 'options', | ||
sdk: { | ||
predicate: 'tags_id_in' | ||
}, | ||
render: { | ||
component: 'inputResourceGroup', | ||
props: { | ||
fieldForLabel: 'name', | ||
fieldForValue: 'id', | ||
resource: 'tags', | ||
searchBy: 'name_cont', | ||
sortBy: { attribute: 'name', direction: 'asc' }, | ||
previewLimit: 5, | ||
showCheckboxIcon: false | ||
} | ||
} | ||
}, | ||
{ | ||
label: 'Search', | ||
type: 'textSearch', | ||
sdk: { | ||
predicate: ['email', 'customer_group_name'].join('_or_') + '_cont' | ||
}, | ||
render: { | ||
component: 'searchBar' | ||
} | ||
} | ||
] |
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,11 @@ | ||
import type { FormFullValues } from '@commercelayer/app-elements/dist/ui/resources/useResourceFilters/types' | ||
|
||
export type ListType = 'all' | ||
|
||
export const presets: Record<ListType, FormFullValues> = { | ||
all: { | ||
customerGroup: [], | ||
status: [], | ||
type: [] | ||
} | ||
} |
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
Oops, something went wrong.