phx-react
Version:
PHX REACT
65 lines • 6.5 kB
JavaScript
import React, { useState } from 'react';
import { PHXBadge } from '../Badge';
import { PHXFormWrap } from '../FormWrap';
import { PHXTable } from '../Table';
import { ApolloWrapper } from '../../lib/apollo-wrapper';
import { getEnv } from '../../read-env-config';
var keyActionImport = 0;
export var PHXTableLogImportExport = function (_a) {
var actionType = _a.actionType, organizationCode = _a.organizationCode;
var _b = useState(0), pagination = _b[0], setPagination = _b[1];
var paginationData = function (pagi) {
setPagination(pagi);
};
var _c = useState('created_at'), fieldSort = _c[0], setFieldSort = _c[1];
var _d = useState('desc'), sortDirection = _d[0], setSortDirection = _d[1];
var sortData = function (fieldSortParams, sortDirectionParams) {
setFieldSort(fieldSortParams);
setSortDirection(sortDirectionParams);
};
var dateStrToDate = function (date) {
return date ? date.slice(8, 10) + '/' + date.slice(5, 7) + '/' + date.slice(0, 4) : '';
};
var list = function (paginationParams, fieldSortParams, sortDirectionParams, organizationCodeParams, actionTypeParams) {
return {
keyResult: 'feature_import_export_file_history',
query: "query getListUploadFileHistory {\n feature_import_export_file_history(\n limit: 10,\n offset: ".concat(paginationParams * 10, ", \n order_by: {").concat(fieldSortParams, ": ").concat(sortDirectionParams, "}\n where: {\n deleted_at: {_is_null: true}, organization_code: {_eq: ").concat(organizationCodeParams, "},action_type: {_eq: ").concat(actionTypeParams, "}}\n ) {\n id\n file_name\n file_path\n file_type\n import_event_code\n module_id\n project_name\n status\n created_at\n }\n \n feature_import_export_file_history_aggregate(where: {deleted_at: {_is_null: true}, organization_code: {_eq: ").concat(organizationCodeParams, "},action_type: {_eq: ").concat(actionTypeParams, "}}) {\n aggregate {\n count\n }\n }\n }")
};
};
var search = function (paginationParams, fieldSortParams, sortDirectionParams, organizationCodeParams, actionTypeParams) {
return {
enable: false,
keyResult: 'feature_import_export_file_history',
query: "query getListUploadFileHistoryBySearch {\n feature_import_export_file_history(\n limit: 10, \n offset: ".concat(paginationParams * 10, ",\n order_by: {").concat(fieldSortParams, ": ").concat(sortDirectionParams, "},\n where: {_or: [{import_event_code: {_ilike: \"%@value%\"}}, {project_name: {_ilike: \"%@value%\"}}], deleted_at: {_is_null: true}, organization_code: {_eq: ").concat(organizationCodeParams, "},action_type: {_eq: ").concat(actionTypeParams, "}}\n ){\n id\n file_name\n file_path\n file_type\n import_event_code\n module_id\n project_name\n status\n created_at\n }\n \n feature_import_export_file_history_aggregate(\n where: {_or: [{import_event_code: {_ilike: \"%@value%\"}}, {project_name: {_ilike: \"%@value%\"}}], deleted_at: {_is_null: true}, organization_code: {_eq: ").concat(organizationCodeParams, "},action_type: {_eq: ").concat(actionTypeParams, "}}\n ){\n aggregate {\n count\n }\n }\n }")
};
};
var thHeader = ['Tên file', 'Đường dẫn file', 'Tên dự án', 'Tên module', 'Trạng thái', 'Ngày tạo'];
var thBody = ['id', 'file_name', 'file_path', 'project_name', 'module_id', 'status', 'created_at'];
var thComponent = {
// @ts-ignore
created_at: function bind(value, itemBody) {
return dateStrToDate(itemBody.created_at);
},
// @ts-ignore
status: function bind(value, itemBody) {
switch (itemBody === null || itemBody === void 0 ? void 0 : itemBody.status) {
case 0:
return React.createElement(PHXBadge, { text: 'Nh\u00E1p', type: 'default' });
case 1:
return React.createElement(PHXBadge, { text: 'Ch\u1EDD x\u1EED l\u00FD', type: 'informational' });
case 2:
return React.createElement(PHXBadge, { text: '\u0110ang x\u1EED l\u00FD', type: 'attention' });
case 3:
return React.createElement(PHXBadge, { text: 'Th\u00E0nh c\u00F4ng', type: 'success' });
default:
return React.createElement(PHXBadge, { text: 'Th\u1EA5t b\u1EA1i', type: 'danger' });
}
}
};
var listQuery = list(pagination, fieldSort, sortDirection, organizationCode, actionType);
var searchQuery = search(pagination, fieldSort, sortDirection, organizationCode, actionType);
return (React.createElement(PHXFormWrap, { className: 'text-xs', footerAction: false, headerAction: true, size: 'medium', title: actionType === keyActionImport ? 'Những file đã import' : 'Những file đã export', type: 'default' },
React.createElement(ApolloWrapper, null,
React.createElement(PHXTable, { clickRow: false, graphqlEndpoint: getEnv('NEXT_PUBLIC_GRAPHQL_API_PROCESS_CENTER', process.env.NEXT_PUBLIC_GRAPHQL_API_PROCESS_CENTER), graphqlKey: getEnv('NEXT_PUBLIC_GRAPHQL_KEY_PROCESS_CENTER', process.env.NEXT_PUBLIC_GRAPHQL_KEY_PROCESS_CENTER), list: listQuery, paginationData: paginationData, search: searchQuery, sortData: sortData, thBody: thBody, thBodyComponent: thComponent, thHeader: thHeader, router: undefined }))));
};
//# sourceMappingURL=TableLogImportExport.js.map