Skip to content

Commit 0e02f9f

Browse files
committed
chore: ShopAPIUtil namespace추가
1 parent 857eaf8 commit 0e02f9f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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;

0 commit comments

Comments
 (0)