50 lines
2.6 KiB
TypeScript
50 lines
2.6 KiB
TypeScript
import {PerformanceFull, UserCompact} from "@/types/gwcf";
|
|
import {TMPLAT_PURPOSE, Template} from "@/types/notification";
|
|
|
|
export const PHONE_VERIFICATION_PREVIEW = "인증번호는 [######] 입니다.";
|
|
|
|
export const isPhoneVerificationSupported = (template: Pick<Template, "tmplatTy">) =>
|
|
template.tmplatTy === 10 || template.tmplatTy === 20;
|
|
|
|
export const buildTemplatePreviewBody = (template: Pick<Template, "tmplatBody" | "tmplatPurpose">) =>
|
|
template.tmplatPurpose === TMPLAT_PURPOSE.PHONE_VERIFICATION
|
|
? `${template.tmplatBody}\n${PHONE_VERIFICATION_PREVIEW}`
|
|
: template.tmplatBody;
|
|
|
|
export const getSmsByteLength = (value: string) =>
|
|
Array.from(value).reduce((total, character) => total + (character.charCodeAt(0) > 0x7f ? 2 : 1), 0);
|
|
|
|
export const toNotificationParamValue = (value: unknown) => value == null ? "" : String(value);
|
|
|
|
export const buildUserMsgParam = (user: UserCompact): Record<string, string> => ({
|
|
...Object.fromEntries(
|
|
Object.entries(user.userDetail ?? {}).map(([key, value]) => [key, toNotificationParamValue(value)])
|
|
),
|
|
userId: toNotificationParamValue(user.userId),
|
|
userCmpn: toNotificationParamValue(user.userCmpn),
|
|
userTeam: toNotificationParamValue(user.userTeam),
|
|
userName: toNotificationParamValue(user.userName),
|
|
userRole: toNotificationParamValue(user.userRole),
|
|
});
|
|
|
|
export const buildPerformanceSmsParams = (performance: PerformanceFull): Record<string, string> => ({
|
|
businessType: toNotificationParamValue(performance.businessType),
|
|
performanceGenre: toNotificationParamValue(performance.performanceGenre),
|
|
performanceArea: toNotificationParamValue(performance.performanceArea),
|
|
artistName: toNotificationParamValue(performance.artistName),
|
|
performanceName: toNotificationParamValue(performance.performanceName),
|
|
performanceStartMonth: toNotificationParamValue(performance.performanceStartMonth),
|
|
performanceDtInfo: toNotificationParamValue(performance.performanceDtInfo),
|
|
performanceTimeInfo: toNotificationParamValue(performance.performanceTimeInfo),
|
|
ticketReservationStatus: toNotificationParamValue(performance.ticketReservationStatus),
|
|
ticketReservationMemo: toNotificationParamValue(performance.ticketReservationMemo),
|
|
performanceMemo: toNotificationParamValue(performance.performanceMemo),
|
|
...Object.fromEntries(
|
|
Object.entries(performance.performanceDetail ?? {}).map(([key, value]) => [key, toNotificationParamValue(value)])
|
|
),
|
|
...Object.fromEntries(
|
|
Object.entries(performance.performanceMonitoringSchedule ?? {}).map(([key, value]) => [key, toNotificationParamValue(value)])
|
|
),
|
|
performanceId: toNotificationParamValue(performance.id),
|
|
});
|