File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
package/pyconkr-shop/utils Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ import * as R from "remeda" ;
2+
3+ import ShopAPISchema from "@pyconkr-shop/schemas" ;
4+ import { startPortOnePurchase as _startPortOnePurchase } from './portone' ;
5+
6+ namespace ShopAPIUtil {
7+ export const getCustomResponsePattern = ( optionGroup : Pick < ShopAPISchema . OptionGroup , "custom_response_pattern" > ) => {
8+ const pattern = optionGroup . custom_response_pattern ?. trim ( ) ?? "" ;
9+ return R . isString ( pattern ) && ! R . isEmpty ( pattern ) ? new RegExp ( pattern , "g" ) : undefined ;
10+ } ;
11+
12+ export const isOrderProductOptionModifiable = ( optionRel : ShopAPISchema . OrderProductItem [ "options" ] [ number ] ) : boolean => {
13+ if ( ! optionRel . product_option_group . is_custom_response ) return false ;
14+
15+ if ( R . isNullish ( optionRel . product_option_group . response_modifiable_ends_at ) )
16+ return true ;
17+ else if ( new Date ( ) <= new Date ( optionRel . product_option_group . response_modifiable_ends_at ) )
18+ return true ;
19+
20+ return false ;
21+ }
22+
23+ export const startPortOnePurchase = _startPortOnePurchase ;
24+ } ;
25+
26+ export default ShopAPIUtil ;
You can’t perform that action at this time.
0 commit comments