Last active
March 23, 2018 15:36
-
-
Save Mottokrosh/cdc789f246998540387c0c2890e50588 to your computer and use it in GitHub Desktop.
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
// | |
// The FE state: | |
// | |
let queryState = [ | |
{ | |
name: 'keywords', | |
title: 'Keywords', | |
value: 'red' // null|string | |
}, | |
{ | |
name: 'recommendation', | |
title: 'Recommended for you', | |
value: null // null|1 | |
}, | |
{ | |
name: 'group_id', | |
title: 'Pretty flowers', | |
value: null // null|int | |
}, | |
{ | |
name: 'selling_to', | |
title: 'Selling to', | |
value: 'US', // null|string | |
defaultValue: 'US', | |
options: [ | |
{ | |
title: 'Afghanistan', | |
value: 'AF' | |
}, | |
{ | |
title: 'Aland Islands', | |
value: 'AX', | |
} | |
// ... | |
] | |
}, | |
{ | |
name: 'price_from', | |
title: 'From', | |
value: 5 // int|null | |
}, | |
{ | |
name: 'price_to', | |
title: 'To', | |
value: 500 // int|null | |
}, | |
{ | |
name: 'category', | |
title: 'Category', | |
value: 10008, // int|null | |
options: [ | |
{ | |
title: 'Computers', | |
value: 70 | |
}, | |
{ | |
title: 'Clothing', | |
value: 1, | |
options: [ | |
{ | |
title: 'Trousers', | |
value: 10007 | |
}, | |
{ | |
title: 'Dresses', | |
value: 10008 | |
} | |
// ... | |
] | |
}, | |
{ | |
title: 'Health', | |
value: 1765 | |
}, | |
] | |
}, | |
{ | |
name: 'sort', | |
title: 'Sort by', | |
value: 'sellerRateDown', // null|string | |
options: [ | |
{ | |
title: 'Relevance', | |
value: 'sellerRateDown' | |
}, | |
{ | |
title: 'Lowest price', | |
value: 'orignalPriceUp' | |
} | |
// ... | |
] | |
} | |
]; | |
// | |
// For example, that state serializes to: | |
// | |
const queryString = '?keywords=red&selling_to=US&price_from=5&price_to=500&category=10008&sort=sellerRateDown'; | |
// | |
// BE returns the above queryState back with the response as a property | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment