163 lines
4.9 KiB
JavaScript
163 lines
4.9 KiB
JavaScript
import { createAsyncThunk } from '@reduxjs/toolkit';
|
|
import {
|
|
axiosRetailInstanceData,
|
|
axiosCommonInstanceData,
|
|
} from '../AuthenicationToken/AuthenticationToken';
|
|
|
|
export const getEmpBasedOnCmpId = createAsyncThunk(
|
|
'Emp/getEmp',
|
|
async (CompId) => {
|
|
if (CompId != null && CompId != undefined) {
|
|
return await axiosRetailInstanceData.get(`/employee?CompId=${CompId}`);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getEmpBasedOnCmpIdBrId = createAsyncThunk(
|
|
'Emp/getEmp',
|
|
async (data) => {
|
|
if (
|
|
data?.cmpId != null &&
|
|
data?.cmpId != undefined &&
|
|
data?.BranchId != null &&
|
|
data?.BranchId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/employee?CompId=${data?.cmpId}&BranchId=${data?.BranchId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const UserDataBasedOnBranchId = createAsyncThunk(
|
|
'Emp/UserData',
|
|
async (data) => {
|
|
if (
|
|
data?.Type == 'E' &&
|
|
data?.BranchId != null &&
|
|
data?.BranchId != undefined
|
|
) {
|
|
return await axiosCommonInstanceData.get(
|
|
`/login?BranchId=${data?.BranchId}&Type=E`
|
|
);
|
|
} else if (data?.BranchId != null && data?.BranchId != undefined) {
|
|
return await axiosCommonInstanceData.get(
|
|
`/login?BranchId=${data?.BranchId}&Type=EE`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const EmpTypeDropDown = createAsyncThunk(
|
|
'Emp/EmpTypeDropDown',
|
|
async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Employee Type`
|
|
);
|
|
}
|
|
);
|
|
|
|
export const EmpDesgDropDown = createAsyncThunk(
|
|
'Emp/EmpDesgDropDown',
|
|
async ({ AppId }) => {
|
|
if (AppId != null && AppId != undefined) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Designation&AppId=${AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
export const EmpDepartMentDropDown = createAsyncThunk(
|
|
'Emp/EmpDesgDropDown',
|
|
async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Department`
|
|
);
|
|
}
|
|
);
|
|
export const GettingShiftData = createAsyncThunk(
|
|
'Shift/GettingShiftData',
|
|
async (CompId) => {
|
|
if (CompId != null && CompId != undefined) {
|
|
return await axiosRetailInstanceData.get(`/shift?CompId=${CompId}`);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getBranchDataBasedonCmpAppId = createAsyncThunk(
|
|
'Emp/BranchData',
|
|
async (data) => {
|
|
if (
|
|
data?.AppId != null &&
|
|
data?.AppId != undefined &&
|
|
data?.cmpId != null &&
|
|
data?.cmpId != undefined
|
|
) {
|
|
return await axiosCommonInstanceData.get(
|
|
`/appAccess?AppId=${data?.AppId}&CompId=${data?.cmpId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const delEmp = createAsyncThunk('Emp/delEmp', async (deleteData) => {
|
|
if (
|
|
deleteData?.UniqueId &&
|
|
deleteData?.ActiveStatus &&
|
|
deleteData?.UpdatedBy
|
|
) {
|
|
return await axiosRetailInstanceData.delete(
|
|
`/employee?UniqueId=${deleteData?.UniqueId}&ActiveStatus=${deleteData?.ActiveStatus}&UpdatedBy=${deleteData?.UpdatedBy}`
|
|
);
|
|
}
|
|
});
|
|
|
|
export const postEmpCommOrIncen = createAsyncThunk('commOrIncen/postEmpCommOrIncen', async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/EmployeeIncentive`, postData);
|
|
});
|
|
|
|
export const putEmpCommOrIncen = createAsyncThunk('commOrIncen/putEmpCommOrIncen', async (putData) => {
|
|
return await axiosRetailInstanceData.put(`/EmployeeIncentive`, putData);
|
|
});
|
|
|
|
export const getEmpCommOrIncentive = createAsyncThunk('commOrIncen/getEmpCommOrIncentive', async (data) => {
|
|
const { AppId, CompId, BranchId, UserRole } = data
|
|
if (AppId !== null && AppId !== undefined && CompId !== null && CompId !== undefined && BranchId !== null && BranchId !== undefined && UserRole !== null && UserRole !== undefined) {
|
|
return await axiosRetailInstanceData.get(`/EmployeeIncentive?AppId=${AppId}&CompId=${CompId}&BranchId=${BranchId}&UserRole=${UserRole}`);
|
|
}
|
|
});
|
|
|
|
export const deleteCommOrIncentive = createAsyncThunk('commOrIncen/deleteCommOrIncentive', async (deleteData) => {
|
|
const { IncentiveId, UpdatedBy, ActiveStatus, UserRole } = deleteData;
|
|
if (IncentiveId && UpdatedBy && ActiveStatus && UserRole) {
|
|
return await axiosRetailInstanceData.delete(
|
|
`/EmployeeIncentive?incentiveId=${IncentiveId}&activeStatus=${ActiveStatus}&UpdatedBy=${UpdatedBy}&UserRole=${UserRole}`
|
|
);
|
|
}
|
|
});
|
|
|
|
|
|
export const postEmp = createAsyncThunk('postEmp/postEmp', async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/employee`, postData);
|
|
});
|
|
|
|
export const putEmp = createAsyncThunk('putEmp/putEmp', async (putData) => {
|
|
return await axiosRetailInstanceData.put(`/employee`, putData);
|
|
});
|
|
|
|
export const checkTrialCompany = createAsyncThunk(
|
|
'userAppMap/checkTrialCompany',
|
|
async (getTrialCompany) => {
|
|
if (
|
|
getTrialCompany.AppId != null &&
|
|
getTrialCompany.AppId != undefined &&
|
|
getTrialCompany.UserId != null &&
|
|
getTrialCompany.UserId != undefined
|
|
) {
|
|
return await axiosCommonInstanceData.get(
|
|
`/userAppMap?AppId=${getTrialCompany.AppId}&UserId=${getTrialCompany.UserId}`
|
|
);
|
|
}
|
|
}
|
|
);
|