(owner, type, role, isSignyourself)
| 226 | } |
| 227 | }; |
| 228 | export const addPreferenceOpt = (owner, type, role, isSignyourself) => { |
| 229 | const widget = owner?.WidgetPreferences?.find((w) => w.type === type) || {}; |
| 230 | switch (type) { |
| 231 | case "date": { |
| 232 | const signingDate = widget?.isSigningDate ? "today" : widget?.date || ""; |
| 233 | const isReadOnly = widget?.isReadOnly || false; |
| 234 | const isPrefill = role && role === "prefill"; |
| 235 | const format = |
| 236 | widget?.format || selectFormat(owner?.DateFormat) || "MM/DD/YYYY"; |
| 237 | const prefillDate = new Date(); |
| 238 | const response = isPrefill |
| 239 | ? formatDate({ date: prefillDate, format: format }) |
| 240 | : signingDate || ""; |
| 241 | const option = |
| 242 | isSignyourself || isPrefill ? {} : { isReadOnly: isReadOnly }; |
| 243 | return { |
| 244 | response: response, |
| 245 | ...option, |
| 246 | format: widget?.format || "MM/dd/yyyy" |
| 247 | }; |
| 248 | } |
| 249 | default: |
| 250 | return {}; |
| 251 | } |
| 252 | }; |
| 253 | |
| 254 | export function formatDate(dateObj) { |
| 255 | const format = dateObj?.format?.toLowerCase(); |
no test coverage detected