Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0-beta.11 #796

Merged
merged 29 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
78dc51b
bug fix: taxes not calculated correctly
johnvan7 Nov 7, 2023
637216e
load default SelectAsync
johnvan7 Nov 7, 2023
f23af85
fix value in SelectAsync
johnvan7 Nov 7, 2023
738bd97
feat: add Catalonian lang
Nov 9, 2023
775d1b1
Merge pull request #784 from tommm2/issue/add-catalonian-lang
salahlalami Nov 9, 2023
0ad77c2
fix: resolved invalid dashboard due balance
disalechinmay Nov 9, 2023
720e12e
Revert changes to backend/.env
disalechinmay Nov 9, 2023
36952ab
Delete backend/package-lock.json
salahlalami Nov 9, 2023
4416f23
Merge pull request #787 from disalechinmay/issues/fix-invalid-dashboa…
salahlalami Nov 9, 2023
07f4363
Merge pull request #764 from johnvan7/fix/taxes-not-calculated-correctly
salahlalami Nov 9, 2023
2c68715
add package lock
Nov 9, 2023
f2115a9
🐛 FIX: Summary
Nov 9, 2023
45161d0
feat: add persian lang
tommm2 Nov 10, 2023
4689524
Merge pull request #789 from tommm2/issue/add-persian-lang
salahlalami Nov 10, 2023
518e1c9
fix
johnvan7 Nov 10, 2023
0488f2b
loadDefault true in forms
johnvan7 Nov 10, 2023
a1114f1
Merge pull request #765 from johnvan7/feature/load-default-selectasync
salahlalami Nov 10, 2023
c627121
feat: add Serbian lang
tommm2 Nov 10, 2023
66ade76
fix
tommm2 Nov 10, 2023
8b60197
Merge pull request #792 from tommm2/issue/add-serbian-lang
salahlalami Nov 10, 2023
6f9ea45
update language file
Nov 10, 2023
15508fc
update cors
Nov 11, 2023
1022e0e
update auth login with no-cors
Nov 11, 2023
5a1e05b
update auth
Nov 11, 2023
c9a0526
refresh datatable after delete
Nov 11, 2023
aa11789
add Partitioned: true to setCookies
Nov 11, 2023
8a0ded6
update package
Nov 11, 2023
0c841c6
update path in set cookies
Nov 11, 2023
f70e9bc
add Partitioned
Nov 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const corsOptions = {
origin: true,
credentials: true,
};
app.use(cors(corsOptions));

// setting cors at one place for all the routes
// putting cors as first in order to avoid unneccessary requests from unallowed origins
Expand All @@ -35,9 +36,6 @@ const corsOptions = {
// cors()(req, res, next);
// }
// });
app.use(function (req, res, next) {
cors(corsOptions)(req, res, next);
});

// serves up static files from the public folder. Anything in public/ will just be served up as the file it is

Expand Down
22 changes: 13 additions & 9 deletions backend/controllers/appControllers/invoiceController/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const summary = async (req, res) => {
{
$match: {
removed: false,
date: {
$gte: startDate.toDate(),
$lte: endDate.toDate(),
},
// date: {
// $gte: startDate.toDate(),
// $lte: endDate.toDate(),
// },
},
},
{
Expand Down Expand Up @@ -163,18 +163,22 @@ const summary = async (req, res) => {
{
$match: {
removed: false,
date: {
$gte: startDate.toDate(),
$lte: endDate.toDate(),
// date: {
// $gte: startDate.toDate(),
// $lte: endDate.toDate(),
// },
paymentStatus: {
$in: ['unpaid', 'partially'],
},
paymentStatus: 'unpaid',
},
},
{
$group: {
_id: null,
total_amount: {
$sum: '$total',
$sum: {
$subtract: ['$total', '$credit'],
},
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions backend/controllers/appControllers/offerController/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const summary = async (req, res) => {
{
$match: {
removed: false,
date: {
$gte: startDate.toDate(),
$lte: endDate.toDate(),
},
// date: {
// $gte: startDate.toDate(),
// $lte: endDate.toDate(),
// },
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const summary = async (req, res) => {
{
$match: {
removed: false,
date: {
$gte: startDate.toDate(),
$lte: endDate.toDate(),
},
// date: {
// $gte: startDate.toDate(),
// $lte: endDate.toDate(),
// },
},
},
{
Expand Down
8 changes: 4 additions & 4 deletions backend/controllers/appControllers/quoteController/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const summary = async (req, res) => {
{
$match: {
removed: false,
date: {
$gte: startDate.toDate(),
$lte: endDate.toDate(),
},
// date: {
// $gte: startDate.toDate(),
// $lte: endDate.toDate(),
// },
},
},
{
Expand Down
11 changes: 7 additions & 4 deletions backend/controllers/coreControllers/authJwtController/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,27 @@ const login = async (req, res) => {

const { error, value } = objectSchema.validate({ email, password });
if (error) {
return res.status(400).json({
return res.status(409).json({
success: false,
result: null,
error: error,
message: 'Invalid/Missing credentials.',
errorMessage: error.message,
});
}

const admin = await Admin.findOne({ email: email, removed: false });
// console.log(admin);
if (!admin)
return res.status(400).json({
return res.status(404).json({
success: false,
result: null,
message: 'No account with this email has been registered.',
});

const isMatch = await bcrypt.compare(password, admin.password);
if (!isMatch)
return res.status(400).json({
return res.status(403).json({
success: false,
result: null,
message: 'Invalid credentials.',
Expand Down Expand Up @@ -84,7 +86,8 @@ const login = async (req, res) => {
httpOnly: true,
secure: true,
domain: req.hostname,
Path: '/',
path: '/',
Partitioned: true,
})
.json({
success: true,
Expand Down
8 changes: 4 additions & 4 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"description": "Just you wait folks!",
"main": "app.js",
"keywords": [],
"author": "Salah Eddine Lalami",
"license": "MIT",
"author": "IDURAR",
"license": "Fair-code License",
"repository": {
"type": "git",
"url": "git+https://github.com/idurar/idurar-erp-crm/.git"
Expand Down
20 changes: 5 additions & 15 deletions frontend/src/auth/auth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@ import successHandler from '@/request/successHandler';

export const login = async ({ loginData }) => {
try {
const response = await fetch(API_BASE_URL + `login?timestamp=${new Date().getTime()}`, {
method: 'POST', // *GET, POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, *cors, same-origin
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cache
credentials: 'include',
headers: {
'Content-Type': 'application/json',
// 'Content-Type': 'application/x-www-form-urlencoded',
},
redirect: 'follow', // manual, *follow, error
referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body: JSON.stringify(loginData), // body data type must match "Content-Type" header
});
const response = await axios.post(
API_BASE_URL + `login?timestamp=${new Date().getTime()}`,
loginData
);

const { status } = response;
const data = await response.json();
const { status, data } = response;

successHandler(
{ data, status },
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/DeleteModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function DeleteModal({ config }) {
const { current, isLoading, isSuccess } = useSelector(selectDeletedItem);
const { state, crudContextAction } = useCrudContext();
const { appContextAction } = useAppContext();
const { panel, collapsedBox, readBox } = crudContextAction;
const { panel, readBox } = crudContextAction;
const { navMenu } = appContextAction;
const { isModalOpen } = state;
const { modal } = crudContextAction;
Expand All @@ -45,8 +45,10 @@ export default function DeleteModal({ config }) {
const id = current._id;
dispatch(crud.delete({ entity, id }));
readBox.close();
modal.close();
panel.close();
navMenu.collapse();
dispatch(crud.list({ entity }));
};
const handleCancel = () => {
if (!isLoading) modal.close();
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/MoneyInputFormItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export default function MoneyInputFormItem({ updatePrice, value = 0, readOnly =
readOnly={readOnly}
className="moneyInput"
onChange={updatePrice}
value={value}
precision={money.cent_precision ? money.cent_precision : 2}
value={money.amountFormatter({ amount: value })}
controls={false}
addonAfter={money.currency_position === 'after' ? money.currency_symbol : undefined}
addonBefore={money.currency_position === 'before' ? money.currency_symbol : undefined}
formatter={(value) => money.amountFormatter({ amount: value })}
/>
</Form.Item>
);
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/components/SelectAsync/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useRef } from 'react';
import { useState, useEffect } from 'react';
import { request } from '@/request';
import useFetch from '@/hooks/useFetch';
import { Select } from 'antd';
Expand All @@ -11,6 +11,8 @@ export default function SelectAsync({
outputValue = '_id',
value,
onChange,
loadDefault = false,
defaultField = 'isDefault',
redirectLabel = '',
withRedirect = false,
urlToRedirect = '/',
Expand Down Expand Up @@ -51,6 +53,18 @@ export default function SelectAsync({
}
};

useEffect(() => {
if(loadDefault) {
const elem = selectOptions.find((option) => {
return option[defaultField] === true;
});
if (elem) {
setCurrentValue(elem[outputValue] || elem);
onChange(elem[outputValue] || elem);
}
}
}, [selectOptions]);

return (
<Select
loading={fetchIsLoading}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/forms/PaymentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default function PaymentForm({ maxAmount = null, isUpdateForm = false })
<SelectAsync
entity={'paymentMode'}
displayLabels={['name']}
loadDefault={true}
withRedirect={true}
urlToRedirect="/payment/mode"
redirectLabel="Add Payment Mode"
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/locale/antdLocale.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import fiFi from 'antd/es/locale/fi_FI';
import etEE from 'antd/es/locale/et_EE';
import elGR from 'antd/es/locale/el_GR';
import ltLT from 'antd/es/locale/lt_LT';
import caES from 'antd/es/locale/ca_ES';
import faIR from 'antd/es/locale/fa_IR';
import srRS from 'antd/es/locale/sr_RS';

const antdLocale = {
zh_cn: zhCN,
Expand Down Expand Up @@ -74,8 +77,11 @@ const antdLocale = {
lv_lv: lvLV,
fi_fi: fiFi,
et_ee: etEE,
el_GR: elGR,
lt_LT: ltLT,
el_gr: elGR,
lt_lt: ltLT,
ca_es: caES,
fa_ir: faIR,
sr_rs: srRS,
};

export default antdLocale;
7 changes: 3 additions & 4 deletions frontend/src/locale/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const languages = [
{ icon: '🇩🇿 ', label: 'Arabic', value: 'ar_eg', isRtl: true },
{ icon: '🇧🇩 ', label: 'Bengali', value: 'bn_bd' },
{ icon: '🇧🇬 ', label: 'Bulgarian', value: 'bg_bg' },
{ icon: '🇪🇦 ', label: 'Catalonian', value: 'ca_es' },
{ icon: '🇨🇳 ', label: 'Chinese', value: 'zh_cn' },
{ icon: '🇭🇷 ', label: 'Croatian', value: 'hr_hr' },
{ icon: '🇨🇿 ', label: 'Czech', value: 'cs_cz' },
Expand All @@ -24,11 +25,13 @@ const languages = [
{ icon: '🇲🇰 ', label: 'Macedonian', value: 'mk_mk' },
{ icon: '🇲🇾 ', label: 'Malay', value: 'ms_my' },
{ icon: '🇳🇴 ', label: 'Norwegian', value: 'nb_no' },
{ icon: '🇮🇷 ', label: 'Persian', value: 'fa_ir', isRtl: true },
{ icon: '🇵🇱 ', label: 'Polish', value: 'pl_pl' },
{ icon: '🇧🇷 ', label: 'Portuguese Brazil', value: 'pt_br' },
{ icon: '🇵🇹 ', label: 'Portuguese Portugal', value: 'pt_pt' },
{ icon: '🇷🇴 ', label: 'Romanian', value: 'ro_ro' },
{ icon: '🇷🇺 ', label: 'Russian', value: 'ru_ru' },
{ icon: '🇷🇸 ', label: 'Serbian', value: 'sr_rs' },
{ icon: '🇸🇰 ', label: 'Slovak', value: 'sk_sk' },
{ icon: '🇸🇮 ', label: 'Slovenian', value: 'sl_si' },
{ icon: '🇪🇸 ', label: 'Spanish', value: 'es_es' },
Expand All @@ -38,10 +41,6 @@ const languages = [
{ icon: '🇺🇦 ', label: 'Ukrainian', value: 'uk_ua' },
{ icon: '🇵🇰 ', label: 'Urdu', value: 'ur_pk', isRtl: true },
{ icon: '🇻🇳 ', label: 'Vietnamese', value: 'vi_vn' },
{ icon: '🇦🇱 ', label: 'Albanian', value: 'sq_al', disabled: true },
{ icon: '🇷🇸 ', label: 'Serbian', value: 'sr_rs', disabled: true },
{ icon: '🇪🇦 ', label: 'Catalonian', value: 'ca_es', disabled: true },
{ icon: '🇮🇷 ', label: 'Persian', value: 'fa_ir', isRtl: true, disabled: true },
];

export default languages;
Loading