diff --git a/build/admin-rtl.css b/build/admin-rtl.css index 8f9dbf0df..a003764f2 100644 --- a/build/admin-rtl.css +++ b/build/admin-rtl.css @@ -3,6 +3,6 @@ .formipay-order-timeline h3{color:#1e1e1e;font-size:16px;font-weight:600;margin:0 0 16px}.timeline-progress{justify-content:space-between;margin-bottom:24px}.timeline-progress,.timeline-step{align-items:center;display:flex;position:relative}.timeline-step{flex:1;flex-direction:column;gap:8px;z-index:1}.timeline-dot{background:#e0e0e0;border:2px solid #c3c4c7;border-radius:50%;height:24px;position:relative;width:24px}.timeline-step.completed .timeline-dot{background:#2271b1;border-color:#2271b1}.timeline-step.completed .timeline-dot:after{background:#fff;border-radius:50%;content:"";height:8px;right:50%;position:absolute;top:50%;transform:translate(50%,-50%);width:8px}.timeline-line{background:#e0e0e0;height:2px;right:50%;position:absolute;top:12px;width:100%;z-index:-1}.timeline-step.completed .timeline-line{background:#2271b1}.timeline-label{color:#646970;font-size:10px;font-weight:600;text-align:center;text-transform:uppercase}.timeline-events ul{list-style:none;margin:0;padding:0}.timeline-events li{border-bottom:1px solid #f0f0f1;display:grid;gap:8px;grid-template-columns:1fr auto;padding:12px 0}.timeline-events li:last-child{border-bottom:none}.event-status{color:#1e1e1e;font-size:13px;font-weight:600}.event-date{color:#646970;font-size:11px;text-align:left}.event-note{color:#646970;font-size:12px;grid-column:1/-1;margin-top:4px}.no-events{color:#646970;font-size:13px;padding:20px 0;text-align:center} .formipay-notification-log h3{align-items:center;color:#1e1e1e;display:flex;font-size:16px;font-weight:600;gap:8px;margin:0 0 16px}.formipay-notification-log svg{fill:#1e1e1e}.no-logs{color:#646970;font-size:13px;padding:20px 0;text-align:center}.notification-list{list-style:none;margin:0;padding:0}.notification-item{background:#f6f7f7;border:1px solid #e0e0e0;border-radius:4px;display:flex;gap:12px;margin-bottom:8px;padding:12px}.notification-icon{align-items:center;background:#fff;border-radius:50%;display:flex;flex-shrink:0;height:36px;justify-content:center;width:36px}.notification-icon svg{fill:#1e1e1e}.notification-content{flex:1;min-width:0}.notification-header{align-items:center;display:flex;justify-content:space-between;margin-bottom:4px}.notification-type{color:#2271b1;font-size:10px;font-weight:700;text-transform:uppercase}.notification-status{border-radius:10px;font-size:10px;font-weight:600;padding:2px 6px}.notification-item.sent .notification-status{background:#e7f7ed;color:#28a745}.notification-item.failed .notification-status{background:#fbeaea;color:#dc3545}.notification-item.pending .notification-status{background:#fff8e5;color:#f0ad4e}.notification-details{display:flex;flex-direction:column;gap:2px}.notification-details strong{color:#1e1e1e;font-size:13px}.notification-date,.notification-recipient{color:#646970;font-size:11px}.notification-date{margin-top:4px} .formipay-order-detail{background:#f6f7f7;display:flex;flex-direction:column;height:100%}.formipay-detail-header{align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;display:flex;gap:16px;justify-content:space-between;padding:16px 20px}.formipay-detail-header h1{flex:1;font-size:20px;font-weight:600;margin:0}.header-actions{display:flex;gap:8px}.formipay-detail-content{display:grid;gap:20px;grid-template-columns:2fr 1fr;overflow-y:auto;padding:20px}.formipay-detail-main,.formipay-detail-sidebar{display:flex;flex-direction:column;gap:20px}.formipay-detail-card{background:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:20px}.formipay-detail-card h3{color:#1e1e1e;font-size:16px;font-weight:600;margin:0 0 16px}.detail-list{display:grid;gap:16px;grid-template-columns:repeat(2,1fr)}.detail-list>div{display:flex;flex-direction:column}.detail-list dt{color:#646970;font-size:12px;font-weight:600;margin-bottom:4px}.detail-list dd{align-items:center;color:#1e1e1e;display:flex;font-size:14px;gap:8px}.detail-list dd .components-select-control{flex:1}.items-table{border-collapse:collapse;width:100%}.items-table td,.items-table th{border-bottom:1px solid #f0f0f1;padding:10px;text-align:right}.items-table th{color:#646970;font-size:12px;font-weight:600;text-transform:uppercase}.items-table td{font-size:13px}.items-table small{color:#646970;display:block;font-size:11px}.items-table tfoot td{border-bottom:none;border-top:2px solid #1e1e1e;padding-top:16px}.customer-info{display:grid;gap:12px;grid-template-columns:1fr}.customer-info>div{display:flex;flex-direction:column}.customer-info dt{color:#646970;font-size:11px;font-weight:600;margin-bottom:2px}.customer-info dd{color:#1e1e1e;font-size:13px}.no-data{color:#646970;font-size:13px}.formipay-error,.formipay-loading{align-items:center;display:flex;flex-direction:column;gap:16px;justify-content:center;padding:60px 20px}.formipay-error p{color:#646970;margin:0} -.formipay-data-table-empty,.formipay-data-table-loading{padding:40px;text-align:center}.formipay-data-table{margin-top:20px}.formipay-data-table thead th{font-weight:600;padding:12px 10px}.formipay-data-table tbody td{padding:10px}.formipay-data-table tbody tr.is-clickable{cursor:pointer}.formipay-data-table tbody tr.is-clickable:hover{background-color:#f0f0f1} +.formipay-data-table-wrapper{margin:20px 0}.formipay-table-toolbar{align-items:center;display:flex;flex-wrap:wrap;gap:12px;margin-bottom:16px}.formipay-table-search{flex-grow:1;max-width:300px}.formipay-table-toolbar .components-select-control{min-width:150px}.formipay-filter-tabs{border-bottom:1px solid #ddd;display:flex;gap:4px;margin-bottom:16px}.formipay-filter-tabs .filter-tab{background:transparent;border:none;border-bottom:3px solid transparent;color:#646970;cursor:pointer;font-size:13px;padding:8px 16px;transition:all .2s}.formipay-filter-tabs .filter-tab:hover{background:#f0f0f1;color:#135e96}.formipay-filter-tabs .filter-tab.active{border-bottom-color:#135e96;color:#135e96;font-weight:600}.formipay-filter-tabs .filter-tab .count{background:#dcdcde;border-radius:10px;display:inline-block;font-size:11px;line-height:1.4;margin-right:6px;min-width:18px;padding:2px 6px}.formipay-filter-tabs .filter-tab.active .count{background:#135e96;color:#fff}.formipay-table-container{background:#fff;border:1px solid #c3c4c7;box-shadow:0 1px 1px rgba(0,0,0,.04)}.formipay-table-loading{padding:60px;text-align:center}.formipay-table-empty{color:#646970;padding:40px;text-align:center}.formipay-table{border-collapse:collapse;width:100%}.formipay-table thead th{background:#f6f7f7;border-bottom:1px solid #c3c4c7;font-weight:600;padding:12px 10px;text-align:right}.formipay-table tbody td{border-bottom:1px solid #c3c4c7;padding:10px}.formipay-table tbody tr:last-child td{border-bottom:none}.formipay-table tbody tr:hover{background-color:#f0f0f1}.formipay-table .column-select{text-align:center;width:40px}.formipay-table tbody td:first-child input[type=checkbox]{margin:0}.formipay-table .column-actions{width:200px}.formipay-table .row-actions{display:none;visibility:hidden}.formipay-table tbody tr:hover .row-actions{display:block;visibility:visible}.formipay-table .row-actions .button-link,.formipay-table .row-actions a{color:#a7aaad;cursor:pointer;text-decoration:none}.formipay-table .row-actions .button-link:hover,.formipay-table .row-actions a:hover{color:#135e96}.formipay-table .row-actions .delete{color:#b32d2e}.formipay-table .row-actions .delete:hover{color:#d63638}.formipay-table .status-label{border-radius:4px;display:inline-block;font-size:12px;font-weight:500;padding:4px 8px}.formipay-table .status-label.publish{background:#edfaef;color:#007017}.formipay-table .status-label.draft{background:#f0f0f1;color:#646970}.formipay-table .status-label.pending{background:#fff8e5;color:#d63638}.formipay-table input.formipay-form-shortcode{background:#f6f7f7;border:1px solid #8c8f94;border-radius:4px;color:#646970;font-family:monospace;font-size:12px;min-width:150px;padding:4px 8px}.formipay-table button.copy-shortcode{align-items:center;background:#fff;border:1px solid #8c8f94;border-radius:4px;cursor:pointer;display:inline-flex;gap:4px;margin-right:4px;padding:4px 8px}.formipay-table button.copy-shortcode:hover{background:#f6f7f7}.formipay-table button.copy-shortcode svg{height:16px;width:16px}.formipay-table-pagination{align-items:center;background:#fff;border:1px solid #c3c4c7;border-top:none;display:flex;justify-content:space-between;padding:12px 16px}.formipay-table-pagination .pagination-info{color:#646970;font-size:13px}.formipay-table-pagination .pagination-controls{align-items:center;display:flex;gap:8px}.formipay-table-pagination .page-info{color:#646970;font-size:13px;padding:0 8px}.formipay-table-pagination .components-select-control{min-width:80px}.formipay-modal-actions{display:flex;gap:12px;justify-content:flex-end;margin-top:20px}.formipay-table thead th.sorted{padding-left:20px;position:relative}.formipay-table thead th .sort-indicator{color:#135e96;position:absolute;left:8px;top:50%;transform:translateY(-50%)} .formipay-page-header{align-items:center;display:flex;justify-content:space-between;margin-bottom:20px}.formipay-page-header h1{font-size:23px;font-weight:400;margin:0}.status-badge{border-radius:4px;display:inline-block;font-size:12px;font-weight:500;padding:4px 8px}.status-badge.status-active,.status-badge.status-publish{background-color:#edfaef;color:#00a32a}.status-badge.status-draft,.status-badge.status-inactive{background-color:#f0f0f1;color:#646970}.status-badge.status-expired{background-color:#f6f7f7;color:#d63638}code{background-color:#f0f0f1;border-radius:3px;font-family:monospace;font-size:13px;padding:2px 6px} .formipay-variation-table{border-collapse:collapse;margin-top:20px;width:100%}.formipay-variation-table thead th{border-bottom:2px solid #1e1e1e;color:#1e1e1e;font-size:13px;font-weight:600;padding:12px;text-align:right}.formipay-variation-table tbody td{border-bottom:1px solid #f0f0f1;padding:12px}.variation-row{background:#fff}.variation-name{gap:8px}.toggle-expand,.variation-name{align-items:center;display:flex}.toggle-expand{background:transparent;border:none;border-radius:2px;cursor:pointer;height:24px;justify-content:center;padding:0;width:24px}.toggle-expand:hover{background:#f0f0f1}.toggle-expand svg{fill:#646970}.variation-name strong{color:#1e1e1e;font-size:13px}.price-cell,.variation-stock,.variation-weight{min-width:120px}.price-cell input,.variation-stock input,.variation-weight input{border:1px solid #8c8f94;border-radius:2px;font-size:13px;padding:6px 8px;width:100%}.variation-stock .components-base-control,.variation-weight .components-base-control{margin:0}.variation-actions{min-width:100px}.variation-details-row{background:#f9f9f9}.variation-details-row td{padding:0}.inner-table{border-collapse:collapse;margin:0;width:100%}.inner-table thead{display:none}.inner-table td{border-bottom:1px solid #f0f0f1;padding:8px 12px}.inner-table tr:last-child td{border-bottom:none}.inner-table input[type=number]{border:1px solid #8c8f94;border-radius:2px;font-size:12px;padding:6px 8px;width:100%}.currency-name{color:#1e1e1e;font-size:12px;font-weight:600}.required{color:#dc3545;margin-right:4px} diff --git a/build/admin.asset.php b/build/admin.asset.php index b9bd00146..8ec749820 100644 --- a/build/admin.asset.php +++ b/build/admin.asset.php @@ -1 +1 @@ - array('react', 'wp-components', 'wp-element', 'wp-i18n', 'wp-icons/build/arrow-left', 'wp-icons/build/bell', 'wp-icons/build/eye-closed', 'wp-icons/build/eye-opened', 'wp-icons/build/list', 'wp-icons/build/message', 'wp-icons/build/minus', 'wp-icons/build/plus', 'wp-icons/build/trash', 'wp-icons/build/visible'), 'version' => 'a62306d2a4d673c06ceb'); + array('react', 'wp-components', 'wp-element', 'wp-i18n', 'wp-icons/build/arrow-left', 'wp-icons/build/bell', 'wp-icons/build/eye-closed', 'wp-icons/build/eye-opened', 'wp-icons/build/list', 'wp-icons/build/message', 'wp-icons/build/minus', 'wp-icons/build/plus', 'wp-icons/build/trash', 'wp-icons/build/visible'), 'version' => '164b137f81dde0451242'); diff --git a/build/admin.css b/build/admin.css index 8a60a1481..46f99de01 100644 --- a/build/admin.css +++ b/build/admin.css @@ -3,6 +3,6 @@ .formipay-order-timeline h3{color:#1e1e1e;font-size:16px;font-weight:600;margin:0 0 16px}.timeline-progress{justify-content:space-between;margin-bottom:24px}.timeline-progress,.timeline-step{align-items:center;display:flex;position:relative}.timeline-step{flex:1;flex-direction:column;gap:8px;z-index:1}.timeline-dot{background:#e0e0e0;border:2px solid #c3c4c7;border-radius:50%;height:24px;position:relative;width:24px}.timeline-step.completed .timeline-dot{background:#2271b1;border-color:#2271b1}.timeline-step.completed .timeline-dot:after{background:#fff;border-radius:50%;content:"";height:8px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:8px}.timeline-line{background:#e0e0e0;height:2px;left:50%;position:absolute;top:12px;width:100%;z-index:-1}.timeline-step.completed .timeline-line{background:#2271b1}.timeline-label{color:#646970;font-size:10px;font-weight:600;text-align:center;text-transform:uppercase}.timeline-events ul{list-style:none;margin:0;padding:0}.timeline-events li{border-bottom:1px solid #f0f0f1;display:grid;gap:8px;grid-template-columns:1fr auto;padding:12px 0}.timeline-events li:last-child{border-bottom:none}.event-status{color:#1e1e1e;font-size:13px;font-weight:600}.event-date{color:#646970;font-size:11px;text-align:right}.event-note{color:#646970;font-size:12px;grid-column:1/-1;margin-top:4px}.no-events{color:#646970;font-size:13px;padding:20px 0;text-align:center} .formipay-notification-log h3{align-items:center;color:#1e1e1e;display:flex;font-size:16px;font-weight:600;gap:8px;margin:0 0 16px}.formipay-notification-log svg{fill:#1e1e1e}.no-logs{color:#646970;font-size:13px;padding:20px 0;text-align:center}.notification-list{list-style:none;margin:0;padding:0}.notification-item{background:#f6f7f7;border:1px solid #e0e0e0;border-radius:4px;display:flex;gap:12px;margin-bottom:8px;padding:12px}.notification-icon{align-items:center;background:#fff;border-radius:50%;display:flex;flex-shrink:0;height:36px;justify-content:center;width:36px}.notification-icon svg{fill:#1e1e1e}.notification-content{flex:1;min-width:0}.notification-header{align-items:center;display:flex;justify-content:space-between;margin-bottom:4px}.notification-type{color:#2271b1;font-size:10px;font-weight:700;text-transform:uppercase}.notification-status{border-radius:10px;font-size:10px;font-weight:600;padding:2px 6px}.notification-item.sent .notification-status{background:#e7f7ed;color:#28a745}.notification-item.failed .notification-status{background:#fbeaea;color:#dc3545}.notification-item.pending .notification-status{background:#fff8e5;color:#f0ad4e}.notification-details{display:flex;flex-direction:column;gap:2px}.notification-details strong{color:#1e1e1e;font-size:13px}.notification-date,.notification-recipient{color:#646970;font-size:11px}.notification-date{margin-top:4px} .formipay-order-detail{background:#f6f7f7;display:flex;flex-direction:column;height:100%}.formipay-detail-header{align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;display:flex;gap:16px;justify-content:space-between;padding:16px 20px}.formipay-detail-header h1{flex:1;font-size:20px;font-weight:600;margin:0}.header-actions{display:flex;gap:8px}.formipay-detail-content{display:grid;gap:20px;grid-template-columns:2fr 1fr;overflow-y:auto;padding:20px}.formipay-detail-main,.formipay-detail-sidebar{display:flex;flex-direction:column;gap:20px}.formipay-detail-card{background:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:20px}.formipay-detail-card h3{color:#1e1e1e;font-size:16px;font-weight:600;margin:0 0 16px}.detail-list{display:grid;gap:16px;grid-template-columns:repeat(2,1fr)}.detail-list>div{display:flex;flex-direction:column}.detail-list dt{color:#646970;font-size:12px;font-weight:600;margin-bottom:4px}.detail-list dd{align-items:center;color:#1e1e1e;display:flex;font-size:14px;gap:8px}.detail-list dd .components-select-control{flex:1}.items-table{border-collapse:collapse;width:100%}.items-table td,.items-table th{border-bottom:1px solid #f0f0f1;padding:10px;text-align:left}.items-table th{color:#646970;font-size:12px;font-weight:600;text-transform:uppercase}.items-table td{font-size:13px}.items-table small{color:#646970;display:block;font-size:11px}.items-table tfoot td{border-bottom:none;border-top:2px solid #1e1e1e;padding-top:16px}.customer-info{display:grid;gap:12px;grid-template-columns:1fr}.customer-info>div{display:flex;flex-direction:column}.customer-info dt{color:#646970;font-size:11px;font-weight:600;margin-bottom:2px}.customer-info dd{color:#1e1e1e;font-size:13px}.no-data{color:#646970;font-size:13px}.formipay-error,.formipay-loading{align-items:center;display:flex;flex-direction:column;gap:16px;justify-content:center;padding:60px 20px}.formipay-error p{color:#646970;margin:0} -.formipay-data-table-empty,.formipay-data-table-loading{padding:40px;text-align:center}.formipay-data-table{margin-top:20px}.formipay-data-table thead th{font-weight:600;padding:12px 10px}.formipay-data-table tbody td{padding:10px}.formipay-data-table tbody tr.is-clickable{cursor:pointer}.formipay-data-table tbody tr.is-clickable:hover{background-color:#f0f0f1} +.formipay-data-table-wrapper{margin:20px 0}.formipay-table-toolbar{align-items:center;display:flex;flex-wrap:wrap;gap:12px;margin-bottom:16px}.formipay-table-search{flex-grow:1;max-width:300px}.formipay-table-toolbar .components-select-control{min-width:150px}.formipay-filter-tabs{border-bottom:1px solid #ddd;display:flex;gap:4px;margin-bottom:16px}.formipay-filter-tabs .filter-tab{background:transparent;border:none;border-bottom:3px solid transparent;color:#646970;cursor:pointer;font-size:13px;padding:8px 16px;transition:all .2s}.formipay-filter-tabs .filter-tab:hover{background:#f0f0f1;color:#135e96}.formipay-filter-tabs .filter-tab.active{border-bottom-color:#135e96;color:#135e96;font-weight:600}.formipay-filter-tabs .filter-tab .count{background:#dcdcde;border-radius:10px;display:inline-block;font-size:11px;line-height:1.4;margin-left:6px;min-width:18px;padding:2px 6px}.formipay-filter-tabs .filter-tab.active .count{background:#135e96;color:#fff}.formipay-table-container{background:#fff;border:1px solid #c3c4c7;box-shadow:0 1px 1px rgba(0,0,0,.04)}.formipay-table-loading{padding:60px;text-align:center}.formipay-table-empty{color:#646970;padding:40px;text-align:center}.formipay-table{border-collapse:collapse;width:100%}.formipay-table thead th{background:#f6f7f7;border-bottom:1px solid #c3c4c7;font-weight:600;padding:12px 10px;text-align:left}.formipay-table tbody td{border-bottom:1px solid #c3c4c7;padding:10px}.formipay-table tbody tr:last-child td{border-bottom:none}.formipay-table tbody tr:hover{background-color:#f0f0f1}.formipay-table .column-select{text-align:center;width:40px}.formipay-table tbody td:first-child input[type=checkbox]{margin:0}.formipay-table .column-actions{width:200px}.formipay-table .row-actions{display:none;visibility:hidden}.formipay-table tbody tr:hover .row-actions{display:block;visibility:visible}.formipay-table .row-actions .button-link,.formipay-table .row-actions a{color:#a7aaad;cursor:pointer;text-decoration:none}.formipay-table .row-actions .button-link:hover,.formipay-table .row-actions a:hover{color:#135e96}.formipay-table .row-actions .delete{color:#b32d2e}.formipay-table .row-actions .delete:hover{color:#d63638}.formipay-table .status-label{border-radius:4px;display:inline-block;font-size:12px;font-weight:500;padding:4px 8px}.formipay-table .status-label.publish{background:#edfaef;color:#007017}.formipay-table .status-label.draft{background:#f0f0f1;color:#646970}.formipay-table .status-label.pending{background:#fff8e5;color:#d63638}.formipay-table input.formipay-form-shortcode{background:#f6f7f7;border:1px solid #8c8f94;border-radius:4px;color:#646970;font-family:monospace;font-size:12px;min-width:150px;padding:4px 8px}.formipay-table button.copy-shortcode{align-items:center;background:#fff;border:1px solid #8c8f94;border-radius:4px;cursor:pointer;display:inline-flex;gap:4px;margin-left:4px;padding:4px 8px}.formipay-table button.copy-shortcode:hover{background:#f6f7f7}.formipay-table button.copy-shortcode svg{height:16px;width:16px}.formipay-table-pagination{align-items:center;background:#fff;border:1px solid #c3c4c7;border-top:none;display:flex;justify-content:space-between;padding:12px 16px}.formipay-table-pagination .pagination-info{color:#646970;font-size:13px}.formipay-table-pagination .pagination-controls{align-items:center;display:flex;gap:8px}.formipay-table-pagination .page-info{color:#646970;font-size:13px;padding:0 8px}.formipay-table-pagination .components-select-control{min-width:80px}.formipay-modal-actions{display:flex;gap:12px;justify-content:flex-end;margin-top:20px}.formipay-table thead th.sorted{padding-right:20px;position:relative}.formipay-table thead th .sort-indicator{color:#135e96;position:absolute;right:8px;top:50%;transform:translateY(-50%)} .formipay-page-header{align-items:center;display:flex;justify-content:space-between;margin-bottom:20px}.formipay-page-header h1{font-size:23px;font-weight:400;margin:0}.status-badge{border-radius:4px;display:inline-block;font-size:12px;font-weight:500;padding:4px 8px}.status-badge.status-active,.status-badge.status-publish{background-color:#edfaef;color:#00a32a}.status-badge.status-draft,.status-badge.status-inactive{background-color:#f0f0f1;color:#646970}.status-badge.status-expired{background-color:#f6f7f7;color:#d63638}code{background-color:#f0f0f1;border-radius:3px;font-family:monospace;font-size:13px;padding:2px 6px} .formipay-variation-table{border-collapse:collapse;margin-top:20px;width:100%}.formipay-variation-table thead th{border-bottom:2px solid #1e1e1e;color:#1e1e1e;font-size:13px;font-weight:600;padding:12px;text-align:left}.formipay-variation-table tbody td{border-bottom:1px solid #f0f0f1;padding:12px}.variation-row{background:#fff}.variation-name{gap:8px}.toggle-expand,.variation-name{align-items:center;display:flex}.toggle-expand{background:transparent;border:none;border-radius:2px;cursor:pointer;height:24px;justify-content:center;padding:0;width:24px}.toggle-expand:hover{background:#f0f0f1}.toggle-expand svg{fill:#646970}.variation-name strong{color:#1e1e1e;font-size:13px}.price-cell,.variation-stock,.variation-weight{min-width:120px}.price-cell input,.variation-stock input,.variation-weight input{border:1px solid #8c8f94;border-radius:2px;font-size:13px;padding:6px 8px;width:100%}.variation-stock .components-base-control,.variation-weight .components-base-control{margin:0}.variation-actions{min-width:100px}.variation-details-row{background:#f9f9f9}.variation-details-row td{padding:0}.inner-table{border-collapse:collapse;margin:0;width:100%}.inner-table thead{display:none}.inner-table td{border-bottom:1px solid #f0f0f1;padding:8px 12px}.inner-table tr:last-child td{border-bottom:none}.inner-table input[type=number]{border:1px solid #8c8f94;border-radius:2px;font-size:12px;padding:6px 8px;width:100%}.currency-name{color:#1e1e1e;font-size:12px;font-weight:600}.required{color:#dc3545;margin-left:4px} diff --git a/build/admin.js b/build/admin.js index e48e19c4e..0bc890956 100644 --- a/build/admin.js +++ b/build/admin.js @@ -1 +1 @@ -(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,a=window.wp.element,r=window.wp.i18n,n=window.wp.components,l=(0,a.forwardRef)(function({icon:e,size:t=24,...r},n){return(0,a.cloneElement)(e,{width:t,height:t,...r,ref:n})}),o=window.wp["icons/build/list"];var i=e.n(o);const c=window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",s=window.formipayAdmin?.nonce||"";async function m(e,t={}){const a=new FormData;a.append("action",e),a.append("_wpnonce",s),Object.keys(t).forEach(e=>{"object"==typeof t[e]?a.append(e,JSON.stringify(t[e])):a.append(e,t[e])}),console.log(`[AJAX] Sending request: ${e}`,{nonce:s,data:t});try{const t=await fetch(c,{method:"POST",credentials:"same-origin",body:a});console.log(`[AJAX] Response status: ${e}`,t.status);const r=await t.json();if(console.log(`[AJAX] Response data: ${e}`,r),!t.ok||!1===r.success){const e=r.data?.message||r.message||"Request failed";throw new Error(e)}return r}catch(t){throw console.error(`AJAX error [${e}]:`,t),t}}window.formipayAdmin;const d=window.wp["icons/build/visible"];var p=e.n(d);const u={"on-hold":"#f0ad4e","payment-confirm":"#17a2b8","in-progress":"#17a2b8",shipping:"#6c757d",completed:"#28a745",failed:"#dc3545",refunded:"#6c757d",cancelled:"#dc3545"},f={"on-hold":(0,r.__)("On Hold","formipay"),"payment-confirm":(0,r.__)("Payment Confirmed","formipay"),"in-progress":(0,r.__)("In Progress","formipay"),shipping:(0,r.__)("Shipping","formipay"),completed:(0,r.__)("Completed","formipay"),failed:(0,r.__)("Failed","formipay"),refunded:(0,r.__)("Refunded","formipay"),cancelled:(0,r.__)("Cancelled","formipay")};function y({order:e,onSelect:a}){const n=u[e.status]||"#6c757d",o=f[e.status]||e.status,i=(e=>{if(e.form_data){const t=Object.values(e.form_data).find(e=>e.name&&e.name.includes("name"));return t?.value||"-"}return"-"})(e);return(0,t.createElement)("tr",{className:"formipay-order-item"},(0,t.createElement)("td",null,(0,t.createElement)("strong",null,"#",e.id)),(0,t.createElement)("td",null,(c=e.created_date)?new Date(c).toLocaleDateString():"-"),(0,t.createElement)("td",null,"-"!==i?i:(0,t.createElement)("em",null,"Unknown")),(0,t.createElement)("td",null,(0,t.createElement)("strong",null,e.total_formatted||e.total)),(0,t.createElement)("td",null,(0,t.createElement)("span",{className:"status-badge",style:{backgroundColor:n}},o)),(0,t.createElement)("td",null,(0,t.createElement)("button",{type:"button",className:"button button-small",onClick:a},(0,t.createElement)(l,{icon:p()(),size:16}),(0,r.__)("View","formipay"))));var c}function _({onSelectOrder:e}){const[o,c]=(0,a.useState)([]),[s,d]=(0,a.useState)(!0),[p,u]=(0,a.useState)(0),[f,_]=(0,a.useState)({keyword:"",status:"",date_from:"",date_to:""}),[E,g]=(0,a.useState)({limit:20,offset:0}),b=(0,a.useCallback)(()=>{d(!0),((e={})=>m("formipay-tabledata-orders",e))({keyword:f.keyword,status:f.status,date_from:f.date_from,date_to:f.date_to,limit:E.limit,offset:E.offset}).then(e=>{e.data&&(c(e.data.results||[]),u(e.data.total||0))}).catch(e=>{console.error("Load orders error:",e)}).finally(()=>{d(!1)})},[f,E]);(0,a.useEffect)(()=>{b()},[b]);const h=(e,t)=>{_({...f,[e]:t}),g({...E,offset:0})},v=e=>{g({...E,offset:e})},w={"":(0,r.__)("All Statuses","formipay"),"on-hold":(0,r.__)("On Hold","formipay"),"payment-confirm":(0,r.__)("Payment Confirmed","formipay"),"in-progress":(0,r.__)("In Progress","formipay"),shipping:(0,r.__)("Shipping","formipay"),completed:(0,r.__)("Completed","formipay"),failed:(0,r.__)("Failed","formipay"),refunded:(0,r.__)("Refunded","formipay"),cancelled:(0,r.__)("Cancelled","formipay")},N=Math.ceil(p/E.limit),k=Math.floor(E.offset/E.limit)+1;return(0,t.createElement)("div",{className:"formipay-order-list"},(0,t.createElement)("div",{className:"formipay-orders-header"},(0,t.createElement)("h2",null,(0,t.createElement)(l,{icon:i()()}),(0,r.__)("Orders","formipay")),(0,t.createElement)("span",{className:"order-count"},p," ",(0,r.__)("orders","formipay"))),(0,t.createElement)("div",{className:"formipay-orders-filters"},(0,t.createElement)(n.SearchControl,{value:f.keyword,onChange:e=>{h("keyword",e)},placeholder:(0,r.__)("Search by order ID, customer name, email...","formipay")}),(0,t.createElement)(n.SelectControl,{value:f.status,options:Object.entries(w).map(([e,t])=>({value:e,label:t})),onChange:e=>h("status",e),label:(0,r.__)("Status","formipay")}),(0,t.createElement)("input",{type:"date",value:f.date_from,onChange:e=>h("date_from",e.target.value),className:"formipay-date-input"}),(0,t.createElement)("input",{type:"date",value:f.date_to,onChange:e=>h("date_to",e.target.value),className:"formipay-date-input"}),(f.keyword||f.status||f.date_from||f.date_to)&&(0,t.createElement)(n.Button,{variant:"secondary",onClick:()=>{_({keyword:"",status:"",date_from:"",date_to:""}),g({limit:20,offset:0})}},(0,r.__)("Clear Filters","formipay"))),(0,t.createElement)("div",{className:"formipay-orders-table-wrapper"},s?(0,t.createElement)("div",{className:"formipay-loading"},(0,t.createElement)("span",{className:"spinner is-active"})):0===o.length?(0,t.createElement)("div",{className:"formipay-no-results"},(0,t.createElement)("p",null,(0,r.__)("No orders found","formipay"))):(0,t.createElement)(t.Fragment,null,(0,t.createElement)("table",{className:"formipay-orders-table wp-list-table widefat fixed striped"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,r.__)("ID","formipay")),(0,t.createElement)("th",null,(0,r.__)("Date","formipay")),(0,t.createElement)("th",null,(0,r.__)("Customer","formipay")),(0,t.createElement)("th",null,(0,r.__)("Total","formipay")),(0,t.createElement)("th",null,(0,r.__)("Status","formipay")),(0,t.createElement)("th",null,(0,r.__)("Actions","formipay")))),(0,t.createElement)("tbody",null,o.map(a=>(0,t.createElement)(y,{key:a.id,order:a,onSelect:()=>e?.(a.id)})))),N>1&&(0,t.createElement)("div",{className:"formipay-pagination"},(0,t.createElement)(n.Button,{variant:"secondary",disabled:1===k,onClick:()=>v(E.offset-E.limit)},(0,r.__)("Previous","formipay")),(0,t.createElement)("span",{className:"pagination-info"},(0,r.__)("Page","formipay")," ",k," ",(0,r.__)("of","formipay")," ",N),(0,t.createElement)(n.Button,{variant:"secondary",disabled:k===N,onClick:()=>v(E.offset+E.limit)},(0,r.__)("Next","formipay"))))))}const E=window.wp["icons/build/arrowLeft"];var g=e.n(E);const b=window.wp["icons/build/trash"];var h=e.n(b);const v=["on-hold","payment-confirm","in-progress","shipping","completed"],w={"on-hold":(0,r.__)("On Hold","formipay"),"payment-confirm":(0,r.__)("Payment Confirmed","formipay"),"in-progress":(0,r.__)("In Progress","formipay"),shipping:(0,r.__)("Shipping","formipay"),completed:(0,r.__)("Completed","formipay"),failed:(0,r.__)("Failed","formipay"),refunded:(0,r.__)("Refunded","formipay"),cancelled:(0,r.__)("Cancelled","formipay")};function N({orderId:e}){const[n,l]=(0,a.useState)([]);return(0,a.useEffect)(()=>{const e=[{status:"on-hold",date:(new Date).toISOString(),note:(0,r.__)("Order placed","formipay")}];l(e)},[e]),(0,t.createElement)("div",{className:"formipay-order-timeline"},(0,t.createElement)("h3",null,(0,r.__)("Order Timeline","formipay")),(0,t.createElement)("div",{className:"timeline-progress"},v.map((e,a)=>(0,t.createElement)("div",{key:e,className:`timeline-step ${0===a?"first":""} ${a===v.length-1?"last":""}`},(0,t.createElement)("div",{className:"timeline-dot"}),a(0,t.createElement)("li",{key:a},(0,t.createElement)("span",{className:"event-status"},w[e.status]||e.status),(0,t.createElement)("span",{className:"event-date"},new Date(e.date).toLocaleString()),e.note&&(0,t.createElement)("span",{className:"event-note"},e.note))))))}const k=window.wp["icons/build/bell"];var S=e.n(k);const C=window.wp["icons/build/message"];var D=e.n(C);function A(){const e=[{id:1,type:"email",recipient:"customer@example.com",subject:"Order Confirmation",status:"sent",date:(new Date).toISOString()}],a=e=>{switch(e){case"email":default:return S()();case"sms":case"whatsapp":return D()()}};return(0,t.createElement)("div",{className:"formipay-notification-log"},(0,t.createElement)("h3",null,(0,t.createElement)(l,{icon:S()(),size:18}),(0,r.__)("Notification Log","formipay")),0===e.length?(0,t.createElement)("p",{className:"no-logs"},(0,r.__)("No notifications sent yet","formipay")):(0,t.createElement)("ul",{className:"notification-list"},e.map(e=>(0,t.createElement)("li",{key:e.id,className:`notification-item ${e.status}`},(0,t.createElement)("div",{className:"notification-icon"},(0,t.createElement)(l,{icon:a(e.type),size:20})),(0,t.createElement)("div",{className:"notification-content"},(0,t.createElement)("div",{className:"notification-header"},(0,t.createElement)("span",{className:"notification-type"},e.type.toUpperCase()),(0,t.createElement)("span",{className:"notification-status"},e.status)),(0,t.createElement)("div",{className:"notification-details"},(0,t.createElement)("strong",null,e.subject||e.type),(0,t.createElement)("span",{className:"notification-recipient"},(0,r.__)("To:","formipay")," ",e.recipient)),(0,t.createElement)("div",{className:"notification-date"},new Date(e.date).toLocaleString()))))))}const O=[{value:"on-hold",label:(0,r.__)("On Hold","formipay")},{value:"payment-confirm",label:(0,r.__)("Payment Confirmed","formipay")},{value:"in-progress",label:(0,r.__)("In Progress","formipay")},{value:"shipping",label:(0,r.__)("Shipping","formipay")},{value:"completed",label:(0,r.__)("Completed","formipay")},{value:"failed",label:(0,r.__)("Failed","formipay")},{value:"refunded",label:(0,r.__)("Refunded","formipay")},{value:"cancelled",label:(0,r.__)("Cancelled","formipay")}];function I({orderId:e,onBack:o}){const[i,c]=(0,a.useState)(null),[s,d]=(0,a.useState)(!0),[p,u]=(0,a.useState)(!1),[f,y]=(0,a.useState)(""),_=(0,a.useCallback)(()=>{d(!0),(e=>m("formipay-get-order",{order_id:e}))(e).then(e=>{e.data&&(c(e.data),y(e.data.status))}).catch(e=>{console.error("Load order error:",e)}).finally(()=>{d(!1)})},[e]);return(0,a.useEffect)(()=>{_()},[_]),s?(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-loading"},(0,t.createElement)("span",{className:"spinner is-active"}))):i?(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-detail-header"},(0,t.createElement)(n.Button,{variant:"secondary",onClick:o},(0,t.createElement)(l,{icon:g()(),size:16}),(0,r.__)("Back","formipay")),(0,t.createElement)("h1",null,(0,r.__)("Order","formipay")," #",i.id),(0,t.createElement)("div",{className:"header-actions"},(0,t.createElement)(n.Button,{variant:"secondary",isDestructive:!0,onClick:()=>{var t;confirm((0,r.__)("Are you sure you want to delete this order?","formipay"))&&(t=[e],m("formipay-bulk-delete-order",{ids:t})).then(e=>{e.success&&o?.()}).catch(e=>{console.error("Delete order error:",e)})}},(0,t.createElement)(l,{icon:h()(),size:16}),(0,r.__)("Delete","formipay")))),(0,t.createElement)("div",{className:"formipay-detail-content"},(0,t.createElement)("div",{className:"formipay-detail-main"},(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,r.__)("Order Details","formipay")),(0,t.createElement)("dl",{className:"detail-list"},(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,r.__)("Status","formipay")),(0,t.createElement)("dd",null,(0,t.createElement)(n.SelectControl,{value:f,options:O,onChange:y,disabled:p}),f!==i.status&&(0,t.createElement)(n.Button,{variant:"primary",size:"small",onClick:()=>{f&&f!==i.status&&(u(!0),((e,t)=>m("formipay-update-order-status",{order_id:e,status:t}))(e,f).then(e=>{(e.success||e.data?.valid)&&_()}).catch(e=>{console.error("Update status error:",e)}).finally(()=>{u(!1)}))},disabled:p,isBusy:p},p?(0,r.__)("Updating...","formipay"):(0,r.__)("Update Status","formipay")))),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,r.__)("Date Created","formipay")),(0,t.createElement)("dd",null,(E=i.created_date)?new Date(E).toLocaleString():"-")),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,r.__)("Form ID","formipay")),(0,t.createElement)("dd",null,i.form_id)),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,r.__)("Payment Gateway","formipay")),(0,t.createElement)("dd",null,i.payment_gateway||"-")))),(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,r.__)("Items","formipay")),(0,t.createElement)("table",{className:"items-table"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,r.__)("Item","formipay")),(0,t.createElement)("th",null,(0,r.__)("Qty","formipay")),(0,t.createElement)("th",null,(0,r.__)("Subtotal","formipay")))),(0,t.createElement)("tbody",null,i.items?.map((e,a)=>(0,t.createElement)("tr",{key:a},(0,t.createElement)("td",null,(0,t.createElement)("strong",null,e.item),e.description&&(0,t.createElement)("small",null,e.description)),(0,t.createElement)("td",null,e.qty||1),(0,t.createElement)("td",null,e.subtotal_formatted||e.subtotal)))||(0,t.createElement)("tr",null,(0,t.createElement)("td",{colSpan:"3",className:"text-center"},(0,r.__)("No items","formipay")))),(0,t.createElement)("tfoot",null,(0,t.createElement)("tr",null,(0,t.createElement)("td",{colSpan:"2"},(0,t.createElement)("strong",null,(0,r.__)("Total","formipay"))),(0,t.createElement)("td",null,(0,t.createElement)("strong",null,i.total_formatted||i.total))))))),(0,t.createElement)("div",{className:"formipay-detail-sidebar"},(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,r.__)("Customer Information","formipay")),i.form_data?(0,t.createElement)("dl",{className:"customer-info"},Object.entries(i.form_data).map(([e,a])=>["payment","payment_gateway","coupon_code","qty"].includes(e)?null:(0,t.createElement)("div",{key:e},(0,t.createElement)("dt",null,e.replace(/_/g," ")),(0,t.createElement)("dd",null,a?.value||a||"-")))):(0,t.createElement)("p",{className:"no-data"},(0,r.__)("No customer data available","formipay"))),(0,t.createElement)(N,{orderId:e}),(0,t.createElement)(A,null)))):(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-error"},(0,t.createElement)("p",null,(0,r.__)("Order not found","formipay")),(0,t.createElement)(n.Button,{variant:"secondary",onClick:o},(0,t.createElement)(l,{icon:g()(),size:16}),(0,r.__)("Back to Orders","formipay"))));var E}function P({columns:e,data:a,loading:n,emptyMessage:l=(0,r.__)("No items found","formipay"),onRowClick:o}){return n?(0,t.createElement)("div",{className:"formipay-data-table-loading"},(0,t.createElement)("span",{className:"spinner is-active"})):a&&0!==a.length?(0,t.createElement)("table",{className:"formipay-data-table wp-list-table widefat fixed striped"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,e.map(e=>(0,t.createElement)("th",{key:e.key},e.label)))),(0,t.createElement)("tbody",null,a.map((a,r)=>(0,t.createElement)("tr",{key:r,onClick:o?()=>o(a):void 0,className:o?"is-clickable":""},e.map(e=>(0,t.createElement)("td",{key:e.key},e.render?e.render(a):a[e.key])))))):(0,t.createElement)("div",{className:"formipay-data-table-empty"},(0,t.createElement)("p",null,l))}const F=window.wp["icons/build/plus"];var x=e.n(F);const L=window.wp["icons/build/minus"];var j=e.n(L);const U=window.wp["icons/build/eyeClosed"];var B=e.n(U);const $=window.wp["icons/build/eyeOpened"];var M=e.n($);function R({productId:e,productDetails:n}){const[l,o]=(0,a.useState)([]),[i,c]=(0,a.useState)([]),[s,m]=(0,a.useState)(!0),d=(0,a.useRef)(null),p=(0,a.useRef)(null),u=(0,a.useRef)(null),f=(0,a.useCallback)(()=>String(n?.default_currency||"").split(":::")[0]||n?.default_currency_code||"USD",[n]),y=(0,a.useCallback)(e=>{const t=n?.global_currencies||[],a=String(e).split(":::")[0],r=t.find(e=>String(e.currency).split(":::")[0]===a);return parseInt(r?.decimal_digits,10)||2},[n]),_=(0,a.useCallback)(()=>{const e=n?.global_selected_currencies||{};let t=Object.keys(e);if(!t.length){const e=n?.default_currency||"";e&&(t=[e])}return t.map(e=>{const t=String(e).split(":::")[0];return{currency:e,regular_price:"",sale_price:"",currency_decimal_digits:y(t)}})},[n,y]),E=(0,a.useCallback)(e=>{const t={...e};void 0===t.expanded&&(t.expanded=!1);const a=_(),r=e=>String(e).split(":::")[0];if(Array.isArray(t.prices)){const e=new Set(a.map(e=>r(e.currency)));t.prices=t.prices.filter(t=>t&&e.has(r(t.currency))),a.forEach(e=>{const a=r(e.currency);t.prices.some(e=>r(e.currency)===a)||t.prices.push(JSON.parse(JSON.stringify(e)))})}else t.prices=JSON.parse(JSON.stringify(a));Array.isArray(t.prices)&&0!==t.prices.length||(t.prices=JSON.parse(JSON.stringify(a))),t.prices.forEach(e=>{const t=r(e.currency);e.currency_decimal_digits=y(t),void 0!==e.regular_price&&null!==e.regular_price||(e.regular_price=""),void 0!==e.sale_price&&null!==e.sale_price||(e.sale_price="")});const n=f();return t.prices.sort((e,t)=>r(e.currency)===n?-1:r(t.currency)===n?1:0),delete t.price,delete t.sale,t},[_,y,f]),g=(0,a.useCallback)(()=>new Promise(e=>{let t=0;const a=setInterval(()=>{const r=document.querySelector('input[name="product_variation_attributes"]');if(r&&r.value)try{const t=JSON.parse(r.value);clearInterval(a),e(Array.isArray(t)?t:[])}catch(t){clearInterval(a),e([])}else++t>=100&&(clearInterval(a),e([]))},50)}),[]),b=(0,a.useCallback)(e=>{const t=e.map(e=>(e.attribute_variations||[]).map(e=>({label:e.variation_label}))).filter(e=>e.length>0);return t.length?t.reduce((e,t)=>e.flatMap(e=>t.map(t=>[].concat(e,t)))).map(e=>{const t=Array.isArray(e)?e.map(e=>e.label):[e.label];return{key:t.join("||"),label:t.join(" - ")}}):[]},[]),h=(0,a.useCallback)(async()=>{try{const e=await g();if(!e.length)return o([]),void v([]);const t=b(e).filter(e=>!i.includes(e.key)).map(e=>{const t=l.find(t=>t.key===e.key);return t?Object.assign(E(t),{name:e.label}):E({key:e.key,name:e.label,stock:"",weight:0,active:!0})});o(t),v(t)}catch(e){console.warn("Attributes not available; initializing empty variations."),o([]),v([])}},[g,b,i,l,E]),v=(0,a.useCallback)(e=>{d.current&&(d.current.value=JSON.stringify(e||[]))},[]),w=(0,a.useCallback)(async()=>{if(e)try{const t=new FormData;t.append("action","get_product_variables"),t.append("post_id",e),t.append("_wpnonce",window.formipayAdmin?.nonce||"");const a=await fetch(window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",{method:"POST",credentials:"same-origin",body:t}),r=await a.json();if(r.success&&Array.isArray(r.data)&&r.data.length){const e=r.data.map(e=>E(e));o(e),c([]),v(e)}else await h()}catch{await h()}else await h()},[e,E,h,v]),N=(0,a.useCallback)(()=>{const e=()=>{setTimeout(()=>{h()},200)},t=document.querySelector('input[name="product_variation_attributes"]');if(t){t.addEventListener("input",e),t.addEventListener("change",e);const a=new MutationObserver(e);a.observe(t,{attributes:!0,attributeFilter:["value"]}),u.current=a,p.current=setInterval(()=>{const t=document.querySelector('input[name="product_variation_attributes"]');t&&t.value!==d.current?.value&&e()},300)}return()=>{u.current&&u.current.disconnect(),p.current&&clearInterval(p.current)}},[h]);(0,a.useEffect)(()=>{const e=n?.multicurrency,t=n?.global_selected_currencies||{},a=Object.keys(t).length;return m(!e||a<=1),w(),N()},[n,w,N]);const k=(0,a.useCallback)((e,t,a,r)=>{const n=[...l];n[e].prices[t][a]=r,o(n),v(n)},[l,v]),S=(0,a.useCallback)(e=>{const t=[...l];t[e].expanded=!t[e].expanded,o(t)},[l]),C=(0,a.useCallback)((e,t,a)=>{const r=[...l];r[e][t]=a,o(r),v(r)},[l,v]),D=(0,a.useCallback)(e=>{const t=l[e],a=[...i,t.key];c(a);const r=l.filter((t,a)=>a!==e);o(r),v(r)},[l,i,v]),A=(0,a.useCallback)(()=>{const e=f();for(const t of l){const a=t.prices?.find(t=>String(t.currency).split(":::")[0]===e);if(!a||!a.regular_price)return{currencyCode:e,rowLabel:t.name}}return null},[l,f]);return(0,a.useEffect)(()=>{const e=document.getElementById("post");if(!e)return;const t=e=>{const t=A();if(t){e.preventDefault(),e.stopImmediatePropagation();const a=(n?.variation_table?.error_missing_default_price||'Please fill Regular Price for default currency (%1$s) in variation "%2$s".').replace("%1$s",t.currencyCode).replace("%2$s",t.rowLabel);return alert(a),!1}};return e.addEventListener("submit",t,!0),()=>e.removeEventListener("submit",t,!0)},[A,n]),(0,t.createElement)(t.Fragment,null,(0,t.createElement)("input",{ref:d,type:"hidden",name:"product_variation_variables",value:JSON.stringify(l)}),(0,t.createElement)("table",{className:"formipay-variation-table",id:"product-variables-table"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,r.__)("Variation","formipay")),s?(0,t.createElement)(t.Fragment,null,(0,t.createElement)("th",null,(0,r.__)("Price","formipay")),(0,t.createElement)("th",null,(0,r.__)("Sale Price","formipay"))):null,(0,t.createElement)("th",null,(0,r.__)("Stock","formipay")),(0,t.createElement)("th",null,(0,r.__)("Weight","formipay")),(0,t.createElement)("th",null,(0,r.__)("Actions","formipay")))),(0,t.createElement)("tbody",null,l.map((e,a)=>(0,t.createElement)(T,{key:e.key,row:e,rowIndex:a,showFlatPricing:s,defaultCurrencyCode:f(),onToggleExpanded:()=>S(a),onUpdatePrice:(e,t,r)=>k(a,e,t,r),onUpdateField:(e,t)=>C(a,e,t),onDelete:()=>D(a)})))))}function T({row:e,rowIndex:a,showFlatPricing:o,defaultCurrencyCode:i,onToggleExpanded:c,onUpdatePrice:s,onUpdateField:m,onDelete:d}){return(0,t.createElement)(t.Fragment,null,(0,t.createElement)("tr",{className:"variation-row"},(0,t.createElement)("td",{className:"variation-name"},(0,t.createElement)("button",{type:"button",className:"toggle-expand",onClick:c},(0,t.createElement)(l,{icon:e.expanded?M():B(),size:16})),(0,t.createElement)("strong",null,e.name)),o?(0,t.createElement)(t.Fragment,null,(0,t.createElement)(J,{price:e.prices[0],field:"regular_price",onChange:(e,t)=>s(0,e,t)}),(0,t.createElement)(J,{price:e.prices[0],field:"sale_price",onChange:(e,t)=>s(0,e,t)})):null,(0,t.createElement)("td",{className:"variation-stock"},(0,t.createElement)(n.TextControl,{type:"number",value:e.stock,onChange:e=>m("stock",e),placeholder:"Unlimited"})),(0,t.createElement)("td",{className:"variation-weight"},(0,t.createElement)(n.TextControl,{type:"number",value:e.weight,onChange:e=>m("weight",e),step:"0.01"})),(0,t.createElement)("td",{className:"variation-actions"},(0,t.createElement)(n.Button,{variant:"secondary",size:"small",isDestructive:!0,onClick:d,icon:j()()},(0,r.__)("Delete","formipay")))),!o&&e.expanded&&(0,t.createElement)("tr",{className:"variation-details-row"},(0,t.createElement)("td",{colSpan:"5"},(0,t.createElement)("table",{className:"inner-table"},(0,t.createElement)("tbody",null,e.prices.map((e,a)=>{const r=String(e.currency).split(":::")[0]===i,n=e.currency_decimal_digits?1/Math.pow(10,e.currency_decimal_digits):.01;return(0,t.createElement)("tr",{key:a},(0,t.createElement)("td",{className:"currency-name"},e.currency,r&&(0,t.createElement)("span",{className:"required"},"*")),(0,t.createElement)("td",null,(0,t.createElement)("input",{type:"number",value:e.regular_price,onChange:e=>s(a,"regular_price",e.target.value),step:n,placeholder:"Regular Price",required:r})),(0,t.createElement)("td",null,(0,t.createElement)("input",{type:"number",value:e.sale_price,onChange:e=>s(a,"sale_price",e.target.value),step:n,placeholder:"Sale Price"})))}))))))}function J({price:e,field:a,onChange:r}){const n=e.currency_decimal_digits?1/Math.pow(10,e.currency_decimal_digits):.01;return(0,t.createElement)("td",{className:"price-cell"},(0,t.createElement)("input",{type:"number",value:e[a],onChange:e=>r(a,e.target.value),step:n,placeholder:"Auto"}))}const z={orders:function({initialData:e}){const[r,n]=(0,a.useState)(null);return r?(0,t.createElement)(I,{orderId:r,onBack:()=>n(null)}):(0,t.createElement)(_,{onSelectOrder:e=>n(e)})},customers:function({initialData:e}){const[n,l]=(0,a.useState)([]),[o,i]=(0,a.useState)(!0),c=(0,a.useCallback)(()=>{i(!0),((e={})=>m("formipay-tabledata-customers",e))().then(e=>{const t=e.data?.results||e.results||e.data||[];l(t)}).catch(e=>{console.error("Load customers error:",e)}).finally(()=>{i(!1)})},[]);(0,a.useEffect)(()=>{c()},[c]);const s=[{key:"id",label:(0,r.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"name",label:(0,r.__)("Name","formipay"),render:e=>e.name||e.full_name||"-"},{key:"email",label:(0,r.__)("Email","formipay")},{key:"phone",label:(0,r.__)("Phone","formipay"),render:e=>e.phone||e.whatsapp||"-"},{key:"total_order",label:(0,r.__)("Total Orders","formipay"),render:e=>e.total_order||e.total_orders||0},{key:"created_date",label:(0,r.__)("Date","formipay"),render:e=>{const t=e.created_date||e.date;return t?new Date(t).toLocaleDateString():"-"}}];return(0,t.createElement)("div",{className:"formipay-page-customers"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,r.__)("Customers","formipay"))),(0,t.createElement)(P,{columns:s,data:n,loading:o,emptyMessage:(0,r.__)("No customers found","formipay")}))},products:function({initialData:e}){const[n,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),s=e?.productDetails||{};return n&&i?(0,t.createElement)("div",{className:"formipay-page-products"},(0,t.createElement)("div",{className:"formipay-products-header"},(0,t.createElement)("button",{type:"button",className:"button button-secondary",onClick:()=>o(!1)},"← ",(0,r.__)("Back to Products","formipay")),(0,t.createElement)("h1",null,(0,r.__)("Edit Product","formipay"))),(0,t.createElement)("div",{className:"formipay-product-editor"},(0,t.createElement)(R,{productId:i,productDetails:s}))):(0,t.createElement)("div",{className:"formipay-page-products"},(0,t.createElement)("div",{className:"formipay-products-list-header"},(0,t.createElement)("h1",null,(0,r.__)("Products","formipay")),(0,t.createElement)("button",{type:"button",className:"button button-primary",onClick:()=>{c(null),o(!0)}},(0,t.createElement)(l,{icon:x()(),size:16}),(0,r.__)("Add New Product","formipay"))),(0,t.createElement)("p",{className:"formipay-coming-soon"},(0,r.__)("Products list coming soon. Use the classic editor for now.","formipay")))},forms:function({initialData:e}){const[l,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),[s,d]=(0,a.useState)([]),[p,u]=(0,a.useState)(!0),f=(0,a.useCallback)(()=>{u(!0),((e={})=>m("formipay-tabledata-forms",e))().then(e=>{console.log("Forms API result:",e);const t=e.data?.results||e.results||e.data||[];console.log("Forms data extracted:",t),console.log("Forms data length:",t.length),d(t)}).catch(e=>{console.error("Load forms error:",e)}).finally(()=>{u(!1)})},[]);if((0,a.useEffect)(()=>{f()},[f]),l&&i)return window.location.href=`${window.formipayAdmin?.siteUrl||""}/wp-admin/post.php?post=${i}&action=edit`,null;const y=[{key:"id",label:(0,r.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.ID||e.id)},{key:"title",label:(0,r.__)("Title","formipay"),render:e=>(0,t.createElement)("a",{href:`${window.formipayAdmin?.siteUrl||""}/wp-admin/post.php?post=${e.ID||e.id}&action=edit`,onClick:t=>{t.preventDefault(),o(!0),c(e.ID||e.id)}},e.post_title||e.title||(0,r.__)("Untitled","formipay"))},{key:"shortcode",label:(0,r.__)("Shortcode","formipay"),render:e=>(0,t.createElement)("code",null,'[formipay id="',e.ID||e.id,'"]')},{key:"status",label:(0,r.__)("Status","formipay"),render:e=>{const a=e.post_status||e.status||"unknown",n={publish:(0,r.__)("Published","formipay"),draft:(0,r.__)("Draft","formipay"),pending:(0,r.__)("Pending","formipay")}[a]||a;return(0,t.createElement)("span",{className:"status-badge status-"+("publish"===a?"active":"draft")},n)}},{key:"date",label:(0,r.__)("Date","formipay"),render:e=>{const t=e.post_date||e.date;return t?new Date(t).toLocaleDateString():"-"}}];return(0,t.createElement)("div",{className:"formipay-page-forms"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,r.__)("Forms","formipay")),(0,t.createElement)(n.Button,{variant:"primary",href:`${window.formipayAdmin?.siteUrl||""}/wp-admin/post-new.php?post_type=formipay-form`},(0,r.__)("+ Add New Form","formipay"))),(0,t.createElement)(P,{columns:y,data:s,loading:p,emptyMessage:(0,r.__)("No forms found","formipay")}))},coupons:function({initialData:e}){const[l,o]=(0,a.useState)([]),[i,c]=(0,a.useState)(!0),s=(0,a.useCallback)(()=>{c(!0),((e={})=>m("formipay-tabledata-coupons",e))().then(e=>{const t=e.data?.results||e.results||e.data||[];o(t)}).catch(e=>{console.error("Load coupons error:",e)}).finally(()=>{c(!1)})},[]);(0,a.useEffect)(()=>{s()},[s]);const d=[{key:"id",label:(0,r.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"code",label:(0,r.__)("Coupon Code","formipay"),render:e=>(0,t.createElement)("strong",null,e.code||e.post_title)},{key:"type",label:(0,r.__)("Type","formipay"),render:e=>"percentage"===(e.coupon_type||e.type||"percentage")?(0,r.__)("%","formipay"):(0,r.__)("Fixed","formipay")},{key:"amount",label:(0,r.__)("Amount","formipay")},{key:"usages",label:(0,r.__)("Usages","formipay"),render:e=>e.usage_count||e.usages||0},{key:"status",label:(0,r.__)("Status","formipay"),render:e=>"publish"===(e.post_status||e.status||"unknown")?(0,r.__)("Active","formipay"):(0,r.__)("Inactive","formipay")}];return(0,t.createElement)("div",{className:"formipay-page-coupons"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,r.__)("Coupons","formipay")),(0,t.createElement)(n.Button,{variant:"primary",onClick:()=>{const e=prompt((0,r.__)("Enter coupon code:","formipay"));var t;e&&(t={code:e},m("formipay-create-coupon-post",t)).then(()=>s()).catch(console.error)}},(0,r.__)("+ Add New Coupon","formipay"))),(0,t.createElement)(P,{columns:d,data:l,loading:i,emptyMessage:(0,r.__)("No coupons found","formipay")}))},access:function({initialData:e}){const[l,o]=(0,a.useState)([]),[i,c]=(0,a.useState)(!0),s=(0,a.useCallback)(()=>{c(!0),((e={})=>m("formipay-tabledata-access-items",e))().then(e=>{const t=e.data?.results||e.results||e.data||[];o(t)}).catch(e=>{console.error("Load access items error:",e)}).finally(()=>{c(!1)})},[]);(0,a.useEffect)(()=>{s()},[s]);const d=[{key:"id",label:(0,r.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"title",label:(0,r.__)("Title","formipay")},{key:"product_name",label:(0,r.__)("Product","formipay")},{key:"status",label:(0,r.__)("Status","formipay"),render:e=>{const a=e.post_status||e.status||"unknown",n={publish:(0,r.__)("Published","formipay"),draft:(0,r.__)("Draft","formipay")}[a]||a;return(0,t.createElement)("span",{className:`status-badge status-${a}`},n)}},{key:"date",label:(0,r.__)("Date","formipay"),render:e=>{const t=e.post_date||e.date;return t?new Date(t).toLocaleDateString():"-"}}];return(0,t.createElement)("div",{className:"formipay-page-access"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,r.__)("Access Items","formipay")),(0,t.createElement)(n.Button,{variant:"primary",href:window.formipayAdmin?.siteUrl+"/wp-admin/post-new.php?post_type=formipay-access"},(0,r.__)("+ Add New Item","formipay"))),(0,t.createElement)(P,{columns:d,data:l,loading:i,emptyMessage:(0,r.__)("No access items found","formipay")}))},licenses:function({initialData:e}){const[n,l]=(0,a.useState)([]),[o,i]=(0,a.useState)(!0),c=(0,a.useCallback)(()=>{i(!0),fetch(window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"formipay-tabledata-licenses",_wpnonce:window.formipayAdmin?.nonce||""})}).then(e=>e.json()).then(e=>{const t=e.data?.results||e.results||e.data||[];l(t)}).catch(e=>{console.error("Load licenses error:",e)}).finally(()=>{i(!1)})},[]);(0,a.useEffect)(()=>{c()},[c]);const s=[{key:"id",label:(0,r.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"license_key",label:(0,r.__)("License Key","formipay"),render:e=>(0,t.createElement)("code",null,e.license_key||"-")},{key:"product",label:(0,r.__)("Product","formipay"),render:e=>e.product_name||e.product||"-"},{key:"order",label:(0,r.__)("Order","formipay"),render:e=>e.order_id||`#${e.order}`||"-"},{key:"email",label:(0,r.__)("Email","formipay")},{key:"status",label:(0,r.__)("Status","formipay"),render:e=>{const t=e.status||"unknown";return{active:(0,r.__)("Active","formipay"),inactive:(0,r.__)("Inactive","formipay"),expired:(0,r.__)("Expired","formipay")}[t]||t}}];return(0,t.createElement)("div",{className:"formipay-page-licenses"},(0,t.createElement)("div",{className:"formipay-page-licenses"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,r.__)("Licenses","formipay"))),(0,t.createElement)(P,{columns:s,data:n,loading:o,emptyMessage:(0,r.__)("No licenses found","formipay")})))}};function q({page:e,initialData:r}){(0,a.useEffect)(()=>{console.log("[Formipay App] Rendering page:",e,"with data:",r)},[e,r]);const n=z[e];return n?(0,t.createElement)("div",{className:"formipay-admin-wrap"},(0,t.createElement)(n,{initialData:r})):(0,t.createElement)("div",{className:"formipay-error"},(0,t.createElement)("p",null,"Unknown page: ",e))}const H=()=>{const e=document.querySelectorAll("[data-formipay-mount]");console.log("[Formipay] Mount points found:",e.length),console.log("[Formipay] formipayAdmin data:",window.formipayAdmin),e.forEach(e=>{const r=e.dataset.formipayMount,n=window.formipayAdmin?.[r]||{};console.log("[Formipay] Mounting page:",r,"with data:",n);try{(0,a.render)((0,t.createElement)(q,{page:r,initialData:n}),e),console.log("[Formipay] Successfully mounted:",r)}catch(e){console.error("[Formipay] Failed to mount:",r,e)}})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",H):H()})(); \ No newline at end of file +(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,a=window.wp.element,n=window.wp.i18n,r=window.wp.components,l=(0,a.forwardRef)(function({icon:e,size:t=24,...n},r){return(0,a.cloneElement)(e,{width:t,height:t,...n,ref:r})}),o=window.wp["icons/build/list"];var i=e.n(o);const c=window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",s=window.formipayAdmin?.nonce||"";async function m(e,t={}){const a=new FormData;a.append("action",e),a.append("_wpnonce",s),Object.keys(t).forEach(e=>{"object"==typeof t[e]?a.append(e,JSON.stringify(t[e])):a.append(e,t[e])}),console.log(`[AJAX] Sending request: ${e}`,{nonce:s,data:t});try{const t=await fetch(c,{method:"POST",credentials:"same-origin",body:a});console.log(`[AJAX] Response status: ${e}`,t.status);const n=await t.json();if(console.log(`[AJAX] Response data: ${e}`,n),!t.ok||!1===n.success){const e=n.data?.message||n.message||"Request failed";throw new Error(e)}return n}catch(t){throw console.error(`AJAX error [${e}]:`,t),t}}window.formipayAdmin;const d=window.wp["icons/build/visible"];var p=e.n(d);const u={"on-hold":"#f0ad4e","payment-confirm":"#17a2b8","in-progress":"#17a2b8",shipping:"#6c757d",completed:"#28a745",failed:"#dc3545",refunded:"#6c757d",cancelled:"#dc3545"},f={"on-hold":(0,n.__)("On Hold","formipay"),"payment-confirm":(0,n.__)("Payment Confirmed","formipay"),"in-progress":(0,n.__)("In Progress","formipay"),shipping:(0,n.__)("Shipping","formipay"),completed:(0,n.__)("Completed","formipay"),failed:(0,n.__)("Failed","formipay"),refunded:(0,n.__)("Refunded","formipay"),cancelled:(0,n.__)("Cancelled","formipay")};function y({order:e,onSelect:a}){const r=u[e.status]||"#6c757d",o=f[e.status]||e.status,i=(e=>{if(e.form_data){const t=Object.values(e.form_data).find(e=>e.name&&e.name.includes("name"));return t?.value||"-"}return"-"})(e);return(0,t.createElement)("tr",{className:"formipay-order-item"},(0,t.createElement)("td",null,(0,t.createElement)("strong",null,"#",e.id)),(0,t.createElement)("td",null,(c=e.created_date)?new Date(c).toLocaleDateString():"-"),(0,t.createElement)("td",null,"-"!==i?i:(0,t.createElement)("em",null,"Unknown")),(0,t.createElement)("td",null,(0,t.createElement)("strong",null,e.total_formatted||e.total)),(0,t.createElement)("td",null,(0,t.createElement)("span",{className:"status-badge",style:{backgroundColor:r}},o)),(0,t.createElement)("td",null,(0,t.createElement)("button",{type:"button",className:"button button-small",onClick:a},(0,t.createElement)(l,{icon:p()(),size:16}),(0,n.__)("View","formipay"))));var c}function _({onSelectOrder:e}){const[o,c]=(0,a.useState)([]),[s,d]=(0,a.useState)(!0),[p,u]=(0,a.useState)(0),[f,_]=(0,a.useState)({keyword:"",status:"",date_from:"",date_to:""}),[E,h]=(0,a.useState)({limit:20,offset:0}),b=(0,a.useCallback)(()=>{d(!0),((e={})=>m("formipay-tabledata-orders",e))({keyword:f.keyword,status:f.status,date_from:f.date_from,date_to:f.date_to,limit:E.limit,offset:E.offset}).then(e=>{e.data&&(c(e.data.results||[]),u(e.data.total||0))}).catch(e=>{console.error("Load orders error:",e)}).finally(()=>{d(!1)})},[f,E]);(0,a.useEffect)(()=>{b()},[b]);const g=(e,t)=>{_({...f,[e]:t}),h({...E,offset:0})},w=e=>{h({...E,offset:e})},v={"":(0,n.__)("All Statuses","formipay"),"on-hold":(0,n.__)("On Hold","formipay"),"payment-confirm":(0,n.__)("Payment Confirmed","formipay"),"in-progress":(0,n.__)("In Progress","formipay"),shipping:(0,n.__)("Shipping","formipay"),completed:(0,n.__)("Completed","formipay"),failed:(0,n.__)("Failed","formipay"),refunded:(0,n.__)("Refunded","formipay"),cancelled:(0,n.__)("Cancelled","formipay")},N=Math.ceil(p/E.limit),k=Math.floor(E.offset/E.limit)+1;return(0,t.createElement)("div",{className:"formipay-order-list"},(0,t.createElement)("div",{className:"formipay-orders-header"},(0,t.createElement)("h2",null,(0,t.createElement)(l,{icon:i()()}),(0,n.__)("Orders","formipay")),(0,t.createElement)("span",{className:"order-count"},p," ",(0,n.__)("orders","formipay"))),(0,t.createElement)("div",{className:"formipay-orders-filters"},(0,t.createElement)(r.SearchControl,{value:f.keyword,onChange:e=>{g("keyword",e)},placeholder:(0,n.__)("Search by order ID, customer name, email...","formipay")}),(0,t.createElement)(r.SelectControl,{value:f.status,options:Object.entries(v).map(([e,t])=>({value:e,label:t})),onChange:e=>g("status",e),label:(0,n.__)("Status","formipay")}),(0,t.createElement)("input",{type:"date",value:f.date_from,onChange:e=>g("date_from",e.target.value),className:"formipay-date-input"}),(0,t.createElement)("input",{type:"date",value:f.date_to,onChange:e=>g("date_to",e.target.value),className:"formipay-date-input"}),(f.keyword||f.status||f.date_from||f.date_to)&&(0,t.createElement)(r.Button,{variant:"secondary",onClick:()=>{_({keyword:"",status:"",date_from:"",date_to:""}),h({limit:20,offset:0})}},(0,n.__)("Clear Filters","formipay"))),(0,t.createElement)("div",{className:"formipay-orders-table-wrapper"},s?(0,t.createElement)("div",{className:"formipay-loading"},(0,t.createElement)("span",{className:"spinner is-active"})):0===o.length?(0,t.createElement)("div",{className:"formipay-no-results"},(0,t.createElement)("p",null,(0,n.__)("No orders found","formipay"))):(0,t.createElement)(t.Fragment,null,(0,t.createElement)("table",{className:"formipay-orders-table wp-list-table widefat fixed striped"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,n.__)("ID","formipay")),(0,t.createElement)("th",null,(0,n.__)("Date","formipay")),(0,t.createElement)("th",null,(0,n.__)("Customer","formipay")),(0,t.createElement)("th",null,(0,n.__)("Total","formipay")),(0,t.createElement)("th",null,(0,n.__)("Status","formipay")),(0,t.createElement)("th",null,(0,n.__)("Actions","formipay")))),(0,t.createElement)("tbody",null,o.map(a=>(0,t.createElement)(y,{key:a.id,order:a,onSelect:()=>e?.(a.id)})))),N>1&&(0,t.createElement)("div",{className:"formipay-pagination"},(0,t.createElement)(r.Button,{variant:"secondary",disabled:1===k,onClick:()=>w(E.offset-E.limit)},(0,n.__)("Previous","formipay")),(0,t.createElement)("span",{className:"pagination-info"},(0,n.__)("Page","formipay")," ",k," ",(0,n.__)("of","formipay")," ",N),(0,t.createElement)(r.Button,{variant:"secondary",disabled:k===N,onClick:()=>w(E.offset+E.limit)},(0,n.__)("Next","formipay"))))))}const E=window.wp["icons/build/arrowLeft"];var h=e.n(E);const b=window.wp["icons/build/trash"];var g=e.n(b);const w=["on-hold","payment-confirm","in-progress","shipping","completed"],v={"on-hold":(0,n.__)("On Hold","formipay"),"payment-confirm":(0,n.__)("Payment Confirmed","formipay"),"in-progress":(0,n.__)("In Progress","formipay"),shipping:(0,n.__)("Shipping","formipay"),completed:(0,n.__)("Completed","formipay"),failed:(0,n.__)("Failed","formipay"),refunded:(0,n.__)("Refunded","formipay"),cancelled:(0,n.__)("Cancelled","formipay")};function N({orderId:e}){const[r,l]=(0,a.useState)([]);return(0,a.useEffect)(()=>{const e=[{status:"on-hold",date:(new Date).toISOString(),note:(0,n.__)("Order placed","formipay")}];l(e)},[e]),(0,t.createElement)("div",{className:"formipay-order-timeline"},(0,t.createElement)("h3",null,(0,n.__)("Order Timeline","formipay")),(0,t.createElement)("div",{className:"timeline-progress"},w.map((e,a)=>(0,t.createElement)("div",{key:e,className:`timeline-step ${0===a?"first":""} ${a===w.length-1?"last":""}`},(0,t.createElement)("div",{className:"timeline-dot"}),a(0,t.createElement)("li",{key:a},(0,t.createElement)("span",{className:"event-status"},v[e.status]||e.status),(0,t.createElement)("span",{className:"event-date"},new Date(e.date).toLocaleString()),e.note&&(0,t.createElement)("span",{className:"event-note"},e.note))))))}const k=window.wp["icons/build/bell"];var S=e.n(k);const C=window.wp["icons/build/message"];var D=e.n(C);function A(){const e=[{id:1,type:"email",recipient:"customer@example.com",subject:"Order Confirmation",status:"sent",date:(new Date).toISOString()}],a=e=>{switch(e){case"email":default:return S()();case"sms":case"whatsapp":return D()()}};return(0,t.createElement)("div",{className:"formipay-notification-log"},(0,t.createElement)("h3",null,(0,t.createElement)(l,{icon:S()(),size:18}),(0,n.__)("Notification Log","formipay")),0===e.length?(0,t.createElement)("p",{className:"no-logs"},(0,n.__)("No notifications sent yet","formipay")):(0,t.createElement)("ul",{className:"notification-list"},e.map(e=>(0,t.createElement)("li",{key:e.id,className:`notification-item ${e.status}`},(0,t.createElement)("div",{className:"notification-icon"},(0,t.createElement)(l,{icon:a(e.type),size:20})),(0,t.createElement)("div",{className:"notification-content"},(0,t.createElement)("div",{className:"notification-header"},(0,t.createElement)("span",{className:"notification-type"},e.type.toUpperCase()),(0,t.createElement)("span",{className:"notification-status"},e.status)),(0,t.createElement)("div",{className:"notification-details"},(0,t.createElement)("strong",null,e.subject||e.type),(0,t.createElement)("span",{className:"notification-recipient"},(0,n.__)("To:","formipay")," ",e.recipient)),(0,t.createElement)("div",{className:"notification-date"},new Date(e.date).toLocaleString()))))))}const I=[{value:"on-hold",label:(0,n.__)("On Hold","formipay")},{value:"payment-confirm",label:(0,n.__)("Payment Confirmed","formipay")},{value:"in-progress",label:(0,n.__)("In Progress","formipay")},{value:"shipping",label:(0,n.__)("Shipping","formipay")},{value:"completed",label:(0,n.__)("Completed","formipay")},{value:"failed",label:(0,n.__)("Failed","formipay")},{value:"refunded",label:(0,n.__)("Refunded","formipay")},{value:"cancelled",label:(0,n.__)("Cancelled","formipay")}];function P({orderId:e,onBack:o}){const[i,c]=(0,a.useState)(null),[s,d]=(0,a.useState)(!0),[p,u]=(0,a.useState)(!1),[f,y]=(0,a.useState)(""),_=(0,a.useCallback)(()=>{d(!0),(e=>m("formipay-get-order",{order_id:e}))(e).then(e=>{e.data&&(c(e.data),y(e.data.status))}).catch(e=>{console.error("Load order error:",e)}).finally(()=>{d(!1)})},[e]);return(0,a.useEffect)(()=>{_()},[_]),s?(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-loading"},(0,t.createElement)("span",{className:"spinner is-active"}))):i?(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-detail-header"},(0,t.createElement)(r.Button,{variant:"secondary",onClick:o},(0,t.createElement)(l,{icon:h()(),size:16}),(0,n.__)("Back","formipay")),(0,t.createElement)("h1",null,(0,n.__)("Order","formipay")," #",i.id),(0,t.createElement)("div",{className:"header-actions"},(0,t.createElement)(r.Button,{variant:"secondary",isDestructive:!0,onClick:()=>{var t;confirm((0,n.__)("Are you sure you want to delete this order?","formipay"))&&(t=[e],m("formipay-bulk-delete-order",{ids:t})).then(e=>{e.success&&o?.()}).catch(e=>{console.error("Delete order error:",e)})}},(0,t.createElement)(l,{icon:g()(),size:16}),(0,n.__)("Delete","formipay")))),(0,t.createElement)("div",{className:"formipay-detail-content"},(0,t.createElement)("div",{className:"formipay-detail-main"},(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,n.__)("Order Details","formipay")),(0,t.createElement)("dl",{className:"detail-list"},(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,n.__)("Status","formipay")),(0,t.createElement)("dd",null,(0,t.createElement)(r.SelectControl,{value:f,options:I,onChange:y,disabled:p}),f!==i.status&&(0,t.createElement)(r.Button,{variant:"primary",size:"small",onClick:()=>{f&&f!==i.status&&(u(!0),((e,t)=>m("formipay-update-order-status",{order_id:e,status:t}))(e,f).then(e=>{(e.success||e.data?.valid)&&_()}).catch(e=>{console.error("Update status error:",e)}).finally(()=>{u(!1)}))},disabled:p,isBusy:p},p?(0,n.__)("Updating...","formipay"):(0,n.__)("Update Status","formipay")))),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,n.__)("Date Created","formipay")),(0,t.createElement)("dd",null,(E=i.created_date)?new Date(E).toLocaleString():"-")),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,n.__)("Form ID","formipay")),(0,t.createElement)("dd",null,i.form_id)),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,n.__)("Payment Gateway","formipay")),(0,t.createElement)("dd",null,i.payment_gateway||"-")))),(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,n.__)("Items","formipay")),(0,t.createElement)("table",{className:"items-table"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,n.__)("Item","formipay")),(0,t.createElement)("th",null,(0,n.__)("Qty","formipay")),(0,t.createElement)("th",null,(0,n.__)("Subtotal","formipay")))),(0,t.createElement)("tbody",null,i.items?.map((e,a)=>(0,t.createElement)("tr",{key:a},(0,t.createElement)("td",null,(0,t.createElement)("strong",null,e.item),e.description&&(0,t.createElement)("small",null,e.description)),(0,t.createElement)("td",null,e.qty||1),(0,t.createElement)("td",null,e.subtotal_formatted||e.subtotal)))||(0,t.createElement)("tr",null,(0,t.createElement)("td",{colSpan:"3",className:"text-center"},(0,n.__)("No items","formipay")))),(0,t.createElement)("tfoot",null,(0,t.createElement)("tr",null,(0,t.createElement)("td",{colSpan:"2"},(0,t.createElement)("strong",null,(0,n.__)("Total","formipay"))),(0,t.createElement)("td",null,(0,t.createElement)("strong",null,i.total_formatted||i.total))))))),(0,t.createElement)("div",{className:"formipay-detail-sidebar"},(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,n.__)("Customer Information","formipay")),i.form_data?(0,t.createElement)("dl",{className:"customer-info"},Object.entries(i.form_data).map(([e,a])=>["payment","payment_gateway","coupon_code","qty"].includes(e)?null:(0,t.createElement)("div",{key:e},(0,t.createElement)("dt",null,e.replace(/_/g," ")),(0,t.createElement)("dd",null,a?.value||a||"-")))):(0,t.createElement)("p",{className:"no-data"},(0,n.__)("No customer data available","formipay"))),(0,t.createElement)(N,{orderId:e}),(0,t.createElement)(A,null)))):(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-error"},(0,t.createElement)("p",null,(0,n.__)("Order not found","formipay")),(0,t.createElement)(r.Button,{variant:"secondary",onClick:o},(0,t.createElement)(l,{icon:h()(),size:16}),(0,n.__)("Back to Orders","formipay"))));var E}const O=window.Swal;function T({initialData:e=[],columns:l,filterOptions:o=null,statusCounts:i=null,searchable:c=!0,searchPlaceholder:s=(0,n.__)("Search...","formipay"),sortable:m=!0,defaultSort:d={id:"ID",desc:!0},selectable:p=!0,pagination:u=!0,pageSize:f=10,pageSizeOptions:y=[10,20,50,100],actions:_={addNew:!1,bulkDelete:!0,inline:!0},emptyMessage:E=(0,n.__)("No items found","formipay"),ajaxUrl:h,nonce:b,tableAction:g,deleteAction:w,duplicateAction:v}){const[N,k]=(0,a.useState)(e),[S,C]=(0,a.useState)(!0),[D,A]=(0,a.useState)(0),[I,P]=(0,a.useState)("all"),[T,x]=(0,a.useState)(""),[B,L]=(0,a.useState)(d.id||"ID"),[$,F]=(0,a.useState)(d.desc?"desc":"asc"),[j,U]=(0,a.useState)(1),[M,R]=(0,a.useState)(f),[z,J]=(0,a.useState)(new Set),[q,H]=(0,a.useState)(!1),[X,V]=(0,a.useState)(!1),[Z,G]=(0,a.useState)(""),K=g.replace("formipay-tabledata-",""),Q=_.bulkDelete?.action||`formipay-bulk-delete-${K}`,W=w||`formipay-delete-${K}`,Y=v||`formipay-duplicate-${K}`,ee=(0,a.useCallback)(async()=>{C(!0);const e=new URLSearchParams({action:g,_wpnonce:b,limit:M.toString(),offset:((j-1)*M).toString()});o&&"all"!==I&&e.append(o.key,I),T&&e.append("search",T),e.append("orderby",B),e.append("sort",$);try{const t=await fetch(`${h}?${e.toString()}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e}),a=await t.json(),n=a.data?.results||a.results||a.data||[];k(n),A(a.total||n.length)}catch(e){console.error("Load data error:",e)}finally{C(!1)}},[h,b,g,M,j,I,T,B,$,o]);return(0,a.useEffect)(()=>{ee()},[ee]),(0,a.useEffect)(()=>{const e=setTimeout(()=>{null!==T&&U(1)},500);return()=>clearTimeout(e)},[T]),(0,t.createElement)("div",{className:"formipay-data-table-wrapper"},(0,t.createElement)("div",{className:"formipay-table-toolbar"},_.addNew&&(0,t.createElement)(r.Button,{variant:"primary",onClick:()=>V(!0)},_.addNew.label||(0,n.__)("+ Add New","formipay")),_.bulkDelete&&p&&z.size>0&&(0,t.createElement)(r.Button,{variant:"secondary",isDestructive:!0,onClick:async()=>{0!==z.size&&(await O.fire({icon:"info",html:(0,n.__)("Do you want to delete the selected item(s)?","formipay"),showCancelButton:!0,confirmButtonText:(0,n.__)("Confirm","formipay"),cancelButtonText:(0,n.__)("Cancel","formipay")})).isConfirmed&&(await fetch(`${h}?action=${Q}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({ids:Array.from(z),_wpnonce:b})}),J(new Set),H(!1),ee(),O.fire({title:(0,n.__)("Done!","formipay"),html:(0,n.__)("Items deleted successfully.","formipay"),icon:"success"}))}},(0,n.__)("Delete Selected","formipay")," (",z.size,")"),c&&(0,t.createElement)(r.TextControl,{placeholder:s,value:T,onChange:x,className:"formipay-table-search"}),m&&(0,t.createElement)(r.SelectControl,{value:`${B}-${$}`,options:[{label:(0,n.__)("ID ↓","formipay"),value:"ID-desc"},{label:(0,n.__)("ID ↑","formipay"),value:"ID-asc"},{label:(0,n.__)("Date ↓","formipay"),value:"date-desc"},{label:(0,n.__)("Date ↑","formipay"),value:"date-asc"},{label:(0,n.__)("Title A-Z","formipay"),value:"title-asc"},{label:(0,n.__)("Title Z-A","formipay"),value:"title-desc"}],onChange:e=>{const[t,a]=e.split("-");L(t),F(a)}})),o&&(0,t.createElement)("div",{className:"formipay-filter-tabs"},o.options.map(e=>(0,t.createElement)("button",{key:e.value,className:"filter-tab "+(I===e.value?"active":""),onClick:()=>{return t=e.value,P(t),void U(1);var t}},e.label,i&&(0,t.createElement)("span",{className:"count"},i[e.value]||0)))),(0,t.createElement)("div",{className:"formipay-table-container"},S?(0,t.createElement)("div",{className:"formipay-table-loading"},(0,t.createElement)(r.Spinner,null)):0===N.length?(0,t.createElement)("div",{className:"formipay-table-empty"},E):(0,t.createElement)("table",{className:"formipay-table wp-list-table widefat fixed striped"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,p&&(0,t.createElement)("th",{className:"column-select"},(0,t.createElement)("input",{type:"checkbox",checked:q,onChange:()=>{J(q?new Set:new Set(N.map(e=>e.ID||e.id))),H(!q)}})),l.map(e=>(0,t.createElement)("th",{key:e.key,className:`column-${e.key}`},e.label)),_.inline&&(0,t.createElement)("th",{className:"column-actions"},(0,n.__)("Actions","formipay")))),(0,t.createElement)("tbody",null,N.map((e,a)=>{const r=e.ID||e.id;return(0,t.createElement)("tr",{key:a,className:"formipay-table-row"},p&&(0,t.createElement)("td",null,(0,t.createElement)("input",{type:"checkbox",checked:z.has(r),onChange:()=>(e=>{const t=new Set(z);t.has(e)?t.delete(e):t.add(e),J(t),H(!1)})(r)})),l.map(a=>(0,t.createElement)("td",{key:a.key},a.render?a.render(e):e[a.key])),_.inline&&(0,t.createElement)("td",{className:"column-actions"},(0,t.createElement)("div",{className:"row-actions"},(0,t.createElement)("a",{href:`${window.formipayAdmin?.siteUrl||""}/wp-admin/post.php?post=${r}&action=edit`},(0,n.__)("Edit","formipay"))," | ",(0,t.createElement)("button",{className:"button-link delete",onClick:()=>(async e=>{(await O.fire({icon:"info",html:(0,n.__)("Do you want to delete this item?","formipay"),showCancelButton:!0,confirmButtonText:(0,n.__)("Delete Permanently","formipay"),cancelButtonText:(0,n.__)("Cancel","formipay")})).isConfirmed&&(await fetch(`${h}?action=${W}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({id:e,_wpnonce:b})}),ee())})(r)},(0,n.__)("Delete","formipay"))," | ",(0,t.createElement)("button",{className:"button-link duplicate",onClick:()=>(async e=>{(await O.fire({icon:"info",html:(0,n.__)("Do you want to duplicate this item?","formipay"),showCancelButton:!0,confirmButtonText:(0,n.__)("Confirm","formipay"),cancelButtonText:(0,n.__)("Cancel","formipay")})).isConfirmed&&(await fetch(`${h}?action=${Y}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({id:e,_wpnonce:b})}),ee())})(r)},(0,n.__)("Duplicate","formipay")))))})))),u&&D>M&&(0,t.createElement)("div",{className:"formipay-table-pagination"},(0,t.createElement)("div",{className:"pagination-info"},(0,n.__)("Showing","formipay")," ",(j-1)*M+1," - ",Math.min(j*M,D)," ",(0,n.__)("of","formipay")," ",D),(0,t.createElement)("div",{className:"pagination-controls"},(0,t.createElement)(r.Button,{variant:"secondary",disabled:1===j,onClick:()=>U(1)},"««"),(0,t.createElement)(r.Button,{variant:"secondary",disabled:1===j,onClick:()=>U(j-1)},"‹"),(0,t.createElement)("span",{className:"page-info"},(0,n.__)("Page","formipay")," ",j," ",(0,n.__)("of","formipay")," ",Math.ceil(D/M)),(0,t.createElement)(r.Button,{variant:"secondary",disabled:j>=Math.ceil(D/M),onClick:()=>U(j+1)},"›"),(0,t.createElement)(r.Button,{variant:"secondary",disabled:j>=Math.ceil(D/M),onClick:()=>U(Math.ceil(D/M))},"»"),(0,t.createElement)(r.SelectControl,{value:M.toString(),options:y.map(e=>({label:e.toString(),value:e.toString()})),onChange:e=>{R(parseInt(e)),U(1)}}))),_.addNew&&(0,t.createElement)(r.Modal,{title:_.addNew.label||(0,n.__)("Add New","formipay"),isOpen:X,onClose:()=>V(!1)},(0,t.createElement)(r.TextControl,{label:(0,n.__)("Title","formipay"),value:Z,onChange:G,autoFocus:!0}),(0,t.createElement)("div",{className:"formipay-modal-actions"},(0,t.createElement)(r.Button,{variant:"secondary",onClick:()=>V(!1)},(0,n.__)("Cancel","formipay")),(0,t.createElement)(r.Button,{variant:"primary",onClick:async()=>{if(!Z.trim())return void O.fire({html:(0,n.__)("Title is required.","formipay"),icon:"error"});const e=_.addNew.action,t=await fetch(`${h}?action=${e}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({title:Z,_wpnonce:b})}),a=await t.json();a.success?(V(!1),G(""),a.data.edit_post_url?window.location.href=a.data.edit_post_url:ee()):O.fire({html:a.data.message||(0,n.__)("Error creating item.","formipay"),icon:"error"})}},(0,n.__)("Create","formipay")))))}const x=window.wp["icons/build/plus"];var B=e.n(x);const L=window.wp["icons/build/minus"];var $=e.n(L);const F=window.wp["icons/build/eyeClosed"];var j=e.n(F);const U=window.wp["icons/build/eyeOpened"];var M=e.n(U);function R({productId:e,productDetails:r}){const[l,o]=(0,a.useState)([]),[i,c]=(0,a.useState)([]),[s,m]=(0,a.useState)(!0),d=(0,a.useRef)(null),p=(0,a.useRef)(null),u=(0,a.useRef)(null),f=(0,a.useCallback)(()=>String(r?.default_currency||"").split(":::")[0]||r?.default_currency_code||"USD",[r]),y=(0,a.useCallback)(e=>{const t=r?.global_currencies||[],a=String(e).split(":::")[0],n=t.find(e=>String(e.currency).split(":::")[0]===a);return parseInt(n?.decimal_digits,10)||2},[r]),_=(0,a.useCallback)(()=>{const e=r?.global_selected_currencies||{};let t=Object.keys(e);if(!t.length){const e=r?.default_currency||"";e&&(t=[e])}return t.map(e=>{const t=String(e).split(":::")[0];return{currency:e,regular_price:"",sale_price:"",currency_decimal_digits:y(t)}})},[r,y]),E=(0,a.useCallback)(e=>{const t={...e};void 0===t.expanded&&(t.expanded=!1);const a=_(),n=e=>String(e).split(":::")[0];if(Array.isArray(t.prices)){const e=new Set(a.map(e=>n(e.currency)));t.prices=t.prices.filter(t=>t&&e.has(n(t.currency))),a.forEach(e=>{const a=n(e.currency);t.prices.some(e=>n(e.currency)===a)||t.prices.push(JSON.parse(JSON.stringify(e)))})}else t.prices=JSON.parse(JSON.stringify(a));Array.isArray(t.prices)&&0!==t.prices.length||(t.prices=JSON.parse(JSON.stringify(a))),t.prices.forEach(e=>{const t=n(e.currency);e.currency_decimal_digits=y(t),void 0!==e.regular_price&&null!==e.regular_price||(e.regular_price=""),void 0!==e.sale_price&&null!==e.sale_price||(e.sale_price="")});const r=f();return t.prices.sort((e,t)=>n(e.currency)===r?-1:n(t.currency)===r?1:0),delete t.price,delete t.sale,t},[_,y,f]),h=(0,a.useCallback)(()=>new Promise(e=>{let t=0;const a=setInterval(()=>{const n=document.querySelector('input[name="product_variation_attributes"]');if(n&&n.value)try{const t=JSON.parse(n.value);clearInterval(a),e(Array.isArray(t)?t:[])}catch(t){clearInterval(a),e([])}else++t>=100&&(clearInterval(a),e([]))},50)}),[]),b=(0,a.useCallback)(e=>{const t=e.map(e=>(e.attribute_variations||[]).map(e=>({label:e.variation_label}))).filter(e=>e.length>0);return t.length?t.reduce((e,t)=>e.flatMap(e=>t.map(t=>[].concat(e,t)))).map(e=>{const t=Array.isArray(e)?e.map(e=>e.label):[e.label];return{key:t.join("||"),label:t.join(" - ")}}):[]},[]),g=(0,a.useCallback)(async()=>{try{const e=await h();if(!e.length)return o([]),void w([]);const t=b(e).filter(e=>!i.includes(e.key)).map(e=>{const t=l.find(t=>t.key===e.key);return t?Object.assign(E(t),{name:e.label}):E({key:e.key,name:e.label,stock:"",weight:0,active:!0})});o(t),w(t)}catch(e){console.warn("Attributes not available; initializing empty variations."),o([]),w([])}},[h,b,i,l,E]),w=(0,a.useCallback)(e=>{d.current&&(d.current.value=JSON.stringify(e||[]))},[]),v=(0,a.useCallback)(async()=>{if(e)try{const t=new FormData;t.append("action","get_product_variables"),t.append("post_id",e),t.append("_wpnonce",window.formipayAdmin?.nonce||"");const a=await fetch(window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",{method:"POST",credentials:"same-origin",body:t}),n=await a.json();if(n.success&&Array.isArray(n.data)&&n.data.length){const e=n.data.map(e=>E(e));o(e),c([]),w(e)}else await g()}catch{await g()}else await g()},[e,E,g,w]),N=(0,a.useCallback)(()=>{const e=()=>{setTimeout(()=>{g()},200)},t=document.querySelector('input[name="product_variation_attributes"]');if(t){t.addEventListener("input",e),t.addEventListener("change",e);const a=new MutationObserver(e);a.observe(t,{attributes:!0,attributeFilter:["value"]}),u.current=a,p.current=setInterval(()=>{const t=document.querySelector('input[name="product_variation_attributes"]');t&&t.value!==d.current?.value&&e()},300)}return()=>{u.current&&u.current.disconnect(),p.current&&clearInterval(p.current)}},[g]);(0,a.useEffect)(()=>{const e=r?.multicurrency,t=r?.global_selected_currencies||{},a=Object.keys(t).length;return m(!e||a<=1),v(),N()},[r,v,N]);const k=(0,a.useCallback)((e,t,a,n)=>{const r=[...l];r[e].prices[t][a]=n,o(r),w(r)},[l,w]),S=(0,a.useCallback)(e=>{const t=[...l];t[e].expanded=!t[e].expanded,o(t)},[l]),C=(0,a.useCallback)((e,t,a)=>{const n=[...l];n[e][t]=a,o(n),w(n)},[l,w]),D=(0,a.useCallback)(e=>{const t=l[e],a=[...i,t.key];c(a);const n=l.filter((t,a)=>a!==e);o(n),w(n)},[l,i,w]),A=(0,a.useCallback)(()=>{const e=f();for(const t of l){const a=t.prices?.find(t=>String(t.currency).split(":::")[0]===e);if(!a||!a.regular_price)return{currencyCode:e,rowLabel:t.name}}return null},[l,f]);return(0,a.useEffect)(()=>{const e=document.getElementById("post");if(!e)return;const t=e=>{const t=A();if(t){e.preventDefault(),e.stopImmediatePropagation();const a=(r?.variation_table?.error_missing_default_price||'Please fill Regular Price for default currency (%1$s) in variation "%2$s".').replace("%1$s",t.currencyCode).replace("%2$s",t.rowLabel);return alert(a),!1}};return e.addEventListener("submit",t,!0),()=>e.removeEventListener("submit",t,!0)},[A,r]),(0,t.createElement)(t.Fragment,null,(0,t.createElement)("input",{ref:d,type:"hidden",name:"product_variation_variables",value:JSON.stringify(l)}),(0,t.createElement)("table",{className:"formipay-variation-table",id:"product-variables-table"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,n.__)("Variation","formipay")),s?(0,t.createElement)(t.Fragment,null,(0,t.createElement)("th",null,(0,n.__)("Price","formipay")),(0,t.createElement)("th",null,(0,n.__)("Sale Price","formipay"))):null,(0,t.createElement)("th",null,(0,n.__)("Stock","formipay")),(0,t.createElement)("th",null,(0,n.__)("Weight","formipay")),(0,t.createElement)("th",null,(0,n.__)("Actions","formipay")))),(0,t.createElement)("tbody",null,l.map((e,a)=>(0,t.createElement)(z,{key:e.key,row:e,rowIndex:a,showFlatPricing:s,defaultCurrencyCode:f(),onToggleExpanded:()=>S(a),onUpdatePrice:(e,t,n)=>k(a,e,t,n),onUpdateField:(e,t)=>C(a,e,t),onDelete:()=>D(a)})))))}function z({row:e,rowIndex:a,showFlatPricing:o,defaultCurrencyCode:i,onToggleExpanded:c,onUpdatePrice:s,onUpdateField:m,onDelete:d}){return(0,t.createElement)(t.Fragment,null,(0,t.createElement)("tr",{className:"variation-row"},(0,t.createElement)("td",{className:"variation-name"},(0,t.createElement)("button",{type:"button",className:"toggle-expand",onClick:c},(0,t.createElement)(l,{icon:e.expanded?M():j(),size:16})),(0,t.createElement)("strong",null,e.name)),o?(0,t.createElement)(t.Fragment,null,(0,t.createElement)(J,{price:e.prices[0],field:"regular_price",onChange:(e,t)=>s(0,e,t)}),(0,t.createElement)(J,{price:e.prices[0],field:"sale_price",onChange:(e,t)=>s(0,e,t)})):null,(0,t.createElement)("td",{className:"variation-stock"},(0,t.createElement)(r.TextControl,{type:"number",value:e.stock,onChange:e=>m("stock",e),placeholder:"Unlimited"})),(0,t.createElement)("td",{className:"variation-weight"},(0,t.createElement)(r.TextControl,{type:"number",value:e.weight,onChange:e=>m("weight",e),step:"0.01"})),(0,t.createElement)("td",{className:"variation-actions"},(0,t.createElement)(r.Button,{variant:"secondary",size:"small",isDestructive:!0,onClick:d,icon:$()()},(0,n.__)("Delete","formipay")))),!o&&e.expanded&&(0,t.createElement)("tr",{className:"variation-details-row"},(0,t.createElement)("td",{colSpan:"5"},(0,t.createElement)("table",{className:"inner-table"},(0,t.createElement)("tbody",null,e.prices.map((e,a)=>{const n=String(e.currency).split(":::")[0]===i,r=e.currency_decimal_digits?1/Math.pow(10,e.currency_decimal_digits):.01;return(0,t.createElement)("tr",{key:a},(0,t.createElement)("td",{className:"currency-name"},e.currency,n&&(0,t.createElement)("span",{className:"required"},"*")),(0,t.createElement)("td",null,(0,t.createElement)("input",{type:"number",value:e.regular_price,onChange:e=>s(a,"regular_price",e.target.value),step:r,placeholder:"Regular Price",required:n})),(0,t.createElement)("td",null,(0,t.createElement)("input",{type:"number",value:e.sale_price,onChange:e=>s(a,"sale_price",e.target.value),step:r,placeholder:"Sale Price"})))}))))))}function J({price:e,field:a,onChange:n}){const r=e.currency_decimal_digits?1/Math.pow(10,e.currency_decimal_digits):.01;return(0,t.createElement)("td",{className:"price-cell"},(0,t.createElement)("input",{type:"number",value:e[a],onChange:e=>n(a,e.target.value),step:r,placeholder:"Auto"}))}const q=window.Swal,H={orders:function({initialData:e}){const[n,r]=(0,a.useState)(null);return n?(0,t.createElement)(P,{orderId:n,onBack:()=>r(null)}):(0,t.createElement)(_,{onSelectOrder:e=>r(e)})},customers:function({initialData:e}){const[r,l]=(0,a.useState)([]),[o,i]=(0,a.useState)(!0),c=(0,a.useCallback)(()=>{i(!0),((e={})=>m("formipay-tabledata-customers",e))().then(e=>{const t=e.data?.results||e.results||e.data||[];l(t)}).catch(e=>{console.error("Load customers error:",e)}).finally(()=>{i(!1)})},[]);(0,a.useEffect)(()=>{c()},[c]);const s=[{key:"id",label:(0,n.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"name",label:(0,n.__)("Name","formipay"),render:e=>e.name||e.full_name||"-"},{key:"email",label:(0,n.__)("Email","formipay")},{key:"phone",label:(0,n.__)("Phone","formipay"),render:e=>e.phone||e.whatsapp||"-"},{key:"total_order",label:(0,n.__)("Total Orders","formipay"),render:e=>e.total_order||e.total_orders||0},{key:"created_date",label:(0,n.__)("Date","formipay"),render:e=>{const t=e.created_date||e.date;return t?new Date(t).toLocaleDateString():"-"}}];return(0,t.createElement)("div",{className:"formipay-page-customers"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,n.__)("Customers","formipay"))),(0,t.createElement)(T,{columns:s,data:r,loading:o,emptyMessage:(0,n.__)("No customers found","formipay")}))},products:function({initialData:e}){const[r,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),s=e?.productDetails||{};return r&&i?(0,t.createElement)("div",{className:"formipay-page-products"},(0,t.createElement)("div",{className:"formipay-products-header"},(0,t.createElement)("button",{type:"button",className:"button button-secondary",onClick:()=>o(!1)},"← ",(0,n.__)("Back to Products","formipay")),(0,t.createElement)("h1",null,(0,n.__)("Edit Product","formipay"))),(0,t.createElement)("div",{className:"formipay-product-editor"},(0,t.createElement)(R,{productId:i,productDetails:s}))):(0,t.createElement)("div",{className:"formipay-page-products"},(0,t.createElement)("div",{className:"formipay-products-list-header"},(0,t.createElement)("h1",null,(0,n.__)("Products","formipay")),(0,t.createElement)("button",{type:"button",className:"button button-primary",onClick:()=>{c(null),o(!0)}},(0,t.createElement)(l,{icon:B()(),size:16}),(0,n.__)("Add New Product","formipay"))),(0,t.createElement)("p",{className:"formipay-coming-soon"},(0,n.__)("Products list coming soon. Use the classic editor for now.","formipay")))},forms:function(){const e=[{key:"ID",label:(0,n.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.ID)},{key:"title",label:(0,n.__)("Title","formipay"),render:e=>(0,t.createElement)(t.Fragment,null,(0,t.createElement)("strong",null,e.title),(0,t.createElement)("br",null),(0,t.createElement)("span",{className:"row-actions",style:{display:"none",visibility:"hidden"}},(0,t.createElement)("a",{href:`${window.formipayAdmin?.siteUrl||""}/wp-admin/post.php?post=${e.ID}&action=edit`},(0,n.__)("Edit","formipay"))," | ",(0,t.createElement)("button",{className:"button-link delete","data-id":e.ID},(0,n.__)("Delete","formipay"))," | ",(0,t.createElement)("button",{className:"button-link duplicate","data-id":e.ID},(0,n.__)("Duplicate","formipay"))))},{key:"date",label:(0,n.__)("Date","formipay"),render:e=>{const a=new Date(e.date);return(0,t.createElement)("span",{style:{whiteSpace:"nowrap"}},a.toLocaleDateString(),(0,t.createElement)("br",null),(0,t.createElement)("span",{style:{fontSize:"smaller",color:"#646970"}},a.toLocaleTimeString()))}},{key:"status",label:(0,n.__)("Status","formipay"),render:e=>{const a=e.post_status||e.status||"unknown",r={publish:(0,n.__)("Published","formipay"),draft:(0,n.__)("Draft","formipay"),pending:(0,n.__)("Pending","formipay")};return(0,t.createElement)("span",{className:`status-label ${a}`},r[a]||a)}},{key:"shortcode",label:(0,n.__)("Shortcode","formipay"),render:e=>(0,t.createElement)(t.Fragment,null,(0,t.createElement)("input",{className:"formipay-form-shortcode",value:`[formipay form=${e.ID}]`,disabled:!0}),(0,t.createElement)("button",{className:"copy-shortcode","data-copy":`[formipay form=${e.ID}]`,onClick:e=>{const t=e.currentTarget.dataset.copy;navigator.clipboard.writeText(t).then(()=>{const t=e.currentTarget.innerHTML;e.currentTarget.innerHTML="✓ Copied",setTimeout(()=>{e.currentTarget.innerHTML=t},2e3),q.fire({icon:"success",title:(0,n.__)("Shortcode copied!","formipay"),toast:!0,position:"top-end",showConfirmButton:!1,timer:3e3,timerProgressBar:!0})})}},"📋 ",(0,n.__)("Copy","formipay")))}];return(0,t.createElement)("div",{className:"formipay-page-forms"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,n.__)("Forms","formipay"))),(0,t.createElement)(T,{columns:e,ajaxUrl:window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",nonce:window.formipayAdmin?.nonce||"",tableAction:"formipay-tabledata-forms",deleteAction:"formipay-delete-form",duplicateAction:"formipay-duplicate-form",filterOptions:{key:"post_status",options:[{value:"all",label:(0,n.__)("All","formipay")},{value:"publish",label:(0,n.__)("Published","formipay")},{value:"draft",label:(0,n.__)("Draft","formipay")}]},actions:{addNew:{label:(0,n.__)("+ Add New Form","formipay"),action:"formipay-create-form-post"},bulkDelete:{action:"formipay-bulk-delete-form"},inline:!0},emptyMessage:(0,n.__)("No forms found","formipay")}))},coupons:function({initialData:e}){const[l,o]=(0,a.useState)([]),[i,c]=(0,a.useState)(!0),s=(0,a.useCallback)(()=>{c(!0),((e={})=>m("formipay-tabledata-coupons",e))().then(e=>{const t=e.data?.results||e.results||e.data||[];o(t)}).catch(e=>{console.error("Load coupons error:",e)}).finally(()=>{c(!1)})},[]);(0,a.useEffect)(()=>{s()},[s]);const d=[{key:"id",label:(0,n.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"code",label:(0,n.__)("Coupon Code","formipay"),render:e=>(0,t.createElement)("strong",null,e.code||e.post_title)},{key:"type",label:(0,n.__)("Type","formipay"),render:e=>"percentage"===(e.coupon_type||e.type||"percentage")?(0,n.__)("%","formipay"):(0,n.__)("Fixed","formipay")},{key:"amount",label:(0,n.__)("Amount","formipay")},{key:"usages",label:(0,n.__)("Usages","formipay"),render:e=>e.usage_count||e.usages||0},{key:"status",label:(0,n.__)("Status","formipay"),render:e=>"publish"===(e.post_status||e.status||"unknown")?(0,n.__)("Active","formipay"):(0,n.__)("Inactive","formipay")}];return(0,t.createElement)("div",{className:"formipay-page-coupons"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,n.__)("Coupons","formipay")),(0,t.createElement)(r.Button,{variant:"primary",onClick:()=>{const e=prompt((0,n.__)("Enter coupon code:","formipay"));var t;e&&(t={code:e},m("formipay-create-coupon-post",t)).then(()=>s()).catch(console.error)}},(0,n.__)("+ Add New Coupon","formipay"))),(0,t.createElement)(T,{columns:d,data:l,loading:i,emptyMessage:(0,n.__)("No coupons found","formipay")}))},access:function({initialData:e}){const[l,o]=(0,a.useState)([]),[i,c]=(0,a.useState)(!0),s=(0,a.useCallback)(()=>{c(!0),((e={})=>m("formipay-tabledata-access-items",e))().then(e=>{const t=e.data?.results||e.results||e.data||[];o(t)}).catch(e=>{console.error("Load access items error:",e)}).finally(()=>{c(!1)})},[]);(0,a.useEffect)(()=>{s()},[s]);const d=[{key:"id",label:(0,n.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"title",label:(0,n.__)("Title","formipay")},{key:"product_name",label:(0,n.__)("Product","formipay")},{key:"status",label:(0,n.__)("Status","formipay"),render:e=>{const a=e.post_status||e.status||"unknown",r={publish:(0,n.__)("Published","formipay"),draft:(0,n.__)("Draft","formipay")}[a]||a;return(0,t.createElement)("span",{className:`status-badge status-${a}`},r)}},{key:"date",label:(0,n.__)("Date","formipay"),render:e=>{const t=e.post_date||e.date;return t?new Date(t).toLocaleDateString():"-"}}];return(0,t.createElement)("div",{className:"formipay-page-access"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,n.__)("Access Items","formipay")),(0,t.createElement)(r.Button,{variant:"primary",href:window.formipayAdmin?.siteUrl+"/wp-admin/post-new.php?post_type=formipay-access"},(0,n.__)("+ Add New Item","formipay"))),(0,t.createElement)(T,{columns:d,data:l,loading:i,emptyMessage:(0,n.__)("No access items found","formipay")}))},licenses:function({initialData:e}){const[r,l]=(0,a.useState)([]),[o,i]=(0,a.useState)(!0),c=(0,a.useCallback)(()=>{i(!0),fetch(window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"formipay-tabledata-licenses",_wpnonce:window.formipayAdmin?.nonce||""})}).then(e=>e.json()).then(e=>{const t=e.data?.results||e.results||e.data||[];l(t)}).catch(e=>{console.error("Load licenses error:",e)}).finally(()=>{i(!1)})},[]);(0,a.useEffect)(()=>{c()},[c]);const s=[{key:"id",label:(0,n.__)("ID","formipay"),render:e=>(0,t.createElement)("strong",null,"#",e.id)},{key:"license_key",label:(0,n.__)("License Key","formipay"),render:e=>(0,t.createElement)("code",null,e.license_key||"-")},{key:"product",label:(0,n.__)("Product","formipay"),render:e=>e.product_name||e.product||"-"},{key:"order",label:(0,n.__)("Order","formipay"),render:e=>e.order_id||`#${e.order}`||"-"},{key:"email",label:(0,n.__)("Email","formipay")},{key:"status",label:(0,n.__)("Status","formipay"),render:e=>{const t=e.status||"unknown";return{active:(0,n.__)("Active","formipay"),inactive:(0,n.__)("Inactive","formipay"),expired:(0,n.__)("Expired","formipay")}[t]||t}}];return(0,t.createElement)("div",{className:"formipay-page-licenses"},(0,t.createElement)("div",{className:"formipay-page-licenses"},(0,t.createElement)("div",{className:"formipay-page-header"},(0,t.createElement)("h1",null,(0,n.__)("Licenses","formipay"))),(0,t.createElement)(T,{columns:s,data:r,loading:o,emptyMessage:(0,n.__)("No licenses found","formipay")})))}};function X({page:e,initialData:n}){(0,a.useEffect)(()=>{console.log("[Formipay App] Rendering page:",e,"with data:",n)},[e,n]);const r=H[e];return r?(0,t.createElement)("div",{className:"formipay-admin-wrap"},(0,t.createElement)(r,{initialData:n})):(0,t.createElement)("div",{className:"formipay-error"},(0,t.createElement)("p",null,"Unknown page: ",e))}const V=()=>{const e=document.querySelectorAll("[data-formipay-mount]");console.log("[Formipay] Mount points found:",e.length),console.log("[Formipay] formipayAdmin data:",window.formipayAdmin),e.forEach(e=>{const n=e.dataset.formipayMount,r=window.formipayAdmin?.[n]||{};console.log("[Formipay] Mounting page:",n,"with data:",r);try{(0,a.render)((0,t.createElement)(X,{page:n,initialData:r}),e),console.log("[Formipay] Successfully mounted:",n)}catch(e){console.error("[Formipay] Failed to mount:",n,e)}})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",V):V()})(); \ No newline at end of file diff --git a/node_modules/.cache/babel-loader/14b79987dc3a84ec3a760fa9a4ef506e3ce0455b2ffc6fe20655310e48e3fcfa.json.gz b/node_modules/.cache/babel-loader/14b79987dc3a84ec3a760fa9a4ef506e3ce0455b2ffc6fe20655310e48e3fcfa.json.gz new file mode 100644 index 000000000..da9224def Binary files /dev/null and b/node_modules/.cache/babel-loader/14b79987dc3a84ec3a760fa9a4ef506e3ce0455b2ffc6fe20655310e48e3fcfa.json.gz differ diff --git a/node_modules/.cache/babel-loader/3a08871aa808e620b9298452a2638f076758a922a7013dae8f82212b9abb6739.json.gz b/node_modules/.cache/babel-loader/3a08871aa808e620b9298452a2638f076758a922a7013dae8f82212b9abb6739.json.gz new file mode 100644 index 000000000..d8a727a91 Binary files /dev/null and b/node_modules/.cache/babel-loader/3a08871aa808e620b9298452a2638f076758a922a7013dae8f82212b9abb6739.json.gz differ diff --git a/node_modules/.cache/babel-loader/3e0c80852595c04cdb34c154a893d8d91023a3de95e1efd6f29d107893ef8cde.json.gz b/node_modules/.cache/babel-loader/3e0c80852595c04cdb34c154a893d8d91023a3de95e1efd6f29d107893ef8cde.json.gz new file mode 100644 index 000000000..431e592ab Binary files /dev/null and b/node_modules/.cache/babel-loader/3e0c80852595c04cdb34c154a893d8d91023a3de95e1efd6f29d107893ef8cde.json.gz differ diff --git a/node_modules/.cache/babel-loader/565207e7fbd18187e191263c954119a26bbd7b51edc56eb9447ae968ea1f9725.json.gz b/node_modules/.cache/babel-loader/565207e7fbd18187e191263c954119a26bbd7b51edc56eb9447ae968ea1f9725.json.gz new file mode 100644 index 000000000..b4a1e43e4 Binary files /dev/null and b/node_modules/.cache/babel-loader/565207e7fbd18187e191263c954119a26bbd7b51edc56eb9447ae968ea1f9725.json.gz differ diff --git a/node_modules/.cache/babel-loader/59e6cb50a62c21cd73de0ec3a02847e236cca65f4149c9c42135fa79a1f8d24b.json.gz b/node_modules/.cache/babel-loader/59e6cb50a62c21cd73de0ec3a02847e236cca65f4149c9c42135fa79a1f8d24b.json.gz new file mode 100644 index 000000000..f0de51a25 Binary files /dev/null and b/node_modules/.cache/babel-loader/59e6cb50a62c21cd73de0ec3a02847e236cca65f4149c9c42135fa79a1f8d24b.json.gz differ diff --git a/node_modules/.cache/babel-loader/5aab4366ac87b889d35d3e884b6b07308dacff02cd1b74d9d32eff007bcff386.json.gz b/node_modules/.cache/babel-loader/5aab4366ac87b889d35d3e884b6b07308dacff02cd1b74d9d32eff007bcff386.json.gz new file mode 100644 index 000000000..07a59fd46 Binary files /dev/null and b/node_modules/.cache/babel-loader/5aab4366ac87b889d35d3e884b6b07308dacff02cd1b74d9d32eff007bcff386.json.gz differ diff --git a/node_modules/.cache/babel-loader/7e14adc209a2f91edde190f1c99acfcf3d64a741cb2fb022cf781fac4171a8f0.json.gz b/node_modules/.cache/babel-loader/7e14adc209a2f91edde190f1c99acfcf3d64a741cb2fb022cf781fac4171a8f0.json.gz new file mode 100644 index 000000000..7b144abf4 Binary files /dev/null and b/node_modules/.cache/babel-loader/7e14adc209a2f91edde190f1c99acfcf3d64a741cb2fb022cf781fac4171a8f0.json.gz differ diff --git a/node_modules/.cache/babel-loader/8c0f4882f684e83867700f22af9cdb354be15632d4208fff53cb9d84f7309af6.json.gz b/node_modules/.cache/babel-loader/8c0f4882f684e83867700f22af9cdb354be15632d4208fff53cb9d84f7309af6.json.gz new file mode 100644 index 000000000..a3e7979d6 Binary files /dev/null and b/node_modules/.cache/babel-loader/8c0f4882f684e83867700f22af9cdb354be15632d4208fff53cb9d84f7309af6.json.gz differ diff --git a/node_modules/.cache/babel-loader/c606103bba57e717885d000da0ada54cbeaf869a996fcecc39b58034960a9cdb.json.gz b/node_modules/.cache/babel-loader/c606103bba57e717885d000da0ada54cbeaf869a996fcecc39b58034960a9cdb.json.gz new file mode 100644 index 000000000..90c7fb229 Binary files /dev/null and b/node_modules/.cache/babel-loader/c606103bba57e717885d000da0ada54cbeaf869a996fcecc39b58034960a9cdb.json.gz differ diff --git a/node_modules/.cache/babel-loader/e45f6611ae3be43cc6b5aa48e32a8dca1bac0185e9a5467996f9400108d8b99c.json.gz b/node_modules/.cache/babel-loader/e45f6611ae3be43cc6b5aa48e32a8dca1bac0185e9a5467996f9400108d8b99c.json.gz new file mode 100644 index 000000000..46905b88a Binary files /dev/null and b/node_modules/.cache/babel-loader/e45f6611ae3be43cc6b5aa48e32a8dca1bac0185e9a5467996f9400108d8b99c.json.gz differ diff --git a/src/admin/components/shared/DataTable.css b/src/admin/components/shared/DataTable.css index 4662ecb56..bafd3c92f 100644 --- a/src/admin/components/shared/DataTable.css +++ b/src/admin/components/shared/DataTable.css @@ -1,26 +1,269 @@ -.formipay-data-table-loading, -.formipay-data-table-empty { - padding: 40px; - text-align: center; +/* DataTable Wrapper */ +.formipay-data-table-wrapper { + margin: 20px 0; } -.formipay-data-table { - margin-top: 20px; +/* Toolbar */ +.formipay-table-toolbar { + display: flex; + gap: 12px; + align-items: center; + flex-wrap: wrap; + margin-bottom: 16px; } -.formipay-data-table thead th { - padding: 12px 10px; +.formipay-table-search { + max-width: 300px; + flex-grow: 1; +} + +.formipay-table-toolbar .components-select-control { + min-width: 150px; +} + +/* Filter Tabs */ +.formipay-filter-tabs { + display: flex; + gap: 4px; + margin-bottom: 16px; + border-bottom: 1px solid #ddd; +} + +.formipay-filter-tabs .filter-tab { + padding: 8px 16px; + background: transparent; + border: none; + border-bottom: 3px solid transparent; + cursor: pointer; + font-size: 13px; + color: #646970; + transition: all 0.2s; +} + +.formipay-filter-tabs .filter-tab:hover { + color: #135e96; + background: #f0f0f1; +} + +.formipay-filter-tabs .filter-tab.active { + color: #135e96; + border-bottom-color: #135e96; font-weight: 600; } -.formipay-data-table tbody td { - padding: 10px; +.formipay-filter-tabs .filter-tab .count { + display: inline-block; + min-width: 18px; + padding: 2px 6px; + margin-left: 6px; + background: #dcdcde; + border-radius: 10px; + font-size: 11px; + line-height: 1.4; } -.formipay-data-table tbody tr.is-clickable { +.formipay-filter-tabs .filter-tab.active .count { + background: #135e96; + color: #fff; +} + +/* Table Container */ +.formipay-table-container { + background: #fff; + border: 1px solid #c3c4c7; + box-shadow: 0 1px 1px rgba(0,0,0,.04); +} + +.formipay-table-loading { + padding: 60px; + text-align: center; +} + +.formipay-table-empty { + padding: 40px; + text-align: center; + color: #646970; +} + +/* Table */ +.formipay-table { + width: 100%; + border-collapse: collapse; +} + +.formipay-table thead th { + padding: 12px 10px; + font-weight: 600; + text-align: left; + border-bottom: 1px solid #c3c4c7; + background: #f6f7f7; +} + +.formipay-table tbody td { + padding: 10px; + border-bottom: 1px solid #c3c4c7; +} + +.formipay-table tbody tr:last-child td { + border-bottom: none; +} + +.formipay-table tbody tr:hover { + background-color: #f0f0f1; +} + +/* Checkbox Column */ +.formipay-table .column-select { + width: 40px; + text-align: center; +} + +.formipay-table tbody td:first-child input[type="checkbox"] { + margin: 0; +} + +/* Actions Column */ +.formipay-table .column-actions { + width: 200px; +} + +.formipay-table .row-actions { + display: none; + visibility: hidden; +} + +.formipay-table tbody tr:hover .row-actions { + display: block; + visibility: visible; +} + +.formipay-table .row-actions a, +.formipay-table .row-actions .button-link { + text-decoration: none; + color: #a7aaad; cursor: pointer; } -.formipay-data-table tbody tr.is-clickable:hover { - background-color: #f0f0f1; +.formipay-table .row-actions a:hover, +.formipay-table .row-actions .button-link:hover { + color: #135e96; +} + +.formipay-table .row-actions .delete { + color: #b32d2e; +} + +.formipay-table .row-actions .delete:hover { + color: #d63638; +} + +/* Status Labels */ +.formipay-table .status-label { + display: inline-block; + padding: 4px 8px; + border-radius: 4px; + font-size: 12px; + font-weight: 500; +} + +.formipay-table .status-label.publish { + background: #edfaef; + color: #007017; +} + +.formipay-table .status-label.draft { + background: #f0f0f1; + color: #646970; +} + +.formipay-table .status-label.pending { + background: #fff8e5; + color: #d63638; +} + +/* Shortcode Input */ +.formipay-table input.formipay-form-shortcode { + padding: 4px 8px; + border: 1px solid #8c8f94; + border-radius: 4px; + background: #f6f7f7; + color: #646970; + font-family: monospace; + font-size: 12px; + min-width: 150px; +} + +.formipay-table button.copy-shortcode { + padding: 4px 8px; + margin-left: 4px; + border: 1px solid #8c8f94; + border-radius: 4px; + background: #fff; + cursor: pointer; + display: inline-flex; + align-items: center; + gap: 4px; +} + +.formipay-table button.copy-shortcode:hover { + background: #f6f7f7; +} + +.formipay-table button.copy-shortcode svg { + width: 16px; + height: 16px; +} + +/* Pagination */ +.formipay-table-pagination { + display: flex; + justify-content: space-between; + align-items: center; + padding: 12px 16px; + background: #fff; + border: 1px solid #c3c4c7; + border-top: none; +} + +.formipay-table-pagination .pagination-info { + color: #646970; + font-size: 13px; +} + +.formipay-table-pagination .pagination-controls { + display: flex; + gap: 8px; + align-items: center; +} + +.formipay-table-pagination .page-info { + padding: 0 8px; + color: #646970; + font-size: 13px; +} + +.formipay-table-pagination .components-select-control { + min-width: 80px; +} + +/* Modal Actions */ +.formipay-modal-actions { + display: flex; + justify-content: flex-end; + gap: 12px; + margin-top: 20px; +} + +/* Sort Indicator */ +.formipay-table thead th.sorted { + position: relative; + padding-right: 20px; +} + +.formipay-table thead th .sort-indicator { + position: absolute; + right: 8px; + top: 50%; + transform: translateY(-50%); + color: #135e96; } diff --git a/src/admin/components/shared/DataTable.js b/src/admin/components/shared/DataTable.js index 53528fde0..697ec0764 100644 --- a/src/admin/components/shared/DataTable.js +++ b/src/admin/components/shared/DataTable.js @@ -1,57 +1,554 @@ /** - * Data Table - Simple table component for admin listings + * Full-featured DataTable component + * Supports: selection, filtering, search, sort, pagination, actions */ import { __ } from '@wordpress/i18n'; +import { useState, useCallback, useEffect } from '@wordpress/element'; +import { + Button, + Modal, + TextControl, + SelectControl, + Spinner, +} from '@wordpress/components'; import './DataTable.css'; -export default function DataTable({ - columns, - data, - loading, - emptyMessage = __('No items found', 'formipay'), - onRowClick -}) { - if (loading) { - return ( -
- -
- ); - } +// SweetAlert2 is loaded via WordPress (global scope) +const Swal = window.Swal; - if (!data || data.length === 0) { - return ( -
-

{ emptyMessage }

-
- ); - } +export default function DataTable({ + // Data fetching + initialData = [], + + // Columns definition + columns, + + // Filtering + filterOptions = null, // { key: 'post_status', options: [{value, label}] } + statusCounts = null, // { all: 10, publish: 5, draft: 5 } + + // Search + searchable = true, + searchPlaceholder = __('Search...', 'formipay'), + + // Sorting + sortable = true, + defaultSort = { id: 'ID', desc: true }, + + // Selection + selectable = true, + + // Pagination + pagination = true, + pageSize = 10, + pageSizeOptions = [10, 20, 50, 100], + + // Actions + actions = { + addNew: false, // { label, action: 'formipay-create-form-post' } + bulkDelete: true, // { action: 'formipay-bulk-delete-form' } + inline: true, // edit, delete, duplicate + }, + + // Empty state + emptyMessage = __('No items found', 'formipay'), + + // AJAX config + ajaxUrl, + nonce, + tableAction, // e.g., 'formipay-tabledata-forms' + deleteAction, + duplicateAction, +}) { + // State + const [data, setData] = useState(initialData); + const [loading, setLoading] = useState(true); + const [total, setTotal] = useState(0); + + // Filters + const [activeFilter, setActiveFilter] = useState('all'); + const [searchQuery, setSearchQuery] = useState(''); + + // Sorting + const [sortBy, setSortBy] = useState(defaultSort.id || 'ID'); + const [sortOrder, setSortOrder] = useState(defaultSort.desc ? 'desc' : 'asc'); + + // Pagination + const [currentPage, setCurrentPage] = useState(1); + const [currentPageSize, setCurrentPageSize] = useState(pageSize); + + // Selection + const [selectedRows, setSelectedRows] = useState(new Set()); + const [selectAll, setSelectAll] = useState(false); + + // Add New Modal + const [isAddModalOpen, setIsAddModalOpen] = useState(false); + const [newItemTitle, setNewItemTitle] = useState(''); + + // Derive action names from tableAction + const baseActionName = tableAction.replace('formipay-tabledata-', ''); + const bulkDeleteAction = actions.bulkDelete?.action || `formipay-bulk-delete-${baseActionName}`; + const deleteActionName = deleteAction || `formipay-delete-${baseActionName}`; + const duplicateActionName = duplicateAction || `formipay-duplicate-${baseActionName}`; + + // Load data + const loadData = useCallback(async () => { + setLoading(true); + + const params = new URLSearchParams({ + action: tableAction, + _wpnonce: nonce, + limit: currentPageSize.toString(), + offset: ((currentPage - 1) * currentPageSize).toString(), + }); + + // Add filter + if (filterOptions && activeFilter !== 'all') { + params.append(filterOptions.key, activeFilter); + } + + // Add search + if (searchQuery) { + params.append('search', searchQuery); + } + + // Add sort + params.append('orderby', sortBy); + params.append('sort', sortOrder); + + try { + const response = await fetch(`${ajaxUrl}?${params.toString()}`, { + method: 'POST', + credentials: 'same-origin', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: params, + }); + + const result = await response.json(); + const items = result.data?.results || result.results || result.data || []; + setData(items); + setTotal(result.total || items.length); + } catch (error) { + console.error('Load data error:', error); + } finally { + setLoading(false); + } + }, [ajaxUrl, nonce, tableAction, currentPageSize, currentPage, activeFilter, searchQuery, sortBy, sortOrder, filterOptions]); + + // Initial load and refresh on filter/sort/page change + useEffect(() => { + loadData(); + }, [loadData]); + + // Handle filter change + const handleFilterChange = (value) => { + setActiveFilter(value); + setCurrentPage(1); + }; + + // Handle search (debounced) + useEffect(() => { + const timeoutId = setTimeout(() => { + if (searchQuery !== null) { + setCurrentPage(1); + } + }, 500); + return () => clearTimeout(timeoutId); + }, [searchQuery]); + + // Handle selection + const handleRowSelect = (id) => { + const newSelected = new Set(selectedRows); + if (newSelected.has(id)) { + newSelected.delete(id); + } else { + newSelected.add(id); + } + setSelectedRows(newSelected); + setSelectAll(false); + }; + + const handleSelectAll = () => { + if (selectAll) { + setSelectedRows(new Set()); + } else { + setSelectedRows(new Set(data.map(row => row.ID || row.id))); + } + setSelectAll(!selectAll); + }; + + // Handle bulk delete + const handleBulkDelete = async () => { + if (selectedRows.size === 0) return; + + const result = await Swal.fire({ + icon: 'info', + html: __('Do you want to delete the selected item(s)?', 'formipay'), + showCancelButton: true, + confirmButtonText: __('Confirm', 'formipay'), + cancelButtonText: __('Cancel', 'formipay'), + }); + + if (result.isConfirmed) { + await fetch(`${ajaxUrl}?action=${bulkDeleteAction}`, { + method: 'POST', + credentials: 'same-origin', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: new URLSearchParams({ + ids: Array.from(selectedRows), + _wpnonce: nonce, + }), + }); + + setSelectedRows(new Set()); + setSelectAll(false); + loadData(); + + Swal.fire({ + title: __('Done!', 'formipay'), + html: __('Items deleted successfully.', 'formipay'), + icon: 'success', + }); + } + }; + + // Handle inline delete + const handleDelete = async (id) => { + const result = await Swal.fire({ + icon: 'info', + html: __('Do you want to delete this item?', 'formipay'), + showCancelButton: true, + confirmButtonText: __('Delete Permanently', 'formipay'), + cancelButtonText: __('Cancel', 'formipay'), + }); + + if (result.isConfirmed) { + await fetch(`${ajaxUrl}?action=${deleteActionName}`, { + method: 'POST', + credentials: 'same-origin', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: new URLSearchParams({ + id, + _wpnonce: nonce, + }), + }); + + loadData(); + } + }; + + // Handle duplicate + const handleDuplicate = async (id) => { + const result = await Swal.fire({ + icon: 'info', + html: __('Do you want to duplicate this item?', 'formipay'), + showCancelButton: true, + confirmButtonText: __('Confirm', 'formipay'), + cancelButtonText: __('Cancel', 'formipay'), + }); + + if (result.isConfirmed) { + await fetch(`${ajaxUrl}?action=${duplicateActionName}`, { + method: 'POST', + credentials: 'same-origin', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: new URLSearchParams({ + id, + _wpnonce: nonce, + }), + }); + + loadData(); + } + }; + + // Handle Add New + const handleAddNew = async () => { + if (!newItemTitle.trim()) { + Swal.fire({ + html: __('Title is required.', 'formipay'), + icon: 'error', + }); + return; + } + + const createAction = actions.addNew.action; + const result = await fetch(`${ajaxUrl}?action=${createAction}`, { + method: 'POST', + credentials: 'same-origin', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: new URLSearchParams({ + title: newItemTitle, + _wpnonce: nonce, + }), + }); + + const response = await result.json(); + + if (response.success) { + setIsAddModalOpen(false); + setNewItemTitle(''); + if (response.data.edit_post_url) { + window.location.href = response.data.edit_post_url; + } else { + loadData(); + } + } else { + Swal.fire({ + html: response.data.message || __('Error creating item.', 'formipay'), + icon: 'error', + }); + } + }; return ( - - - - {columns.map((column) => ( - - ))} - - - - {data.map((row, rowIndex) => ( - onRowClick(row) : undefined} - className={onRowClick ? 'is-clickable' : ''} +
+ {/* Toolbar */} +
+ {/* Add New Button */} + {actions.addNew && ( +
- ))} - - ))} - -
{column.label}
- {column.render ? column.render(row) : row[column.key]} -
+ {actions.addNew.label || __('+ Add New', 'formipay')} + + )} + + {/* Bulk Delete Button */} + {actions.bulkDelete && selectable && selectedRows.size > 0 && ( + + )} + + {/* Search */} + {searchable && ( + + )} + + {/* Sort */} + {sortable && ( + { + const [id, sort] = value.split('-'); + setSortBy(id); + setSortOrder(sort); + }} + /> + )} + + + {/* Filter Tabs */} + {filterOptions && ( +
+ {filterOptions.options.map(option => ( + + ))} +
+ )} + + {/* Table */} +
+ {loading ? ( +
+ +
+ ) : data.length === 0 ? ( +
+ {emptyMessage} +
+ ) : ( + + + + {/* Checkbox column */} + {selectable && ( + + )} + {/* Data columns */} + {columns.map((column) => ( + + ))} + {/* Actions column */} + {actions.inline && ( + + )} + + + + {data.map((row, rowIndex) => { + const rowId = row.ID || row.id; + return ( + + {/* Checkbox */} + {selectable && ( + + )} + {/* Data columns */} + {columns.map((column) => ( + + ))} + {/* Actions */} + {actions.inline && ( + + )} + + ); + })} + +
+ + + {column.label} + {__('Actions', 'formipay')}
+ handleRowSelect(rowId)} + /> + + {column.render ? column.render(row) : row[column.key]} + +
+ + {__('Edit', 'formipay')} + + {' | '} + + {' | '} + +
+
+ )} +
+ + {/* Pagination */} + {pagination && total > currentPageSize && ( +
+
+ {__('Showing', 'formipay')} {((currentPage - 1) * currentPageSize) + 1} - {Math.min(currentPage * currentPageSize, total)} {__('of', 'formipay')} {total} +
+
+ + + + {__('Page', 'formipay')} {currentPage} {__('of', 'formipay')} {Math.ceil(total / currentPageSize)} + + + + ({ + label: size.toString(), + value: size.toString(), + }))} + onChange={(value) => { + setCurrentPageSize(parseInt(value)); + setCurrentPage(1); + }} + /> +
+
+ )} + + {/* Add New Modal */} + {actions.addNew && ( + setIsAddModalOpen(false)} + > + +
+ + +
+
+ )} + ); } diff --git a/src/admin/pages/Forms.js b/src/admin/pages/Forms.js index 7462b28e9..9ada82d7a 100644 --- a/src/admin/pages/Forms.js +++ b/src/admin/pages/Forms.js @@ -1,74 +1,59 @@ /** - * Forms Page - List view and Form Builder + * Forms Page - Form management with full table features */ import { __ } from '@wordpress/i18n'; -import { useState, useCallback, useEffect } from '@wordpress/element'; -import { Button } from '@wordpress/components'; -import { formsApi } from '../api/client'; import DataTable from '../components/shared/DataTable'; import './AdminPages.css'; -export default function FormsPage({ initialData }) { - const [isBuilder, setIsBuilder] = useState(false); - const [selectedFormId, setSelectedFormId] = useState(null); - const [forms, setForms] = useState([]); - const [loading, setLoading] = useState(true); - - const loadForms = useCallback(() => { - setLoading(true); - formsApi.list() - .then(result => { - console.log('Forms API result:', result); - // Handle both WordPress format and direct format - const formsData = result.data?.results || result.results || result.data || []; - console.log('Forms data extracted:', formsData); - console.log('Forms data length:', formsData.length); - setForms(formsData); - }) - .catch(error => { - console.error('Load forms error:', error); - }) - .finally(() => { - setLoading(false); - }); - }, []); - - useEffect(() => { - loadForms(); - }, [loadForms]); - - if (isBuilder && selectedFormId) { - window.location.href = `${window.formipayAdmin?.siteUrl || ''}/wp-admin/post.php?post=${selectedFormId}&action=edit`; - return null; - } +// SweetAlert2 is loaded via WordPress (global scope) +const Swal = window.Swal; +export default function FormsPage() { const columns = [ { - key: 'id', + key: 'ID', label: __('ID', 'formipay'), - render: (row) => #{row.ID || row.id} + render: (row) => #{row.ID} }, { key: 'title', label: __('Title', 'formipay'), render: (row) => ( - { - e.preventDefault(); - setIsBuilder(true); - setSelectedFormId(row.ID || row.id); - }} - > - {row.post_title || row.title || __('Untitled', 'formipay')} - + <> + {row.title} +
+ + + {__('Edit', 'formipay')} + + {' | '} + + {' | '} + + + ) }, { - key: 'shortcode', - label: __('Shortcode', 'formipay'), - render: (row) => [formipay id="{row.ID || row.id}"] + key: 'date', + label: __('Date', 'formipay'), + render: (row) => { + const date = new Date(row.date); + return ( + + {date.toLocaleDateString()} +
+ + {date.toLocaleTimeString()} + +
+ ); + } }, { key: 'status', @@ -80,22 +65,51 @@ export default function FormsPage({ initialData }) { draft: __('Draft', 'formipay'), pending: __('Pending', 'formipay'), }; - const statusLabel = statusLabels[status] || status; return ( - - {statusLabel} + + {statusLabels[status] || status} ); } }, { - key: 'date', - label: __('Date', 'formipay'), - render: (row) => { - const date = row.post_date || row.date; - if (!date) return '-'; - return new Date(date).toLocaleDateString(); - } + key: 'shortcode', + label: __('Shortcode', 'formipay'), + render: (row) => ( + <> + + + + ) }, ]; @@ -103,18 +117,33 @@ export default function FormsPage({ initialData }) {

{ __('Forms', 'formipay') }

-