Commit 0966bc70 by Giang Tran

update code

parent cea04004
......@@ -10,7 +10,7 @@ import ManageJobRoutes from './views/Company/ManageJob/ManageJobRoutes'
import MyAccountRouters from './views/MyAccount/MyAccountRoute'
import FuntionRouters from './views/Company/Function/FuntionRoutes'
import SystemRouters from './views/System/SystemRouters'
import ProductRoutes from './views/product/ProductRouters'
......@@ -29,6 +29,7 @@ const errorRoute = [
]
const routes = [
...ProductRoutes,
...SystemRouters,
...FuntionRouters,
...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) =>
.then((res) => res)
.catch((err) => null)
export const getDropDownGroup = async (body) =>
GetData(url.dropdownUserGroup, body)
.then((res) => res)
.catch((err) => null)
export const dropdownListActive = async (body) =>
GetData(url.dropdownListActive, body)
.then((res) => res)
......@@ -35,117 +40,7 @@ export const dropdownUserApprove = async (body) =>
.then((res) => res)
.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) =>
GetData(url.dropdownProductType, body)
.then((res) => res)
.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)
......@@ -37,212 +37,21 @@ export default {
urlListActionByGroup: `${root}/usergroup/permission`,
changeStatusGroup: `${root}/usergroup/changeStatus`,
//Tin tuc
urlGetListCategoryNews: `${root}/blogcategory/list`,
urlCreateCategoryNews: `${root}/blogcategory/create`,
urlUpdateCategoryNews: `${root}/blogcategory/update`,
urlDeleteCategoryNews: `${root}/blogcategory/delete`,
urlDetailCategoryNews: `${root}/blogcategory`,
changeStatusCategoryNews: `${root}/blogcategory/changeStatus`,
//Bai viet
urlGetListPosts: `${root}/blog/list`,
urlCreatePosts: `${root}/blog/create`,
urlUpdatePosts: `${root}/blog/update`,
urlDeletePosts: `${root}/blog/delete`,
urlDetailPosts: `${root}/blog`,
changeStatusPosts: `${root}/blog/changeStatus`,
//Banner
urlGetListBanner: `${root}/banner/list`,
urlCreateBanner: `${root}/banner/create`,
urlUpdateBanner: `${root}/banner/update`,
urlDeleteBanner: `${root}/banner/delete`,
urlDetailBanner: `${root}/banner`,
changeStatusBanner: `${root}/banner/changeStatus`,
//Social network
urlGetListSocialNetwork: `${root}/socialnetwork/list`,
urlCreateSocialNetwork: `${root}/socialnetwork/create`,
urlUpdateSocialNetwork: `${root}/socialnetwork/update`,
urlDeleteSocialNetwork: `${root}/socialnetwork/delete`,
urlDetailSocialNetwork: `${root}/socialnetwork`,
changeStatusSocialNetwork: `${root}/socialnetwork/changeStatus`,
//Notification
urlGetListNotification: `${root}/notification/list`,
urlCreateNotification: `${root}/notification/create`,
urlUpdateNotification: `${root}/notification/update`,
urlDeleteNotification: `${root}/notification/delete`,
urlDetailNotification: `${root}/notification`,
changeStatusNotification: `${root}/notification/changeStatus`,
//sms
urlGetListSms: `${root}/smslog/list`,
urlCreateSms: `${root}/smslog/create`,
urlDetailSms: `${root}/smslog`,
//email
urlGetListEmail: `${root}/emaillog/list`,
urlCreateEmail: `${root}/emaillog/create`,
urlDetailEmail: `${root}/emaillog`,
//Ask manager
urlGetListAskManager: `${root}/askmanager/list`,
urlCreateAskManager: `${root}/askmanager/create`,
urlUpdateAskManager: `${root}/askmanager/update`,
urlDeleteAskManager: `${root}/askmanager/delete`,
urlDetailAskManager: `${root}/askmanager`,
changeStatusAskManager: `${root}/askmanager/changeStatus`,
//Day off
urlGetListHoliday: `${root}/holiday/list`,
urlCreateHoliday: `${root}/holiday/create`,
urlUpdateHoliday: `${root}/holiday/update`,
urlDeleteHoliday: `${root}/holiday/delete`,
urlDetailHoliday: `${root}/holiday`,
changeStatusHoliday: `${root}/holiday/changeStatus`,
//upload file
//Phong ban
urlGetDepartments: `${root}/organization/list`,
urlCreateDepartment: `${root}/organization/create`,
urlUpdateDepartment: `${root}/organization/update`,
urlDeleteDepartment: `${root}/organization/delete`,
urlDetailDepartment: `${root}/organization`,
changeStatusDepartment: `${root}/organization/changeStatus`,
//Nhan vien
urlGetEmployee: `${root}/user/list`,
urlCreateEmployee: `${root}/user/create`,
urlUpdateEmployee: `${root}/user/update`,
urlDeleteEmployee: `${root}/user/delete`,
urlDetailEmployee: `${root}/user`,
changeStatusEmployee: `${root}/user/changeStatus`,
actionByGroup: `${root}/usergroup/permission`,
urlUploadFile: `${root}/upload/uploadfile`,
//Page Static
urlGetListPageStatic: `${root}/staticpage/list`,
urlCreatePageStatic: `${root}/staticpage/create`,
urlUpdatePageStatic: `${root}/staticpage/update`,
urlDeletePageStatic: `${root}/staticpage/delete`,
urlDetailPageStatic: `${root}/staticpage`,
changeStatusPageStatic: `${root}/staticpage/changeStatus`,
//category
urlGetCategory: `${root}/otherlist/list`,
urlCreateCategory: `${root}/otherlist/create`,
urlUpdateCategory: `${root}/otherlist/update`,
urlDeleteCategory: `${root}/otherlist/delete`,
urlDetailCategory: `${root}/otherlist`,
//category-type
urlGetCategoryType: `${root}/otherlisttype/list`,
urlCreateCategoryType: `${root}/otherlisttype/create`,
urlUpdateCategoryType: `${root}/otherlisttype/update`,
urlDeleteCategoryType: `${root}/otherlisttype/delete`,
urlDetailCategoryType: `${root}/otherlisttype`,
//Log
logAuth: `${root}/logging/listLogin`,
logApi: `${root}/logging/listCallApi`,
logAction: `${root}/logging/listAction`,
//Setting holiday
getListHoliday: `${root}/settings/getSettings`,
updateHoliday: `${root}/settings/updateSettings`,
//BANK
urlGetBank: `${root}/bank/list`,
urlCreateBank: `${root}/bank/create`,
urlUpdateBank: `${root}/bank/update`,
urlDeleteBank: `${root}/bank/delete`,
urlDetailBank: `${root}/bank`,
//Issuers
urlGetListIsuer: `${root}/issuers/list`,
urlCreateIsuer: `${root}/issuers/create`,
urlUpdateIsuer: `${root}/issuers/update`,
urlDeleteIsuer: `${root}/issuers/delete`,
urlDetailIsuer: `${root}/issuers`,
//Agent release
urlGetAgentRelease: `${root}/branch/list`,
urlCreateAgentRelease: `${root}/branch/create`,
urlUpdateAgentRelease: `${root}/branch/update`,
urlDeleteAgentRelease: `${root}/branch/delete`,
urlDetailAgentRelease: `${root}/branch`,
// Issuers account bank
urlGetIsuerBankAccount: `${root}/issuersbankaccount/list`,
urlCreateIsuerBankAccount: `${root}/issuersbankaccount/create`,
urlUpdateIsuerBankAccount: `${root}/issuersbankaccount/update`,
urlDeleteIsuerBankAccount: `${root}/issuersbankaccount/delete`,
urlDetailIsuerBankAccount: `${root}/issuersbankaccount`,
//PeriodInterest
urlGetPeriodInterest: `${root}/period/list`,
urlCreatePeriodInterest: `${root}/period/create`,
urlUpdatePeriodInterest: `${root}/period/update`,
urlDeletePeriodInterest: `${root}/period/delete`,
urlDetailPeriodInterest: `${root}/period`,
//RankCustomer
urlGetRankCustomer: `${root}/customerrank/list`,
urlCreateRankCustomer: `${root}/customerrank/create`,
urlUpdateRankCustomer: `${root}/customerrank/update`,
urlDeleteRankCustomer: `${root}/customerrank/delete`,
urlDetailRankCustomer: `${root}/customerrank`,
//customercare
urlGetCustomerCare: `${root}/customercare/list`,
urlCreateCustomerCare: `${root}/customercare/create`,
urlDetailCustomerCare: `${root}/customercare`,
//FormTeamplate
urlGetFormTeamplate: `${root}/formtemplate/list`,
urlCreateFormTeamplate: `${root}/formtemplate/create`,
urlUpdateFormTeamplate: `${root}/formtemplate/update`,
urlDeleteFormTeamplate: `${root}/formtemplate/delete`,
urlDetailFormTeamplate: `${root}/formtemplate`,
changeStatusFormTeamplate: `${root}/formtemplate/changeStatus`,
//ProductGroup
urlGetProductGroup: `${root}/productgroup/list`,
urlCreateProductGroup: `${root}/productgroup/create`,
urlUpdateProductGroup: `${root}/productgroup/update`,
urlDeleteProductGroup: `${root}/productgroup/delete`,
urlDetailProductGroup: `${root}/productgroup`,
changeStatusProductGroup: `${root}/productgroup/changeStatus`,
//Customer
urlGetCustomer: `${root}/customer/list`,
urlCreateCustomer: `${root}/customer/create`,
urlUpdateCustomer: `${root}/customer/update`,
urlDeleteCustomer: `${root}/customer/delete`,
urlDetailCustomer: `${root}/customer`,
changeStatusCustomer: `${root}/customer/changeStatus`,
asignCustomer: `${root}/customer/assign`,
//Release package
urlGetReleasePackage: `${root}/realeasepackage/list`,
urlCreateReleasePackage: `${root}/realeasepackage/create`,
urlUpdateReleasePackage: `${root}/realeasepackage/update`,
urlDeleteReleasePackage: `${root}/realeasepackage/delete`,
urlDetailReleasePackage: `${root}/realeasepackage`,
urlchangeStatusReleasePackage: `${root}/realeasepackage/changeStatus`,
urlapproveReleasePackage: `${root}/realeasepackage/approve`,
//Product Invest
urlGetProductInvest: `${root}/product/list`,
urlCreateProductInvest: `${root}/product/create`,
urlUpdateProductInvest: `${root}/product/update`,
urlDeleteProductInvest: `${root}/product/delete`,
urlDetailProductInvest: `${root}/product`,
urlchangeStatusProductInvest: `${root}/product/changeStatus`,
urlapproveProductInvest: `${root}/product/approve`,
//product-type
urlGetListProductType: `${root}/poducttype/list`,
urlCreateProductType: `${root}/poducttype/create`,
urlUpdateProductType: `${root}/poducttype/update`,
urlDeleteProductType: `${root}/poducttype/delete`,
urlDetailProductType: `${root}/poducttype`,
changeStatusProductType: `${root}/poducttype/changeStatus`,
//product
urlGetListProduct: `${root}/product/list`,
urlCreateProduct: `${root}/product/create`,
urlUpdateProduct: `${root}/product/update`,
urlDeleteProduct: `${root}/product/delete`,
urlDetailProduct: `${root}/product`,
changeStatusProduct: `${root}/product/changeStatus`,
//dropdown
dropdownFuntions: `${root}/dropdown/function`,
......@@ -251,32 +60,5 @@ export default {
dropdownDepartment: `${root}/dropdown/organization`,
dropdownUserGroup: `${root}/dropdown/usergroup`,
dropdownListActive: `${root}/dropdown/status`,
dropdownUserApprove: `${root}/dropdown/userApprove`,
dropdownSurveyType: `${root}/dropdown/surveyType`,
dropdownAskType: `${root}/dropdown/askType`,
dropdownCategoryType: `${root}/dropdown/otherlistType`,
dropdownBank: `${root}/dropdown/bank`,
dropdownIsuers: `${root}/dropdown/issuers`,
dropdownCustomerType: `${root}/dropdown/customerType`,
dropdownCustomerRank: `${root}/dropdown/customerrank`,
dropdownGender: `${root}/dropdown/gender`,
dropdownCustomerShareType: `${root}/dropdown/customerShareType`,
dropdownBranch: `${root}/dropdown/branch`,
dropdownCareResult: `${root}/dropdown/careResult`,
dropdownCareType: `${root}/dropdown/careType`,
dropdownGetINation: `${root}/dropdown/nation`,
dropdownGetIProvince: `${root}/dropdown/province`,
dropdownGetIProvinceBy: `${root}/dropdown/provinceBy`,
dropdownGetIssuersType: `${root}/dropdown/issuersType`,
dropdownGetOrganizationIdenMethod: `${root}/dropdown/organizationIdenMethod`,
dropdownGetPersonIdenMethod: `${root}/dropdown/personIdenMethod`,
dropdownPeriod: `${root}/dropdown/period`,
dropdownTypePeriod: `${root}/dropdown/periodType`,
dropdownRealeasePackage: `${root}/dropdown/realeasePackage`,
dropdownProductGroup: `${root}/dropdown/productGroup`,
dropdownProductType: `${root}/dropdown/productType`,
dropdownFormTemplate: `${root}/dropdown/formTemplate`,
}
......@@ -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',
......@@ -108,6 +130,28 @@ export const navigationsAdmin = [
type: 'label',
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',
......
......@@ -93,7 +93,7 @@ const SimpleForm = (props) => {
userPermissions: newList,
avatar: image,
status: true,
status: 1,
})
console.log(res)
props.hideLoading()
......
......@@ -10,12 +10,12 @@ import KEY from 'app/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)
......@@ -58,7 +58,7 @@ const ToolNotificate = (props) => {
const getData = async () => {
props.showLoading()
const res = await getListEmployees({
full_name: txtSearch,
full_name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
})
......@@ -81,7 +81,7 @@ const ToolNotificate = (props) => {
useEffect(() => {
getData()
}, [txtSearch, pageIndex])
}, [searchDebount, pageIndex])
const removeItem = async (id) => {
props.showLoading()
......
......@@ -22,18 +22,17 @@ import { connect } from 'react-redux'
import {
dropdownDepartment,
dropdownUserGroup,
getDropDownGroup,
} from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage'
import {
actionByGroup,
updateEmployee,
createEmployee,
detailEmployee,
updateEmployee,
} from 'app/apis/Functions/Employee'
const SimpleForm = (props) => {
const history = useHistory()
const location = useLocation()
const [state, setState] = useState({})
const [listDepartment, setListDepartment] = useState([])
const [listDrop, setListDrop] = useState([])
......@@ -42,46 +41,52 @@ const SimpleForm = (props) => {
const [listChecked, setListChecked] = useState([])
const [role, setRole] = useState()
const [listGroup, setGroup] = useState([])
const [checkAll, setCheckAll] = useState(true)
const location = useLocation()
const [defaultAction, setDefaultAction] = useState([])
useEffect(() => {
getData()
getListDepartments()
getUserGroup()
getData()
}, [])
useEffect(() => {
getListDefault()
}, [defaultAction])
useEffect(() => {
getListAction()
setListChecked([])
}, [role])
const history = useHistory()
const getListDefault = () => {
const newList = defaultAction.map((e) => {
return e.action_id
})
setListChecked(newList)
}
const getData = async () => {
props.showLoading()
const res = await detailEmployee(location.state, {})
Promise.all([
detailEmployee(location.state, {}),
getDropDownGroup({}),
]).then((values) => {
setState(values[0].data.data)
setImage(values[0].data.data.avatar)
setRole(values[0].data.data.user_group_id)
// setBirdth(convertTimeApi(values[0].data.data.birth_day))
// setGender(values[0].data.data.gender == 6 ? '6' : '7')
setGroup(values[1].data.data)
setDefaultAction(values[0].data.data.userPermissions)
})
props.hideLoading()
console.log('res.data.data', res.data.data)
if (res.data.code == 200 && res.data.data) {
setRole(res.data.data.user_group_id)
setState(res.data.data)
setImage(res.data.data.avatar)
if (res.data.data.userPermissions.length > 0) {
const newList = res.data.data.userPermissions.map(
(e) => e.action_id
)
setListChecked(newList)
}
} else if (res.data.code == 401) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Lấy thông tin bản ghi thất bại!', {
theme: 'colored',
})
}
}
const getListAction = async () => {
if (role) {
const res = await actionByGroup(role, {})
console.log('res.data.data', res.data.data)
if (res.data.code == 200 && res.data.data) {
setListAction(res.data.data.userGroupPermissions)
} else if (res.data.code == 401) {
......@@ -96,23 +101,9 @@ const SimpleForm = (props) => {
}
}
const getListDepartments = async () => {
const res = await dropdownDepartment({})
if (res.data.code == 200 && res.data.data) {
setListDepartment(res.data.data)
} 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 getUserGroup = async () => {
const res = await dropdownUserGroup({})
if (res.data.code == 200 && res.data.data) {
setGroup(res.data.data)
} else if (res.data.code == 401) {
......@@ -131,18 +122,15 @@ const SimpleForm = (props) => {
if (listChecked.length > 0) {
if (image) {
const newList = listChecked.map((e) => {
return { action_id: parseInt(e) }
return { action_id: e }
})
props.showLoading()
const res = await updateEmployee({
...newValue,
user_group_id: role,
is_customer_data_manager: newValue.is_customer_data_manager
? newValue.is_customer_data_manager
: false,
userPermissions: newList,
avatar: image,
status: 1,
})
console.log(res)
props.hideLoading()
......@@ -154,7 +142,7 @@ const SimpleForm = (props) => {
})
}
} else {
toast.error('Cập nhật nhân viên thất bại!', {
toast.error('Tạo nhân viên thất bại!', {
theme: 'colored',
})
}
......@@ -178,10 +166,6 @@ const SimpleForm = (props) => {
})
}
const handleCheck = (event) => {
setState({ ...state, [event.target.name]: event.target.checked })
}
const onFileChange = (url) => {
console.log(url)
setImage(url)
......@@ -189,7 +173,7 @@ const SimpleForm = (props) => {
const onPicker = (value) => {
if (value.target.checked) {
const newList = listChecked.concat(parseInt(value.target.name))
const newList = listChecked.concat(value.target.name)
setListChecked(newList)
} else {
const newList = listChecked.filter((e) => {
......@@ -199,16 +183,19 @@ const SimpleForm = (props) => {
}
}
const {
username,
password,
phone,
email,
address,
full_name,
organization_id,
is_customer_data_manager,
} = state
const handleCheckAllRole = (event) => {
setCheckAll(!checkAll)
if (checkAll == true) {
const newList = listAction.map((e) => e.action_id)
setListChecked(newList)
} else {
setListChecked([])
}
}
console.log('role', role)
const { username, password, phone, email, address, full_name } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
......@@ -219,7 +206,7 @@ const SimpleForm = (props) => {
name: 'Danh sách nhân viên',
path: '/employee',
},
{ name: 'Cập nhật nhân viên' },
{ name: 'Thêm mới nhân viên' },
]}
/>
</div>
......@@ -261,13 +248,13 @@ const SimpleForm = (props) => {
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
'maxStringLength:12',
]}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
'Số điện thoại nhiều nhất chỉ có 12 chữ số',
]}
/>
</Grid>
......@@ -308,9 +295,9 @@ const SimpleForm = (props) => {
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tài khoản *"
disabled
label="Tên đăng nhập *"
onChange={handleChange}
disabled
type="text"
name="username"
value={username || ''}
......@@ -320,30 +307,27 @@ const SimpleForm = (props) => {
]}
/>
</Grid>
<Grid lg={6} md={6} sm={12} xs={12} item>
<SelectValidator
variant={'outlined'}
label={'Phòng ban *'}
{/* <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
value={organization_id || ''}
displayEmpty
name="organization_id"
label="Mật khẩu *"
onChange={handleChange}
validators={['required']}
type="password"
name="password"
value={password || ''}
validators={[
'required',
'minStringLength:8',
]}
errorMessages={[
'Không được để trống trường này',
'Mật khẩu phải có ít nhất 8 ký tự',
]}
>
{listDepartment.map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
<Grid lg={6} md={6} sm={12} xs={12} item>
{role ? (
/>
</Grid> */}
{role && (
<Grid lg={6} md={6} sm={12} xs={12} item>
<SelectValidator
variant={'outlined'}
label={'Nhóm quyền *'}
......@@ -364,32 +348,33 @@ const SimpleForm = (props) => {
</MenuItem>
))}
</SelectValidator>
) : null}
</Grid>
<Grid lg={12} md={12} sm={12} xs={12} item>
<FormControlLabel
className="min-w-288"
control={
<Checkbox
size="small"
color="primary"
name="is_customer_data_manager"
onChange={handleCheck}
checked={
is_customer_data_manager ||
false
}
/>
}
label="Quản lý thông tin khách hàng"
/>
</Grid>
</Grid>
)}
<Grid item xs={12} sm={12}>
<Typography variant={'h6'}>
Danh sách hành động
</Typography>
{listAction.length > 0 ? (
<Grid lg={12} md={12} sm={12} xs={12} item>
<FormControlLabel
className="min-w-288"
control={
<Checkbox
size="small"
color="primary"
name="is_customer_data_manager"
onChange={
handleCheckAllRole
}
value={checkAll}
/>
}
label="Chọn tất cả các quyền"
/>
</Grid>
) : null}
<Grid row container item xs={12} sm={12}>
{listAction.map((e) => (
<Grid item xs={3}>
......@@ -397,13 +382,13 @@ const SimpleForm = (props) => {
label={e.action_name}
control={
<Checkbox
checked={listChecked.includes(
e.action_id
)}
size="small"
color="primary"
onChange={onPicker}
name={e.action_id}
checked={listChecked.includes(
e.action_id
)}
/>
}
/>
......
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 } from 'react'
import {
Paper,
Table,
TableBody,
TableCell,
TableHead,
TableContainer,
TablePagination,
TableRow,
IconButton,
MenuItem,
Select,
Modal,
Fade,
Grid,
Backdrop,
Link,
Button,
Tooltip,
Icon,
} from '@material-ui/core'
import EditIcon from '@material-ui/icons/Edit'
import DeleteIcon from '@material-ui/icons/Delete'
import colors from '../../../assets/Color'
import useStyles from '../../../styles/Table'
import { Breadcrumb, SimpleCard } from 'app/components'
import DialogTransition from 'app/components/dialog/DialogTransition'
import { useHistory } from 'react-router-dom'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
const columns = [
{
id: 'index',
label: 'STT',
align: 'center',
minWidth: 50,
},
{
id: 'product_name',
label: 'Tên sản phẩm',
align: 'left',
minWidth: 'auto',
},
{
id: 'code',
label: 'Mã code',
align: 'left',
minWidth: 'auto',
},
{
id: 'type_name',
label: 'Loại sản phẩm',
align: 'left',
minWidth: 'auto',
},
{
id: 'date_created',
label: 'Ngày tạo',
align: 'left',
minWidth: 'auto',
},
]
function TableList(props) {
const {
data,
handeChangeActive,
removeItem,
changeActive,
setChangeActive,
setPageIndex,
setPageSize,
pageIndex,
totalRecords,
permissions,
} = props
const classes = useStyles()
let history = useHistory()
const [selected, setSelected] = useState({
name: '',
id: '',
title: '',
content: '',
})
const [open, setOpen] = React.useState(false)
const handleChangePage = (event, newPage) => {
setPageIndex(newPage)
}
const handleChangeRowsPerPage = (event) => {
setPageSize(event.target.value)
}
const handleClose = () => {
setOpen(false)
}
const { user } = useAuth()
return (
<Paper className={classes.root}>
<TableContainer className={classes.container}>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
{columns.map((column) => (
<TableCell
key={column.id}
align={'center'}
style={{
width: column.minWidth,
backgroundColor: colors.headerTable,
}}
>
{column.label}
</TableCell>
))}
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 105,
}}
>
Trạng thái
</TableCell>
<TableCell
style={{
textAlign: 'center',
backgroundColor: colors.headerTable,
width: 120,
}}
>
sn phm
</TableCell>
</TableRow>
</TableHead>
<TableBody className={classes.columnTable}>
{data.map((row) => {
return (
<TableRow
hover
role="checkbox"
tabIndex={-1}
key={row.code}
>
{columns.map((column) => {
const imageUrl = row[column.id]
return (
<TableCell
key={column.id}
align={column.align}
>
{column.format ? (
<img
src={column.format(
imageUrl
)}
className={
classes.image
}
/>
) : (
imageUrl
)}
</TableCell>
)
})}
<TableCell className={classes.border}>
<Select
variant={'outlined'}
labelId="demo-simple-select-placeholder-label-label"
id="demo-simple-select-placeholder-label"
onChange={(e) =>
handeChangeActive(
row.id,
e.target.value
)
}
displayEmpty
defaultValue={row.status}
className={classes.formControl}
>
<MenuItem value={1}>
Hin th
</MenuItem>
<MenuItem value={2}>Khóa</MenuItem>
</Select>
</TableCell>
<TableCell>
{checkRole(user, '/product/delete') ? (
<Tooltip title="Xoá">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Xóa sản phẩm',
content: `Bạn có muốn xóa sản phẩm ${row.product_name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
) : null}
{checkRole(user, '/product/update') ? (
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {
history.push({
pathname:
'/product/update',
state: row.id,
})
}}
className={classes.button}
aria-label="edit"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
) : null}
</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
</TableContainer>
<DialogTransition
data={selected}
open={open}
handleClose={handleClose}
onAgree={() => {
removeItem(selected.id)
handleClose()
}}
/>
<TablePagination
component="div"
page={pageIndex}
count={totalRecords}
rowsPerPage={10}
rowsPerPageOptions={[]}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</Paper>
)
}
export default TableList
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 } from 'react'
import {
Paper,
Table,
TableBody,
TableCell,
TableHead,
TableContainer,
TablePagination,
TableRow,
IconButton,
MenuItem,
Select,
Modal,
Fade,
Grid,
Backdrop,
Link,
Button,
Tooltip,
Icon,
} from '@material-ui/core'
import EditIcon from '@material-ui/icons/Edit'
import DeleteIcon from '@material-ui/icons/Delete'
import colors from '../../../assets/Color'
import useStyles from '../../../styles/Table'
import { Breadcrumb, SimpleCard } from 'app/components'
import DialogTransition from 'app/components/dialog/DialogTransition'
import { useHistory } from 'react-router-dom'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
const columns = [
{
id: 'index',
label: 'STT',
align: 'center',
minWidth: 50,
},
{
id: 'name',
label: 'Tên loại sản phẩm',
align: 'left',
minWidth: 'auto',
},
// {
// id: 'code',
// label: 'Mã code',
// align: 'left',
// minWidth: 'auto',
// },
{
id: 'date_created',
label: 'Ngày tạo',
align: 'left',
minWidth: 'auto',
},
]
function TableList(props) {
const {
data,
handeChangeActive,
removeItem,
changeActive,
setChangeActive,
setPageIndex,
setPageSize,
pageIndex,
totalRecords,
permissions,
} = props
const classes = useStyles()
let history = useHistory()
const [selected, setSelected] = useState({
name: '',
id: '',
title: '',
content: '',
})
const [open, setOpen] = React.useState(false)
const { user } = useAuth()
const handleChangePage = (event, newPage) => {
setPageIndex(newPage)
}
const handleChangeRowsPerPage = (event) => {
setPageSize(event.target.value)
}
const handleClose = () => {
setOpen(false)
}
return (
<Paper className={classes.root}>
<TableContainer className={classes.container}>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
{columns.map((column) => (
<TableCell
key={column.id}
align={'center'}
style={{
width: column.minWidth,
backgroundColor: colors.headerTable,
}}
>
{column.label}
</TableCell>
))}
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 105,
}}
>
Trạng thái
</TableCell>
<TableCell
style={{
textAlign: 'center',
backgroundColor: colors.headerTable,
width: 120,
}}
>
Hành động
</TableCell>
</TableRow>
</TableHead>
<TableBody className={classes.columnTable}>
{data.map((row) => {
return (
<TableRow
hover
role="checkbox"
tabIndex={-1}
key={row.code}
>
{columns.map((column) => {
const imageUrl = row[column.id]
return (
<TableCell
key={column.id}
align={column.align}
>
{column.format ? (
<img
src={column.format(
imageUrl
)}
className={
classes.image
}
/>
) : (
imageUrl
)}
</TableCell>
)
})}
<TableCell className={classes.border}>
<Select
variant={'outlined'}
labelId="demo-simple-select-placeholder-label-label"
id="demo-simple-select-placeholder-label"
onChange={(e) =>
handeChangeActive(
row.id,
e.target.value
)
}
displayEmpty
defaultValue={row.status}
className={classes.formControl}
>
<MenuItem value={1}>
Hin th
</MenuItem>
<MenuItem value={2}>Khóa</MenuItem>
</Select>
</TableCell>
<TableCell>
{checkRole(
user,
'/product-type/delete'
) ? (
<Tooltip title="Xoá">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Xóa loại sản phẩm',
content: `Bạn có muốn xóa loại sản phẩm ${row.name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
) : null}
{checkRole(
user,
'/product-type/update'
) ? (
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {
history.push({
pathname:
'/product-type/update',
state: row.id,
})
}}
className={classes.button}
aria-label="edit"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
) : null}
</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
</TableContainer>
<DialogTransition
data={selected}
open={open}
handleClose={handleClose}
onAgree={() => {
removeItem(selected.id)
handleClose()
}}
/>
<TablePagination
component="div"
page={pageIndex}
count={totalRecords}
rowsPerPage={10}
rowsPerPageOptions={[]}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</Paper>
)
}
export default TableList
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