Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'react-jhipster' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The error middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `catch`.
* It need not run in production
* process.env.NODE_ENV === 'development'
*/
if (true) {
// Dispatch initial pending promise, but catch any errors
return next(action).catch(error => {
console.error(`${action.type} caught at middleware with reason: ${JSON.stringify(error.message)}.`);
if (error && error.response && error.response.data) {
const message = getErrorMessage(error.response.data);
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The error middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `catch`.
* It need not run in production
*/
if (process.env.NODE_ENV === 'development') {
// Dispatch initial pending promise, but catch any errors
return next(action).catch(error => {
console.error(`${action.type} caught at middleware with reason: ${JSON.stringify(error.message)}.`);
if (error && error.response && error.response.data) {
const message = getErrorMessage(error.response.data);
console.error(`Actual cause: ${message}`);
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The error middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `catch`.
* It need not run in production
*/
if (process.env.NODE_ENV === 'development') {
// Dispatch initial pending promise, but catch any errors
return next(action).catch(error => {
console.error(`${action.type} caught at middleware with reason: ${JSON.stringify(error.message)}.`);
if (error && error.response && error.response.data) {
const message = getErrorMessage(error.response.data);
console.error(`Actual cause: ${message}`);
? new Date(now.getFullYear() - 1, 11, now.getDate())
: new Date(now.getFullYear(), now.getMonth() - 1, now.getDate());
return fromDate.toISOString().slice(0, 10);
};
const today = (): string => {
// Today + 1 day - needed if the current day must be included
const day: Date = new Date();
day.setDate(day.getDate() + 1);
const toDate = new Date(day.getFullYear(), day.getMonth(), day.getDate());
return toDate.toISOString().slice(0, 10);
};
export class AuditsPage extends React.Component {
state: IAuditsPageState = {
...getSortState(this.props.location, ITEMS_PER_PAGE),
fromDate: previousMonth(),
toDate: today()
};
componentDidMount() {
this.getAudits();
}
onChangeFromDate = evt => {
this.setState(
{
fromDate: evt.target.value
},
() => this.getAudits()
);
};
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IRootState } from 'app/shared/reducers';
import { getEntities } from './customer.reducer';
import { ICustomer } from 'app/shared/model/customer.model';
// tslint:disable-next-line:no-unused-variable
import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants';
export interface ICustomerProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {}
export type ICustomerState = IPaginationBaseState;
export class Customer extends React.Component {
state: ICustomerState = {
...getSortState(this.props.location, ITEMS_PER_PAGE)
};
componentDidMount() {
this.getEntities();
}
sort = prop => () => {
this.setState(
{
order: this.state.order === 'asc' ? 'desc' : 'asc',
sort: prop
},
() => this.sortEntities()
);
};
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IRootState } from 'app/shared/reducers';
import { getEntities } from './shipment.reducer';
import { IShipment } from 'app/shared/model/invoice/shipment.model';
// tslint:disable-next-line:no-unused-variable
import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants';
export interface IShipmentProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {}
export type IShipmentState = IPaginationBaseState;
export class Shipment extends React.Component {
state: IShipmentState = {
...getSortState(this.props.location, ITEMS_PER_PAGE)
};
componentDidMount() {
this.getEntities();
}
sort = prop => () => {
this.setState(
{
order: this.state.order === 'asc' ? 'desc' : 'asc',
sort: prop
},
() => this.sortEntities()
);
};
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IRootState } from 'app/shared/reducers';
import { getEntities } from './invoice.reducer';
import { IInvoice } from 'app/shared/model/invoice/invoice.model';
// tslint:disable-next-line:no-unused-variable
import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants';
export interface IInvoiceProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {}
export type IInvoiceState = IPaginationBaseState;
export class Invoice extends React.Component {
state: IInvoiceState = {
...getSortState(this.props.location, ITEMS_PER_PAGE)
};
componentDidMount() {
this.getEntities();
}
sort = prop => () => {
this.setState(
{
order: this.state.order === 'asc' ? 'desc' : 'asc',
sort: prop
},
() => this.sortEntities()
);
};
import { getSearchEntities, getEntities } from 'app/entities/customer-flock/customer-flock.reducer';
import { ICustomerFlock } from 'app/shared/model/customer-flock.model';
// tslint:disable-next-line:no-unused-variable
import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants';
export interface ICustomerFlockProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {}
export interface ICustomerFlockState extends IPaginationBaseState {
search: string;
}
export class CustomerFlock extends React.Component {
state: ICustomerFlockState = {
search: '',
...getSortState(this.props.location, ITEMS_PER_PAGE)
};
componentDidMount() {
this.getEntities();
}
search = () => {
if (this.state.search) {
this.props.getSearchEntities(this.state.search);
}
};
clear = () => {
this.props.getEntities();
this.setState({
search: ''
import { getSearchEntities, getEntities } from 'app/entities/customer/customer.reducer';
import { ICustomer } from 'app/shared/model/customer.model';
// tslint:disable-next-line:no-unused-variable
import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants';
export interface ICustomerProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {}
export interface ICustomerState extends IPaginationBaseState {
search: string;
}
export class Customer extends React.Component {
state: ICustomerState = {
search: '',
...getSortState(this.props.location, ITEMS_PER_PAGE)
};
componentDidMount() {
this.getEntities();
}
search = () => {
if (this.state.search) {
this.props.getSearchEntities(this.state.search);
}
};
clear = () => {
this.props.getEntities();
this.setState({
search: ''
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IRootState } from 'app/shared/reducers';
import { getEntities } from './product-order.reducer';
import { IProductOrder } from 'app/shared/model/product-order.model';
// tslint:disable-next-line:no-unused-variable
import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants';
export interface IProductOrderProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {}
export type IProductOrderState = IPaginationBaseState;
export class ProductOrder extends React.Component {
state: IProductOrderState = {
...getSortState(this.props.location, ITEMS_PER_PAGE)
};
componentDidMount() {
this.getEntities();
}
sort = prop => () => {
this.setState(
{
order: this.state.order === 'asc' ? 'desc' : 'asc',
sort: prop
},
() => this.sortEntities()
);
};