-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Lose order data when reload the thank you page
- Loading branch information
Showing
4 changed files
with
58 additions
and
20 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,26 @@ | ||
import { ResourceIncluded } from '#reducers/OrderReducer' | ||
import type { Order } from '@commercelayer/sdk' | ||
|
||
type Params = { | ||
order: Order | ||
resourceInclude: ResourceIncluded[] | ||
} | ||
|
||
export default function checkIncludeResources({ | ||
order, | ||
resourceInclude, | ||
}: Params) { | ||
const checkKeys: boolean[] = [] | ||
resourceInclude.forEach((v) => { | ||
const isMultiKey = v.includes('.') | ||
if (isMultiKey) { | ||
const [first] = v.split('.') | ||
const resource = order?.[first as keyof Order] | ||
if (resource === undefined) checkKeys.push(false) | ||
} else { | ||
const resource = order?.[v as keyof Order] | ||
if (resource === undefined) checkKeys.push(false) | ||
} | ||
}) | ||
return checkKeys.length === 0 | ||
} |