MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / addPreferenceOpt

Function addPreferenceOpt

apps/OpenSign/src/utils/widgetUtils.js:228–252  ·  view source on GitHub ↗
(owner, type, role, isSignyourself)

Source from the content-addressed store, hash-verified

226 }
227};
228export 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
254export function formatDate(dateObj) {
255 const format = dateObj?.format?.toLowerCase();

Callers 2

addWidgetOptionsFunction · 0.90
addWidgetSelfsignOptionsFunction · 0.90

Calls 2

selectFormatFunction · 0.90
formatDateFunction · 0.85

Tested by

no test coverage detected