import {PerformanceFull, UserCompact} from "@/types/gwcf"; export const toNotificationParamValue = (value: unknown) => value == null ? "" : String(value); export const buildUserMsgParam = (user: UserCompact): Record => ({ ...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 => ({ 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), });