Commit 0966bc70 by Giang Tran

update code

parent cea04004
...@@ -10,7 +10,7 @@ import ManageJobRoutes from './views/Company/ManageJob/ManageJobRoutes' ...@@ -10,7 +10,7 @@ import ManageJobRoutes from './views/Company/ManageJob/ManageJobRoutes'
import MyAccountRouters from './views/MyAccount/MyAccountRoute' import MyAccountRouters from './views/MyAccount/MyAccountRoute'
import FuntionRouters from './views/Company/Function/FuntionRoutes' import FuntionRouters from './views/Company/Function/FuntionRoutes'
import SystemRouters from './views/System/SystemRouters' import SystemRouters from './views/System/SystemRouters'
import ProductRoutes from './views/product/ProductRouters'
...@@ -29,6 +29,7 @@ const errorRoute = [ ...@@ -29,6 +29,7 @@ const errorRoute = [
] ]
const routes = [ const routes = [
...ProductRoutes,
...SystemRouters, ...SystemRouters,
...FuntionRouters, ...FuntionRouters,
...MyAccountRouters, ...MyAccountRouters,
......
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListCustomers = async (body) =>
PostData(url.urlGetCustomer, body)
.then((res) => res)
.catch((err) => null)
export const createCustomer = async (body) =>
PostData(url.urlCreateCustomer, body)
.then((res) => res)
.catch((err) => null)
export const updateCustomer = async (body) =>
PostData(url.urlUpdateCustomer, body)
.then((res) => res)
.catch((err) => null)
export const detailCustomer = async (id, body) =>
GetURL(`${url.urlDetailCustomer}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteCustomer = async (body) =>
PostData(url.urlDeleteCustomer, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusCustomer = async (body) =>
PostData(url.changeStatusCustomer, body)
.then((res) => res)
.catch((err) => null)
export const assignCustomer = async (body) =>
PostData(url.asignCustomer, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListCusomterProcess = async (body) =>
PostData(url.urlGetCustomerCare, body)
.then((res) => res)
.catch((err) => null)
export const createCustomerProcess = async (body) =>
PostData(url.urlCreateCustomerCare, body)
.then((res) => res)
.catch((err) => null)
export const detailCustomerProcess = async (id, body) =>
GetURL(`${url.urlDetailCustomerCare}/${id}`, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListAgentReleases = async (body) =>
PostData(url.urlGetAgentRelease, body)
.then((res) => res)
.catch((err) => null)
export const createAgentRelease = async (body) =>
PostData(url.urlCreateAgentRelease, body)
.then((res) => res)
.catch((err) => null)
export const updateAgentRelease = async (body) =>
PostData(url.urlUpdateAgentRelease, body)
.then((res) => res)
.catch((err) => null)
export const detailAgentRelease = async (id, body) =>
GetURL(`${url.urlDetailAgentRelease}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteAgentRelease = async (body) =>
PostData(url.urlDeleteAgentRelease, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListIsuerBankAccounts = async (body) =>
PostData(url.urlGetIsuerBankAccount, body)
.then((res) => res)
.catch((err) => null)
export const createIsuerBankAccount = async (body) =>
PostData(url.urlCreateIsuerBankAccount, body)
.then((res) => res)
.catch((err) => null)
export const updateIsuerBankAccount = async (body) =>
PostData(url.urlUpdateIsuerBankAccount, body)
.then((res) => res)
.catch((err) => null)
export const detailIsuerBankAccount = async (id, body) =>
GetURL(`${url.urlDetailIsuerBankAccount}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteIsuerBankAccount = async (body) =>
PostData(url.urlDeleteIsuerBankAccount, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListIsuer = async (body) =>
PostData(url.urlGetListIsuer, body)
.then((res) => res)
.catch((err) => null)
export const createIsuer = async (body) =>
PostData(url.urlCreateIsuer, body)
.then((res) => res)
.catch((err) => null)
export const updateIsuer = async (body) =>
PostData(url.urlUpdateIsuer, body)
.then((res) => res)
.catch((err) => null)
export const detailIsuer = async (id, body) =>
GetURL(`${url.urlDetailIsuer}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteIsuer = async (body) =>
PostData(url.urlDeleteIsuer, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListReleasePackage = async (body) =>
PostData(url.urlGetReleasePackage, body)
.then((res) => res)
.catch((err) => null)
export const createReleasePackage = async (body) =>
PostData(url.urlCreateReleasePackage, body)
.then((res) => res)
.catch((err) => null)
export const updateReleasePackage = async (body) =>
PostData(url.urlUpdateReleasePackage, body)
.then((res) => res)
.catch((err) => null)
export const detailReleasePackage = async (id, body) =>
GetURL(`${url.urlDetailReleasePackage}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteReleasePackage = async (body) =>
PostData(url.urlDeleteReleasePackage, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusReleasePackage = async (body) =>
PostData(url.urlchangeStatusReleasePackage, body)
.then((res) => res)
.catch((err) => null)
export const approveReleasePackage = async (body) =>
PostData(url.urlapproveReleasePackage, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListProductInvest = async (body) =>
PostData(url.urlGetProductInvest, body)
.then((res) => res)
.catch((err) => null)
export const createProductInvest = async (body) =>
PostData(url.urlCreateProductInvest, body)
.then((res) => res)
.catch((err) => null)
export const updateProductInvest = async (body) =>
PostData(url.urlUpdateProductInvest, body)
.then((res) => res)
.catch((err) => null)
export const detailProductInvest = async (id, body) =>
GetURL(`${url.urlDetailProductInvest}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteProductInvest = async (body) =>
PostData(url.urlDeleteProductInvest, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusProductInvest = async (body) =>
PostData(url.urlchangeStatusProductInvest, body)
.then((res) => res)
.catch((err) => null)
export const approveProductInvest = async (body) =>
PostData(url.urlapproveProductInvest, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListBanks = async (body) =>
PostData(url.urlGetBank, body)
.then((res) => res)
.catch((err) => null)
export const createBank = async (body) =>
PostData(url.urlCreateBank, body)
.then((res) => res)
.catch((err) => null)
export const updateBank = async (body) =>
PostData(url.urlUpdateBank, body)
.then((res) => res)
.catch((err) => null)
export const detailBank = async (id, body) =>
GetURL(`${url.urlDetailBank}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteBank = async (body) =>
PostData(url.urlDeleteBank, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListCategorys = async (body) =>
PostData(url.urlGetCategory, body)
.then((res) => res)
.catch((err) => null)
export const createCategory = async (body) =>
PostData(url.urlCreateCategory, body)
.then((res) => res)
.catch((err) => null)
export const updateCategory = async (body) =>
PostData(url.urlUpdateCategory, body)
.then((res) => res)
.catch((err) => null)
export const detailCategory = async (id, body) =>
GetURL(`${url.urlDetailCategory}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteCategory = async (body) =>
PostData(url.urlDeleteCategory, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListCategoryTypes = async (body) =>
PostData(url.urlGetCategoryType, body)
.then((res) => res)
.catch((err) => null)
export const createCategoryType = async (body) =>
PostData(url.urlCreateCategoryType, body)
.then((res) => res)
.catch((err) => null)
export const updateCategoryType = async (body) =>
PostData(url.urlUpdateCategoryType, body)
.then((res) => res)
.catch((err) => null)
export const detailCategoryType = async (id, body) =>
GetURL(`${url.urlDetailCategoryType}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteCategoryType = async (body) =>
PostData(url.urlDeleteCategoryType, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const getLogAuth = async (body) =>
PostData(url.logAuth, body)
.then((res) => res)
.catch((err) => null)
export const getLogAction = async (body) =>
PostData(url.logAction, body)
.then((res) => res)
.catch((err) => null)
export const getLogApi = async (body) =>
PostData(url.logApi, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListPeriodInterests = async (body) =>
PostData(url.urlGetPeriodInterest, body)
.then((res) => res)
.catch((err) => null)
export const createPeriodInterest = async (body) =>
PostData(url.urlCreatePeriodInterest, body)
.then((res) => res)
.catch((err) => null)
export const updatePeriodInterest = async (body) =>
PostData(url.urlUpdatePeriodInterest, body)
.then((res) => res)
.catch((err) => null)
export const detailPeriodInterest = async (id, body) =>
GetURL(`${url.urlDetailPeriodInterest}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deletePeriodInterest = async (body) =>
PostData(url.urlDeletePeriodInterest, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../../helpers'
import url from '../../url'
export const getListRankCustomers = async (body) =>
PostData(url.urlGetRankCustomer, body)
.then((res) => res)
.catch((err) => null)
export const createRankCustomer = async (body) =>
PostData(url.urlCreateRankCustomer, body)
.then((res) => res)
.catch((err) => null)
export const updateRankCustomer = async (body) =>
PostData(url.urlUpdateRankCustomer, body)
.then((res) => res)
.catch((err) => null)
export const detailRankCustomer = async (id, body) =>
GetURL(`${url.urlDetailRankCustomer}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteRankCustomer = async (body) =>
PostData(url.urlDeleteRankCustomer, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const urlGetFormTeamplate = async (body) =>
PostData(url.urlGetFormTeamplate, body)
.then((res) => res)
.catch((err) => null)
export const urlCreateFormTeamplate = async (body) =>
PostData(url.urlCreateFormTeamplate, body)
.then((res) => res)
.catch((err) => null)
export const urlUpdateFormTeamplate = async (body) =>
PostData(url.urlUpdateFormTeamplate, body)
.then((res) => res)
.catch((err) => null)
export const urlDetailFormTeamplate = async (id, body) =>
GetURL(`${url.urlDetailFormTeamplate}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const urlDeleteFormTeamplate = async (body) =>
PostData(url.urlDeleteFormTeamplate, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusFormTeamplate = async (body) =>
PostData(url.changeStatusFormTeamplate, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const urlGetProductGroup = async (body) =>
PostData(url.urlGetProductGroup, body)
.then((res) => res)
.catch((err) => null)
export const urlCreateProductGroup = async (body) =>
PostData(url.urlCreateProductGroup, body)
.then((res) => res)
.catch((err) => null)
export const urlUpdateProductGroup = async (body) =>
PostData(url.urlUpdateProductGroup, body)
.then((res) => res)
.catch((err) => null)
export const urlDetailProductGroup = async (id, body) =>
GetURL(`${url.urlDetailProductGroup}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const urlDeleteProductGroup = async (body) =>
PostData(url.urlDeleteProductGroup, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusProductGroup = async (body) =>
PostData(url.changeStatusProductGroup, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const getListAskManager = async (body) =>
PostData(url.urlGetListAskManager, body)
.then((res) => res)
.catch((err) => null)
export const createAskManager = async (body) =>
PostData(url.urlCreateAskManager, body)
.then((res) => res)
.catch((err) => null)
export const updateAskManager = async (body) =>
PostData(url.urlUpdateAskManager, body)
.then((res) => res)
.catch((err) => null)
export const detailAskManager = async (id, body) =>
GetURL(`${url.urlDetailAskManager}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteAskManager = async (body) =>
PostData(url.urlDeleteAskManager, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusAskManager = async (body) =>
PostData(url.changeStatusAskManager, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const getListEmail = async (body) =>
PostData(url.urlGetListEmail, body)
.then((res) => res)
.catch((err) => null)
export const createEmail = async (body) =>
PostData(url.urlCreateEmail, body)
.then((res) => res)
.catch((err) => null)
export const detailEmail = async (id, body) =>
GetURL(`${url.urlCreateEmail}/${id}`, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const getListHoliday = async (body) =>
PostData(url.urlGetListHoliday, body)
.then((res) => res)
.catch((err) => null)
export const createHoliday = async (body) =>
PostData(url.urlCreateHoliday, body)
.then((res) => res)
.catch((err) => null)
export const updateHoliday = async (body) =>
PostData(url.urlUpdateHoliday, body)
.then((res) => res)
.catch((err) => null)
export const detailHoliday = async (id, body) =>
GetURL(`${url.urlDetailHoliday}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteHoliday = async (body) =>
PostData(url.urlDeleteHoliday, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusHoliday = async (body) =>
PostData(url.changeStatusHoliday, body)
.then((res) => res)
.catch((err) => null)
export const getListDateHoliday = async () =>
GetURL(`${url.getListHoliday}`)
.then((res) => res)
.catch((err) => null)
export const updateListDateHoliday = async (body) =>
PostData(url.updateHoliday, body)
.then((res) => res)
.catch((err) => null)
\ No newline at end of file
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const getListNotification = async (body) =>
PostData(url.urlGetListNotification, body)
.then((res) => res)
.catch((err) => null)
export const createNotification = async (body) =>
PostData(url.urlCreateNotification, body)
.then((res) => res)
.catch((err) => null)
export const updateNotification = async (body) =>
PostData(url.urlUpdateNotification, body)
.then((res) => res)
.catch((err) => null)
export const detailNotification = async (id, body) =>
GetURL(`${url.urlDetailNotification}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteNotification = async (body) =>
PostData(url.urlDeleteNotification, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusNotification = async (body) =>
PostData(url.changeStatusNotification, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const getListSMS = async (body) =>
PostData(url.urlGetListSms, body)
.then((res) => res)
.catch((err) => null)
export const createSMS = async (body) =>
PostData(url.urlCreateSms, body)
.then((res) => res)
.catch((err) => null)
export const detailSMS = async (id, body) =>
GetURL(`${url.urlCreateSms}/${id}`, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../../helpers'
import url from '../../url'
export const getListSocialNetwork = async (body) =>
PostData(url.urlGetListSocialNetwork, body)
.then((res) => res)
.catch((err) => null)
export const createSocialNetwork = async (body) =>
PostData(url.urlCreateSocialNetwork, body)
.then((res) => res)
.catch((err) => null)
export const updateSocialNetwork = async (body) =>
PostData(url.urlUpdateSocialNetwork, body)
.then((res) => res)
.catch((err) => null)
export const detailSocialNetwork = async (id, body) =>
GetURL(`${url.urlDetailSocialNetwork}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteSocialNetwork = async (body) =>
PostData(url.urlDeleteSocialNetwork, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusSocialNetwork = async (body) =>
PostData(url.changeStatusSocialNetwork, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../helpers'
import url from '../url'
export const getListBanner = async (body) =>
PostData(url.urlGetListBanner, body)
.then((res) => res)
.catch((err) => null)
export const createBanner = async (body) =>
PostData(url.urlCreateBanner, body)
.then((res) => res)
.catch((err) => null)
export const updateBanner = async (body) =>
PostData(url.urlUpdateBanner, body)
.then((res) => res)
.catch((err) => null)
export const detailBanner = async (id, body) =>
GetURL(`${url.urlDetailBanner}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteBanner = async (body) =>
PostData(url.urlDeleteBanner, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusBanner = async (body) =>
PostData(url.changeStatusBanner, body)
.then((res) => res)
.catch((err) => null)
...@@ -25,6 +25,11 @@ export const dropdownUserGroup = async (body) => ...@@ -25,6 +25,11 @@ export const dropdownUserGroup = async (body) =>
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const getDropDownGroup = async (body) =>
GetData(url.dropdownUserGroup, body)
.then((res) => res)
.catch((err) => null)
export const dropdownListActive = async (body) => export const dropdownListActive = async (body) =>
GetData(url.dropdownListActive, body) GetData(url.dropdownListActive, body)
.then((res) => res) .then((res) => res)
...@@ -35,117 +40,7 @@ export const dropdownUserApprove = async (body) => ...@@ -35,117 +40,7 @@ export const dropdownUserApprove = async (body) =>
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const dropdownSurveyType = async (body) =>
GetData(url.dropdownSurveyType, body)
.then((res) => res)
.catch((err) => null)
export const dropdownAskType = async (body) =>
GetData(url.dropdownAskType, body)
export const dropdownCategoryType = async (body) =>
GetData(url.dropdownCategoryType, body)
.then((res) => res)
.catch((err) => null)
export const dropdownBank = async (body) =>
GetData(url.dropdownBank, body)
.then((res) => res)
.catch((err) => null)
export const dropdownBranch = async (body) =>
GetData(url.dropdownBranch, body)
.then((res) => res)
.catch((err) => null)
export const dropdownIsuers = async (body) =>
GetData(url.dropdownIsuers, body)
.then((res) => res)
.catch((err) => null)
export const dropdownGetOrganizationIdenMethod = async (body) =>
GetData(url.dropdownGetOrganizationIdenMethod, body)
.then((res) => res)
.catch((err) => null)
export const dropdownGetPersonIdenMethod = async (body) =>
GetData(url.dropdownGetPersonIdenMethod, body)
.then((res) => res)
.catch((err) => null)
export const dropdownGetIssuersType = async (body) =>
GetData(url.dropdownGetIssuersType, body)
.then((res) => res)
.catch((err) => null)
export const dropdownGetINation = async (body) =>
GetData(url.dropdownGetINation, body)
.then((res) => res)
.catch((err) => null)
export const dropdownGetIProvince = async (body) =>
GetData(url.dropdownGetIProvince, body)
.then((res) => res)
.catch((err) => null)
export const dropdownGetIProvinceBy = async (id, body) =>
GetData(`${url.dropdownGetIProvinceBy}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const dropdownPeriod = async (body) =>
GetData(url.dropdownPeriod, body)
.then((res) => res)
.catch((err) => null)
export const dropdownTypePeriod = async (body) =>
GetData(url.dropdownTypePeriod, body)
.then((res) => res)
.catch((err) => null)
export const dropdownCustomerType = async (body) =>
GetData(url.dropdownCustomerType, body)
.then((res) => res)
.catch((err) => null)
export const dropdownCustomerRank = async (body) =>
GetData(url.dropdownCustomerRank, body)
.then((res) => res)
.catch((err) => null)
export const dropdownGender = async (body) =>
GetData(url.dropdownGender, body)
.then((res) => res)
.catch((err) => null)
export const dropdownCustomerShareType = async (body) =>
GetData(url.dropdownCustomerShareType, body)
.then((res) => res)
.catch((err) => null)
export const dropdownCareType = async (body) =>
GetData(url.dropdownCareType, body)
.then((res) => res)
.catch((err) => null)
export const dropdownCareResult = async (body) =>
GetData(url.dropdownCareResult, body)
.then((res) => res)
.catch((err) => null)
export const dropdownRealeasePackage = async (body) =>
GetData(url.dropdownRealeasePackage, body)
.then((res) => res)
.catch((err) => null)
export const dropdownProductGroup = async (body) =>
GetData(url.dropdownProductGroup, body)
.then((res) => res)
.catch((err) => null)
export const dropdownProductType = async (body) => export const dropdownProductType = async (body) =>
GetData(url.dropdownProductType, body) GetData(url.dropdownProductType, body)
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const dropdownFormTemplate = async (body) =>
GetData(url.dropdownFormTemplate, body)
.then((res) => res)
.catch((err) => null)
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../helpers'
import url from '../url'
export const getListProductTypes = async (body) =>
PostData(url.urlGetListProductType, body)
.then((res) => res)
.catch((err) => null)
export const createProductType = async (body) =>
PostData(url.urlCreateProductType, body)
.then((res) => res)
.catch((err) => null)
export const updateProductType = async (body) =>
PostData(url.urlUpdateProductType, body)
.then((res) => res)
.catch((err) => null)
export const detailProductType = async (id, body) =>
GetURL(`${url.urlDetailProductType}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteProductType = async (body) =>
PostData(url.urlDeleteProductType, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusProductType = async (body) =>
PostData(url.changeStatusProductType, body)
.then((res) => res)
.catch((err) => null)
export const getListProduct = async (body) =>
PostData(url.urlGetListProduct, body)
.then((res) => res)
.catch((err) => null)
export const createProduct = async (body) =>
PostData(url.urlCreateProduct, body)
.then((res) => res)
.catch((err) => null)
export const updateProduct = async (body) =>
PostData(url.urlUpdateProduct, body)
.then((res) => res)
.catch((err) => null)
export const detailProduct = async (id, body) =>
GetURL(`${url.urlDetailProduct}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteProduct = async (body) =>
PostData(url.urlDeleteProduct, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusProduct = async (body) =>
PostData(url.changeStatusProduct, body)
.then((res) => res)
.catch((err) => null)
...@@ -34,6 +34,28 @@ export const navigations = [ ...@@ -34,6 +34,28 @@ export const navigations = [
}, },
], ],
}, },
{
name: 'Quản lý sản phẩm',
icon: 'wb_iridescent',
hide: false,
children: [
{
name: 'Sản phẩm',
path: '/product',
iconText: 'EM',
//icon: 'group',
hide: false,
id: 'EMPLOYEE',
},
{
name: 'Loại sản phẩm',
iconText: 'FN',
path: '/product-type',
hide: false,
id: 'FUNCTION',
},
],
},
{ {
name: 'Quản lý hệ thống', name: 'Quản lý hệ thống',
...@@ -108,6 +130,28 @@ export const navigationsAdmin = [ ...@@ -108,6 +130,28 @@ export const navigationsAdmin = [
type: 'label', type: 'label',
hide: false, hide: false,
}, },
{
name: 'Quản lý sản phẩm',
icon: 'wb_iridescent',
hide: false,
children: [
{
name: 'Sản phẩm',
path: '/product',
iconText: 'EM',
//icon: 'group',
hide: false,
id: 'EMPLOYEE',
},
{
name: 'Loại sản phẩm',
iconText: 'FN',
path: '/product-type',
hide: false,
id: 'FUNCTION',
},
],
},
{ {
name: 'Quản lý hệ thống', name: 'Quản lý hệ thống',
......
...@@ -93,7 +93,7 @@ const SimpleForm = (props) => { ...@@ -93,7 +93,7 @@ const SimpleForm = (props) => {
userPermissions: newList, userPermissions: newList,
avatar: image, avatar: image,
status: true, status: 1,
}) })
console.log(res) console.log(res)
props.hideLoading() props.hideLoading()
......
...@@ -10,12 +10,12 @@ import KEY from 'app/assets/Key' ...@@ -10,12 +10,12 @@ import KEY from 'app/assets/Key'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null) const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1) const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000)
const [pageIndex, setPageIndex] = useState(0) const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10) const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
...@@ -58,7 +58,7 @@ const ToolNotificate = (props) => { ...@@ -58,7 +58,7 @@ const ToolNotificate = (props) => {
const getData = async () => { const getData = async () => {
props.showLoading() props.showLoading()
const res = await getListEmployees({ const res = await getListEmployees({
full_name: txtSearch, full_name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
...@@ -81,7 +81,7 @@ const ToolNotificate = (props) => { ...@@ -81,7 +81,7 @@ const ToolNotificate = (props) => {
useEffect(() => { useEffect(() => {
getData() getData()
}, [txtSearch, pageIndex]) }, [searchDebount, pageIndex])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
......
import React from 'react'
const ProductRoutes = [
{
path: '/product/create',
component: React.lazy(() => import('./product/Create')),
},
{
path: '/product/update',
component: React.lazy(() => import('./product/Update')),
},
{
path: '/product',
component: React.lazy(() => import('./product/Index')),
},
{
path: '/product-type/create',
component: React.lazy(() => import('./type/Create')),
},
{
path: '/product-type/update',
component: React.lazy(() => import('./type/Update')),
},
{
path: '/product-type',
component: React.lazy(() => import('./type/Index')),
},
]
export default ProductRoutes
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import {
Button,
Icon,
Grid,
Radio,
RadioGroup,
FormControlLabel,
Checkbox,
TextField,
Typography,
MenuItem,
Select,
InputLabel,
} from '@material-ui/core'
import { Breadcrumb, SimpleCard } from 'app/components'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { toast } from 'react-toastify'
import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { createProduct } from 'app/apis/Functions/product'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const history = useHistory()
useEffect(() => {
getData()
}, [])
const getData = async () => {
props.showLoading()
const res = await dropdownProductType({})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { name: e.type_name, value: e.id, ...e }
})
setListDrop(newList)
} else if (res.data.code == 401) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Lấy giữ liệu thất bại !', {
theme: 'colored',
})
}
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createProduct({
...newValue,
type_id: 2,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/product')
if (res.data.code == 200) {
toast.success('Tạo sản phẩm thành công!', {
theme: 'colored',
})
}
} else {
toast.error('Tạo sản phẩm thất bại!', {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const { name, code, price_default, type_id } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách sản phẩm',
path: '/product',
},
{ name: 'Thêm mới sản phẩm' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Thuộc chức năng *'}
className="mb-4 w-full"
value={type_id || ''}
displayEmpty
name="type_id"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{listDrop.map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên *"
onChange={handleChange}
type="text"
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã code *"
onChange={handleChange}
type="text"
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Giá mặc định *"
onChange={handleChange}
type="text"
name="price_default"
value={price_default || ''}
validators={['required', 'isNumber']}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
]}
/>
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Link to="/product">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Thêm mi</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListProduct,
changeStatusProduct,
deleteProduct,
} from 'app/apis/Functions/product'
import { useHistory } from 'react-router-dom'
import KEY from '../../../assets/Key'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000)
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const history = useHistory()
const [data, setData] = useState([])
const [permissions, setPermissions] = useState([])
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusProduct({ idGuid: id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Thay đổi trạng thái thành công!', {
theme: 'colored',
})
} else {
toast.error('Thay đổi trạng thái thất bại!', {
theme: 'colored',
})
}
}
const getData = async () => {
props.showLoading()
const res = await getListProduct({
name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(res.data)
const newList = res.data.data.data.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Lấy giữ liệu thất bại !', {
theme: 'colored',
})
}
}
useEffect(() => {
getData()
}, [txtSearch, pageIndex])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteProduct({ idGuid: id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Xoá bản ghi thành công!', {
theme: 'colored',
})
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Xoá bản ghi thất bại!', {
theme: 'colored',
})
}
}
return (
<ToolUserView
data={data}
removeItem={removeItem}
setTxtSearch={setTxtSearch}
setActiveSeleted={setActiveSeleted}
pageIndex={pageIndex}
changeActive={changeActive}
setChangeActive={setChangeActive}
setPageIndex={setPageIndex}
activeSelected={activeSelected}
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
permissions={permissions}
/>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
ToolNotificate
)
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import { Button, Grid, MenuItem } from '@material-ui/core'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
import { detailProduct, updateProduct } from 'app/apis/Functions/product'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux'
import localStorageService from 'app/services/localStorageService'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const history = useHistory()
const location = useLocation()
useEffect(() => {
getDropDown()
getData()
}, [])
const getData = async () => {
props.showLoading()
const res = await detailProduct(location.state, {})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(res.data.data)
setState(res.data.data)
} else if (res.data.code == 401) {
localStorageService.removeToken()
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Lấy thông tin bản ghi thất bại!', {
theme: 'colored',
})
}
}
const getDropDown = async () => {
props.showLoading()
const res = await dropdownProductType({})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { name: e.type_name, value: e.id, ...e }
})
setListDrop(newList)
} else if (res.data.code == 401) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Lấy giữ liệu thất bại !', {
theme: 'colored',
})
}
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await updateProduct({
...newValue,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/product')
if (res.data.code == 200) {
toast.success('Cập nhật sản phẩm thành công!', {
theme: 'colored',
})
}
} else {
toast.error('Cập nhật sản phẩm thất bại!', {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const { name, code, price_default, type_id } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách sản phẩm',
path: '/product',
},
{ name: 'Cập nhật sản phẩm' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Thuộc chức năng *'}
className="mb-4 w-full"
value={type_id || ''}
disabled
displayEmpty
name="type_id"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{listDrop.map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên *"
onChange={handleChange}
type="text"
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã code *"
onChange={handleChange}
type="text"
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Giá mặc định *"
onChange={handleChange}
type="text"
name="price_default"
value={price_default || ''}
validators={['required', 'isNumber']}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
]}
/>
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Link to="/product">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Cp nht</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { Fragment, useState, useEffect } from 'react'
import {
TextField,
Icon,
Button,
StepLabel,
Step,
Stepper,
Grid,
FormControl,
InputLabel,
Select,
MenuItem,
} from '@material-ui/core'
import Table from './Table'
import { Breadcrumb } from 'app/components'
import { Link } from 'react-router-dom'
import { Autocomplete, createFilterOptions } from '@material-ui/lab'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
function CustomerView(props) {
const [age, setAge] = React.useState('')
const {
data,
updateItem,
removeItem,
setTxtSearch,
changeActive,
setChangeActive,
handeChangeActive,
setPageIndex,
pageIndex,
totalRecords,
permissions,
} = props
const { user } = useAuth()
const handleChange = (event) => {
setAge(event.target.value)
}
return (
<Fragment>
<div className="m-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách sản phẩm',
path: '/product',
},
]}
/>
</div>
<Grid
style={{
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid item lg={3} md={3} sm={6} xs={6}>
<TextField
variant="outlined"
className="w-full"
label="Tên sản phẩm"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
{checkRole(user, '/product/create') ? (
<Link to="/product/create">
<Button
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>Thêm mi</span>
</Button>
</Link>
) : null}
</Grid>
<Table
data={data}
changeActive={changeActive}
setChangeActive={setChangeActive}
handeChangeActive={handeChangeActive}
updateItem={updateItem}
removeItem={removeItem}
pageIndex={pageIndex}
setPageIndex={setPageIndex}
totalRecords={totalRecords}
permissions={permissions}
/>
</div>
</Fragment>
)
}
export default CustomerView
import React, { useState, useEffect } from 'react'
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator'
import { Button, Grid } from '@material-ui/core'
import { createProductType } from 'app/apis/Functions/product'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const history = useHistory()
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createProductType({
...newValue,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/product-type')
if (res.data.code == 200) {
toast.success('Tạo loại sản phẩm thành công!', {
theme: 'colored',
})
}
} else {
toast.error('Tạo loại sản phẩm thất bại!', {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const { name, code } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách loại sản phẩm',
path: '/product-type',
},
{ name: 'Thêm mới loại sản phẩm' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên loại sản phẩm *"
onChange={handleChange}
type="text"
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
{/* <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã loại sản phẩm *"
onChange={handleChange}
type="text"
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid> */}
</Grid>
<Grid container justify={'flex-end'}>
<Link to="/product-type">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Thêm mi</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListProductTypes,
deleteProductType,
changeStatusProductType,
} from 'app/apis/Functions/product'
import { useHistory } from 'react-router-dom'
import KEY from '../../../assets/Key'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const searchDebount = useDebounce(txtSearch, 1000)
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const history = useHistory()
const [data, setData] = useState([])
const [permissions, setPermissions] = useState([])
// useEffect(() => {
// getListPermission();
// }, []);
// const getListPermission = () => {
// let temp = localStorage.getItem(KEY.LISTPATH);
// let listPath = JSON.parse(temp);
// if (listPath) {
// const newlist = listPath.map((e) => {
// if (e.function_code) return e.function_code;
// return e.action_code;
// });
// setPermissions(newlist);
// }
// };
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusProductType({ id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Thay đổi trạng thái thành công!', {
theme: 'colored',
})
} else {
toast.error('Thay đổi trạng thái thất bại!', {
theme: 'colored',
})
}
}
const getData = async () => {
props.showLoading()
const res = await getListProductTypes({
name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(res.data)
const newList = res.data.data.data.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
// enqueueSnackbar('Error!', { variant: 'error' })
}
}
useEffect(() => {
getData()
}, [searchDebount, pageIndex])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteProductType({ id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Xoá bản ghi thành công!', {
theme: 'colored',
})
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Xoá bản ghi thất bại!', {
theme: 'colored',
})
}
}
return (
<ToolUserView
data={data}
removeItem={removeItem}
setTxtSearch={setTxtSearch}
setActiveSeleted={setActiveSeleted}
pageIndex={pageIndex}
changeActive={changeActive}
setChangeActive={setChangeActive}
setPageIndex={setPageIndex}
activeSelected={activeSelected}
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
permissions={permissions}
/>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
ToolNotificate
)
import React, { useState, useEffect } from 'react'
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator'
import { Button, Grid } from '@material-ui/core'
import {
detailProductType,
updateProductType,
} from 'app/apis/Functions/product'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux'
import localStorageService from 'app/services/localStorageService'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const history = useHistory()
const location = useLocation()
useEffect(() => {
getData()
}, [])
const getData = async () => {
props.showLoading()
const res = await detailProductType(location.state, {})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
setState(res.data.data)
} else if (res.data.code == 401) {
localStorageService.removeToken()
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Lấy thông tin bản ghi thất bại!', {
theme: 'colored',
})
}
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await updateProductType({
...newValue,
status: 1,
is_default: true,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/product-type')
if (res.data.code == 200) {
toast.success('Cập nhật loại sản phẩm thành công!', {
theme: 'colored',
})
}
} else {
toast.error('Cập nhật loại sản phẩm thất bại!', {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const { description, name, code, url } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách loại sản phẩm',
path: '/product-type',
},
{ name: 'Cập nhật loại sản phẩm' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên loại sản phẩm *"
onChange={handleChange}
type="text"
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Link to="/product-type">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Cp nht</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { Fragment, useState, useEffect } from 'react'
import {
TextField,
Icon,
Button,
StepLabel,
Step,
Stepper,
Grid,
FormControl,
InputLabel,
Select,
MenuItem,
} from '@material-ui/core'
import Table from './Table'
import { Breadcrumb } from 'app/components'
import { Link } from 'react-router-dom'
import { Autocomplete, createFilterOptions } from '@material-ui/lab'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
function CustomerView(props) {
const {
data,
updateItem,
removeItem,
setTxtSearch,
changeActive,
setChangeActive,
handeChangeActive,
setPageIndex,
pageIndex,
totalRecords,
permissions,
} = props
const [age, setAge] = React.useState('')
const { user } = useAuth()
const handleChange = (event) => {
setAge(event.target.value)
}
return (
<Fragment>
<div className="m-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách loại sản phẩm',
path: '/product-type',
},
]}
/>
</div>
<Grid
style={{
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid item lg={3} md={3} sm={6} xs={6}>
<TextField
variant="outlined"
className="w-full"
label="Tên loại sản phẩm"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
{checkRole(user, '/product-type/create') ? (
<Link to="/product-type/create">
<Button
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>Thêm mi</span>
</Button>
</Link>
) : null}
</Grid>
<Table
data={data}
changeActive={changeActive}
setChangeActive={setChangeActive}
handeChangeActive={handeChangeActive}
updateItem={updateItem}
removeItem={removeItem}
pageIndex={pageIndex}
setPageIndex={setPageIndex}
totalRecords={totalRecords}
permissions={permissions}
/>
</div>
</Fragment>
)
}
export default CustomerView
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment