chrone: sperate client and server to different repos.

This commit is contained in:
a.bouhuolia
2021-09-21 17:13:53 +02:00
parent e011b2a82b
commit 18df5530c7
10015 changed files with 17686 additions and 97524 deletions

View File

@@ -0,0 +1,74 @@
import React, { useCallback } from 'react';
import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { queryCache } from 'react-query';
import { useApproveEstimate } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* Estimate approve alert.
*/
function EstimateApproveAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { estimateId },
// #withAlertActions
closeAlert,
}) {
const {
mutateAsync: deliverEstimateMutate,
isLoading,
} = useApproveEstimate();
// handle cancel approve alert.
const handleCancelApproveEstimate = () => {
closeAlert(name);
};
// Handle confirm estimate approve.
const handleConfirmEstimateApprove = useCallback(() => {
deliverEstimateMutate(estimateId)
.then(() => {
AppToaster.show({
message: intl.get('the_estimate_has_been_approved_successfully'),
intent: Intent.SUCCESS,
});
queryCache.invalidateQueries('estimates-table');
})
.catch((error) => {})
.finally(() => {
closeAlert(name);
});
}, [estimateId, deliverEstimateMutate, closeAlert, name]);
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'approve'} />}
intent={Intent.WARNING}
isOpen={isOpen}
loading={isLoading}
onCancel={handleCancelApproveEstimate}
onConfirm={handleConfirmEstimateApprove}
>
<p>
<T id={'are_sure_to_approve_this_estimate'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(EstimateApproveAlert);

View File

@@ -0,0 +1,79 @@
import React, { useCallback } from 'react';
import intl from 'react-intl-universal';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
import { Intent, Alert } from '@blueprintjs/core';
import { useDeleteEstimate } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { compose } from 'utils';
/**
* Estimate delete alert.
*/
function EstimateDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { estimateId },
// #withAlertActions
closeAlert,
// #withDrawerActions
closeDrawer,
}) {
const { mutateAsync: deleteEstimateMutate, isLoading } = useDeleteEstimate();
// handle cancel delete alert.
const handleAlertCancel = () => {
closeAlert(name);
};
// handle confirm delete estimate
const handleAlertConfirm = () => {
deleteEstimateMutate(estimateId)
.then(() => {
AppToaster.show({
message: intl.get('the_estimate_has_been_deleted_successfully'),
intent: Intent.SUCCESS,
});
closeDrawer('estimate-detail-drawer');
})
.catch(({ errors }) => {})
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'delete'} />}
icon="trash"
intent={Intent.DANGER}
isOpen={isOpen}
loading={isLoading}
onCancel={handleAlertCancel}
onConfirm={handleAlertConfirm}
>
<p>
<FormattedHTMLMessage
id={'once_delete_this_estimate_you_will_able_to_restore_it'}
/>
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
withDrawerActions,
)(EstimateDeleteAlert);

View File

@@ -0,0 +1,70 @@
import React from 'react';
import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { useDeliverEstimate } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* Estimate delivered alert.
*/
function EstimateDeliveredAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { estimateId },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: deliverEstimateMutate, isLoading } = useDeliverEstimate();
// Handle cancel delivered estimate alert.
const handleAlertCancel = () => {
closeAlert(name);
};
// Handle confirm estimate delivered.
const handleAlertConfirm = () => {
deliverEstimateMutate(estimateId)
.then(() => {
AppToaster.show({
message: intl.get('the_estimate_has_been_delivered_successfully'),
intent: Intent.SUCCESS,
})
})
.catch((error) => {})
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'deliver'} />}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleAlertCancel}
onConfirm={handleAlertConfirm}
loading={isLoading}
>
<p>
<T id={'are_sure_to_deliver_this_estimate'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(EstimateDeliveredAlert);

View File

@@ -0,0 +1,73 @@
import React from 'react';
import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components';
import { useRejectEstimate } from 'hooks/query';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* Estimate reject delete alerts.
*/
function EstimateRejectAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { estimateId },
// #withAlertActions
closeAlert,
}) {
const {
mutateAsync: rejectEstimateMutate,
isLoading
} = useRejectEstimate();
// Handle cancel reject estimate alert.
const handleCancelRejectEstimate = () => {
closeAlert(name);
};
// Handle confirm estimate reject.
const handleConfirmEstimateReject = () => {
rejectEstimateMutate(estimateId)
.then(() => {
AppToaster.show({
message: intl.get('the_estimate_has_been_rejected_successfully'),
intent: Intent.SUCCESS,
});
})
.catch((error) => {})
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'reject'} />}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleCancelRejectEstimate}
onConfirm={handleConfirmEstimateReject}
loading={isLoading}
>
<p>
<T id={'are_sure_to_approve_this_estimate'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(EstimateRejectAlert);