re-structure to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 01:02:31 +02:00
parent 8242ec64ba
commit 7a0a13f9d5
10400 changed files with 46966 additions and 17223 deletions

View File

@@ -0,0 +1,101 @@
// @ts-nocheck
import React, { Suspense } from 'react';
import styled from 'styled-components';
import clsx from 'classnames';
import * as R from 'ramda';
import { Intent, Classes, ProgressBar } from '@blueprintjs/core';
import { debounce } from 'lodash';
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
import withAlertActions from '@/containers/Alert/withAlertActions';
import { AppToaster } from '@/components';
function AlertLazyFallbackMessage({ amount }) {
return (
<React.Fragment>
<ToastText>Alert content is loading, just a second.</ToastText>
<ProgressBar
className={clsx({
[Classes.PROGRESS_NO_STRIPES]: amount >= 100,
})}
intent={amount < 100 ? Intent.PRIMARY : Intent.SUCCESS}
value={amount / 100}
/>
</React.Fragment>
);
}
function AlertLazyFallback({}) {
const progressToastInterval = React.useRef(null);
const toastKey = React.useRef(null);
const toastProgressLoading = (amount) => {
return {
message: <AlertLazyFallbackMessage amount={amount} />,
onDismiss: (didTimeoutExpire) => {
if (!didTimeoutExpire) {
window.clearInterval(progressToastInterval.current);
}
},
timeout: amount < 100 ? 0 : 2000,
};
};
const triggerProgressToast = () => {
let progress = 0;
toastKey.current = AppToaster.show(toastProgressLoading(0));
progressToastInterval.current = window.setInterval(() => {
if (toastKey.current == null || progress > 100) {
window.clearInterval(progressToastInterval.current);
} else {
progress += 10 + Math.random() * 20;
AppToaster.show(toastProgressLoading(progress), toastKey.current);
}
}, 100);
};
const hideProgressToast = () => {
window.clearInterval(progressToastInterval.current);
AppToaster.dismiss(toastKey.current);
};
// Debounce the trigger.
const dobounceTrigger = React.useRef(
debounce(() => {
triggerProgressToast();
}, 500),
);
React.useEffect(() => {
dobounceTrigger.current();
return () => {
hideProgressToast();
dobounceTrigger.current.cancel();
};
});
return null;
}
function AlertLazyInside({ isOpen, name, Component }) {
if (!isOpen) {
return null;
}
return (
<Suspense fallback={<AlertLazyFallback />}>
<Component name={name} />
</Suspense>
);
}
export const AlertLazy = R.compose(
withAlertStoreConnect(),
withAlertActions,
)(AlertLazyInside);
const ToastText = styled.div`
margin-bottom: 10px;
`;

View File

@@ -0,0 +1,14 @@
// @ts-nocheck
import React from 'react';
import { AlertLazy } from './components'
import registered from './registered';
export default function AlertsContainer() {
return (
<React.Fragment>
{registered.map((alert) => (
<AlertLazy name={alert.name} Component={alert.component} />
))}
</React.Fragment>
);
}

View File

@@ -0,0 +1,56 @@
// @ts-nocheck
import AccountsAlerts from '@/containers/Accounts/AccountsAlerts';
import ItemsAlerts from '@/containers/Items/ItemsAlerts';
import ItemsCategoriesAlerts from '@/containers/ItemsCategories/ItemsCategoriesAlerts';
import InventoryAdjustmentsAlerts from '@/containers/InventoryAdjustments/InventoryAdjustmentsAlerts';
import EstimatesAlerts from '@/containers/Sales/Estimates/EstimatesAlerts';
import InvoicesAlerts from '@/containers/Sales/Invoices/InvoicesAlerts';
import ReceiptsAlerts from '@/containers/Sales/Receipts/ReceiptsAlerts';
import PaymentReceiveAlerts from '@/containers/Sales/PaymentReceives/PaymentReceiveAlerts';
import BillsAlerts from '@/containers/Purchases/Bills/BillsLanding/BillsAlerts';
import PaymentMadesAlerts from '@/containers/Purchases/PaymentMades/PaymentMadesAlerts';
import CustomersAlerts from '@/containers/Customers/CustomersAlerts';
import VendorsAlerts from '@/containers/Vendors/VendorsAlerts';
import ManualJournalsAlerts from '@/containers/Accounting/JournalsLanding/ManualJournalsAlerts';
import ExchangeRatesAlerts from '@/containers/ExchangeRates/ExchangeRatesAlerts';
import ExpensesAlerts from '@/containers/Expenses/ExpensesAlerts';
import AccountTransactionsAlerts from '@/containers/CashFlow/AccountTransactions/AccountTransactionsAlerts';
import UsersAlerts from '@/containers/Preferences/Users/UsersAlerts';
import CurrenciesAlerts from '@/containers/Preferences/Currencies/CurrenciesAlerts';
import RolesAlerts from '@/containers/Preferences/Users/Roles/RolesAlerts';
import CreditNotesAlerts from '@/containers/Sales/CreditNotes/CreditNotesAlerts';
import VendorCreditNotesAlerts from '@/containers/Purchases/CreditNotes/VendorCreditNotesAlerts';
import TransactionsLockingAlerts from '@/containers/TransactionsLocking/TransactionsLockingAlerts';
import WarehousesAlerts from '@/containers/Preferences/Warehouses/WarehousesAlerts';
import WarehousesTransfersAlerts from '@/containers/WarehouseTransfers/WarehousesTransfersAlerts';
import BranchesAlerts from '@/containers/Preferences/Branches/BranchesAlerts';
import ProjectAlerts from '@/containers/Projects/containers/ProjectAlerts';
export default [
...AccountsAlerts,
...ItemsAlerts,
...ItemsCategoriesAlerts,
...InventoryAdjustmentsAlerts,
...EstimatesAlerts,
...InvoicesAlerts,
...ReceiptsAlerts,
...PaymentReceiveAlerts,
...BillsAlerts,
...PaymentMadesAlerts,
...CustomersAlerts,
...VendorsAlerts,
...ManualJournalsAlerts,
...ExchangeRatesAlerts,
...ExpensesAlerts,
...AccountTransactionsAlerts,
...UsersAlerts,
...CurrenciesAlerts,
...RolesAlerts,
...CreditNotesAlerts,
...VendorCreditNotesAlerts,
...TransactionsLockingAlerts,
...WarehousesAlerts,
...WarehousesTransfersAlerts,
...BranchesAlerts,
...ProjectAlerts,
];