GRAYBYTE WORDPRESS FILE MANAGER3891

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/swamivivekananda.co.in/wp-content/plugins/suremails/src/api/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/swamivivekananda.co.in/wp-content/plugins/suremails/src/api//logs.js
// @api/logs.js
import apiFetch from '@wordpress/api-fetch';
import { __ } from '@wordpress/i18n';
import { format } from '@utils/utils';

/**
 * Fetches email logs from the server.
 *
 * @param {Object}    params             - The parameters for fetching logs.
 * @param {number}    params.pageNumber  - The current page number.
 * @param {Date|null} params.startDate   - The start date for filtering.
 * @param {Date|null} params.endDate     - The end date for filtering.
 * @param {string}    params.filter      - The status filter ('sent' or 'failed').
 * @param {string}    params.searchTerm  - The search term.
 * @param {number}    params.logsPerPage - Number of logs per page.
 * @return {Promise<Object>} The response containing logs and total count.
 */
export const fetchLogs = async ( {
	pageNumber = 1,
	startDate = null,
	endDate = null,
	filter = '',
	searchTerm = '',
	logsPerPage = 10,
} ) => {
	try {
		const response = await apiFetch( {
			path: `/suremails/v1/email-logs`,
			method: 'POST',
			headers: {
				'X-WP-Nonce': suremails.nonce,
				'Content-Type': 'application/json',
			},
			body: JSON.stringify( {
				page: pageNumber,
				per_page: logsPerPage,
				start_date: startDate
					? format( new Date( startDate ), 'yyyy-MM-dd' )
					: null,
				end_date: endDate
					? format( new Date( endDate ), 'yyyy-MM-dd' )
					: null,
				filter: filter.toLowerCase() || null,
				search: searchTerm || null,
			} ),
		} );

		return response;
	} catch ( error ) {
		throw new Error(
			error.message ||
				__( 'There was an issue fetching logs.', 'suremails' )
		);
	}
};

/**
 * Deletes specified email logs.
 *
 * @param {Array<number>} logIds - Array of log IDs to delete.
 * @return {Promise<Object>} The response from the server.
 */
export const deleteLogs = async ( logIds ) => {
	if ( ! logIds || logIds.length === 0 ) {
		throw new Error( __( 'No logs selected for deletion.', 'suremails' ) );
	}

	try {
		const response = await apiFetch( {
			path: '/suremails/v1/delete-logs',
			method: 'POST',
			headers: {
				'X-WP-Nonce': suremails.nonce,
				'Content-Type': 'application/json',
			},
			body: JSON.stringify( {
				log_ids: logIds,
			} ),
		} );

		return response;
	} catch ( error ) {
		throw new Error(
			error.message ||
				__( 'There was an issue deleting logs.', 'suremails' )
		);
	}
};

/**
 * Resends emails for specified log IDs.
 *
 * @param {Array<number>} logIds - Array of log IDs to resend.
 * @return {Promise<Object>} The response from the server.
 */
export const resendEmails = async ( logIds ) => {
	if ( ! logIds || logIds.length === 0 ) {
		throw new Error( __( 'No logs selected for resending.', 'suremails' ) );
	}

	try {
		const response = await apiFetch( {
			path: '/suremails/v1/resend-email',
			method: 'POST',
			headers: {
				'X-WP-Nonce': suremails.nonce,
				'Content-Type': 'application/json',
			},
			body: JSON.stringify( {
				log_ids: logIds,
			} ),
		} );

		return response;
	} catch ( error ) {
		throw new Error(
			error.message ||
				__( 'There was an issue resending the email(s).', 'suremails' )
		);
	}
};

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:27
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:27
giriqfky / giriqfky
0644
auth.js
0.6 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
connections.js
4.318 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
dashboard.js
1.515 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
logs.js
3.036 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
onboarding.js
0.759 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
plugins.js
0.908 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
settings.js
2.309 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF