-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from bigcommerce/develop
v1.2.0
- Loading branch information
Showing
18 changed files
with
654 additions
and
2,919 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@bigcommerce/storefront-data-hooks", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"main": "index.js", | ||
"repository": "[email protected]:bigcommerce/storefront-data-hooks.git", | ||
"license": "MIT", | ||
|
@@ -43,12 +43,13 @@ | |
"@types/node": "^14.14.3", | ||
"@types/react": "^16.9.53", | ||
"graphql": "^15.4.0", | ||
"next": "^9.5.5", | ||
"next": "^10.0.8", | ||
"prettier": "^2.1.2", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.0.3" | ||
}, | ||
"peerDependencies": { | ||
"next": ">=10", | ||
"react": ">=17" | ||
} | ||
} |
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
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
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,31 @@ | ||
import type { Orders, OrdersHandlers } from '..' | ||
import getCustomerId from '../../operations/get-customer-id' | ||
|
||
const getOrders: OrdersHandlers['getOrders'] = async ({ | ||
res, | ||
body: { customerToken }, | ||
config, | ||
}) => { | ||
let result: Orders = [] | ||
if (customerToken) { | ||
const customerId = customerToken && (await getCustomerId({ customerToken, config })) | ||
|
||
if (!customerId) { | ||
// If the customerToken is invalid, then this request is too | ||
return res.status(404).json({ | ||
data: null, | ||
errors: [{ message: 'Orders not found' }], | ||
}) | ||
} | ||
|
||
result = await config.storeApiFetch(`/v2/orders?customer_id=${customerId}`, { | ||
headers: { | ||
Accept: "application/json", | ||
} | ||
}) | ||
} | ||
|
||
res.status(200).json({ data: result ?? null }) | ||
} | ||
|
||
export default getOrders |
Oops, something went wrong.