Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: quick order settings #2546

Open
wants to merge 1 commit into
base: feat/quick-order
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/@generated/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as types from './graphql'
* Therefore it is highly recommended to use the babel or swc plugin for production.
*/
const documents = {
'\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n advertisement {\n adId\n adResponseId\n }\n }\n':
'\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\t\tunitMultiplier\n\n isVariantOf {\n productGroupID\n name\n\t\t\tskuVariants {\n\t\t\t\tallVariantsByName\n\t\t\t\tactiveVariations\n\t\t\t\tslugsMap\n\t\t\t\tavailableVariations\n\t\t\t}\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n\t\t\t\tpriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n advertisement {\n adId\n adResponseId\n }\n }\n':
types.ProductSummary_ProductFragmentDoc,
'\n fragment Filter_facets on StoreFacet {\n ... on StoreFacetRange {\n key\n label\n\n min {\n selected\n absolute\n }\n\n max {\n selected\n absolute\n }\n\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n\n __typename\n }\n }\n':
types.Filter_FacetsFragmentDoc,
Expand Down Expand Up @@ -62,7 +62,7 @@ const documents = {
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function gql(
source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n advertisement {\n adId\n adResponseId\n }\n }\n'
source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\t\tunitMultiplier\n\n isVariantOf {\n productGroupID\n name\n\t\t\tskuVariants {\n\t\t\t\tallVariantsByName\n\t\t\t\tactiveVariations\n\t\t\t\tslugsMap\n\t\t\t\tavailableVariations\n\t\t\t}\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n\t\t\t\tpriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n advertisement {\n adId\n adResponseId\n }\n }\n'
): typeof import('./graphql').ProductSummary_ProductFragmentDoc
/**
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
Expand Down
51 changes: 46 additions & 5 deletions packages/core/@generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,9 +1129,19 @@ export type ProductSummary_ProductFragment = {
sku: string
name: string
gtin: string
unitMultiplier: number | null
id: string
brand: { name: string; brandName: string }
isVariantOf: { productGroupID: string; name: string }
isVariantOf: {
productGroupID: string
name: string
skuVariants: {
allVariantsByName: any | null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Why types are any | null ? allVariantsByName and the other fields were not created correctly in the @faststore/api ?

activeVariations: any | null
slugsMap: any | null
availableVariations: any | null
} | null
}
image: Array<{ url: string; alternateName: string }>
offers: {
lowPrice: number
Expand All @@ -1141,6 +1151,7 @@ export type ProductSummary_ProductFragment = {
price: number
listPrice: number
listPriceWithTaxes: number
priceWithTaxes: number
quantity: number
seller: { identifier: string }
}>
Expand Down Expand Up @@ -1440,9 +1451,19 @@ export type ClientManyProductsQueryQuery = {
sku: string
name: string
gtin: string
unitMultiplier: number | null
id: string
brand: { name: string; brandName: string }
isVariantOf: { productGroupID: string; name: string }
isVariantOf: {
productGroupID: string
name: string
skuVariants: {
allVariantsByName: any | null
activeVariations: any | null
slugsMap: any | null
availableVariations: any | null
} | null
}
image: Array<{ url: string; alternateName: string }>
offers: {
lowPrice: number
Expand All @@ -1452,6 +1473,7 @@ export type ClientManyProductsQueryQuery = {
price: number
listPrice: number
listPriceWithTaxes: number
priceWithTaxes: number
quantity: number
seller: { identifier: string }
}>
Expand Down Expand Up @@ -1568,9 +1590,19 @@ export type ClientSearchSuggestionsQueryQuery = {
sku: string
name: string
gtin: string
unitMultiplier: number | null
id: string
brand: { name: string; brandName: string }
isVariantOf: { productGroupID: string; name: string }
isVariantOf: {
productGroupID: string
name: string
skuVariants: {
allVariantsByName: any | null
activeVariations: any | null
slugsMap: any | null
availableVariations: any | null
} | null
}
image: Array<{ url: string; alternateName: string }>
offers: {
lowPrice: number
Expand All @@ -1580,6 +1612,7 @@ export type ClientSearchSuggestionsQueryQuery = {
price: number
listPrice: number
listPriceWithTaxes: number
priceWithTaxes: number
quantity: number
seller: { identifier: string }
}>
Expand Down Expand Up @@ -1691,9 +1724,16 @@ export const ProductSummary_ProductFragmentDoc = new TypedDocumentString(
}
name
gtin
unitMultiplier
isVariantOf {
productGroupID
name
skuVariants {
allVariantsByName
activeVariations
slugsMap
availableVariations
}
}
image {
url
Expand All @@ -1710,6 +1750,7 @@ export const ProductSummary_ProductFragmentDoc = new TypedDocumentString(
price
listPrice
listPriceWithTaxes
priceWithTaxes
quantity
seller {
identifier
Expand Down Expand Up @@ -2087,7 +2128,7 @@ export const SubscribeToNewsletterDocument = {
export const ClientManyProductsQueryDocument = {
__meta__: {
operationName: 'ClientManyProductsQuery',
operationHash: 'ad2eb78cfccb9dbd5a9f2d1e150cc70fea5da99a',
operationHash: 'e7bbfcfafb21aa4bd6da4214051cd8f16aa1327a',
},
} as unknown as TypedDocumentString<
ClientManyProductsQueryQuery,
Expand All @@ -2114,7 +2155,7 @@ export const ClientProductQueryDocument = {
export const ClientSearchSuggestionsQueryDocument = {
__meta__: {
operationName: 'ClientSearchSuggestionsQuery',
operationHash: '4d9f934764d8578aea08673b8ba57e8bf738f534',
operationHash: 'b1f6ae39a92bcb3aab858edfecb283b71ff9fb27',
},
} as unknown as TypedDocumentString<
ClientSearchSuggestionsQueryQuery,
Expand Down
6 changes: 6 additions & 0 deletions packages/core/cms/faststore/sections.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@
"discount_desc",
"score_desc"
]
},
"quickOrder": {
"title": "Enable Quick Order?",
"description": "Allows adding products directly to the cart through search terms, streamlining the purchase.",
"type": "boolean",
"default": false
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/navigation/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function Navbar({
<SearchInput
placeholder={searchInput?.placeholder}
sort={searchInput?.sort}
quickOrder={searchInput?.quickOrder}
/>

<NavbarButtons.Component
Expand All @@ -167,6 +168,7 @@ function Navbar({
buttonTestId="store-input-mobile-button"
onSearchClick={handlerExpandSearch}
sort={searchInput?.sort}
quickOrder={searchInput?.quickOrder}
hidden={!searchExpanded}
aria-hidden={!searchExpanded}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,17 @@ export const fragment = gql(`
}
name
gtin
unitMultiplier

isVariantOf {
productGroupID
name
skuVariants {
allVariantsByName
activeVariations
slugsMap
availableVariations
}
}

image {
Expand All @@ -186,6 +193,7 @@ export const fragment = gql(`
price
listPrice
listPriceWithTaxes
priceWithTaxes
quantity
seller {
identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ import { formatSearchPath } from 'src/sdk/search/formatSearchPath'

interface SearchDropdownProps {
sort: SearchState['sort']
quickOrder?: boolean
[key: string]: any
}

function SearchDropdown({ sort, ...otherProps }: SearchDropdownProps) {
function SearchDropdown({
sort,
quickOrder,
...otherProps
}: SearchDropdownProps) {
const {
values: { onSearchSelection, products, term, terms },
} = useSearch()
Expand Down Expand Up @@ -59,6 +64,7 @@ function SearchDropdown({ sort, ...otherProps }: SearchDropdownProps) {
key={productParsed.id}
product={productParsed}
index={index}
quickOrder={quickOrder}
/>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type SearchInputProps = {
buttonTestId?: string
containerStyle?: CSSProperties
placeholder?: string
quickOrder?: boolean
sort?: string
} & Omit<UISearchInputFieldProps, 'onSubmit'>

Expand All @@ -60,6 +61,7 @@ const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
containerStyle,
sort,
placeholder,
quickOrder = false,
...otherProps
},
ref
Expand Down Expand Up @@ -138,7 +140,10 @@ const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(

{searchDropdownVisible && (
<Suspense fallback={null}>
<SearchDropdown sort={sort as SearchState['sort']} />
<SearchDropdown
sort={sort as SearchState['sort']}
quickOrder={quickOrder}
/>
</Suspense>
)}
</UISearchInput>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ type SearchProductItemProps = {
* Index to generate product link.
*/
index: number
/**
* Enable Quick Order.
*/
quickOrder?: boolean
}

function SearchProductItem({
product,
index,
quickOrder,
...otherProps
}: SearchProductItemProps) {
const {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/components/sections/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface NavbarProps {
searchInput: {
placeholder?: string
sort: string
quickOrder?: boolean
}
signInButton: {
icon: {
Expand Down
Loading