You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GHHub/src/hooks/useProductsSets.js

53 lines
1.8 KiB
JavaScript

import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
/**
* 产品管理 相关的预设数据
*/
export const useProductsTypes = () => {
const [types, setTypes] = useState([]);
const { t, i18n } = useTranslation();
useEffect(() => {
const newData = [
{ label: t('products:type.Experience'), value: 'Experience', key: 'Experience' },
{ label: t('products:type.Car'), value: 'Car', key: 'Car' },
{ label: t('products:type.Guide'), value: 'Guide', key: 'Guide' },
{ label: t('products:type.Package'), value: 'Package', key: 'Package' },
{ label: t('products:type.Attractions'), value: 'Attractions', key: 'Attractions' },
{ label: t('products:type.Meals'), value: 'Meals', key: 'Meals' },
{ label: t('products:type.Extras'), value: 'Extras', key: 'Extras' },
{ label: t('products:type.Special'), value: 'Special', key: 'Special' },
];
setTypes(newData);
}, [i18n.language]);
return types;
};
1 year ago
export const useProductsAuditStates = () => {
const [types, setTypes] = useState([]);
const { t, i18n } = useTranslation();
useEffect(() => {
const newData = [
{ key: '-1', value: '-1', label: t('products:auditState.New') },
{ key: '0', value: '0', label: t('products:auditState.Pending') },
{ key: '2', value: '2', label: t('products:auditState.Approved') },
// { key: '3', value: '3', label: t('products:auditState.Rejected') },
{ key: '1', value: '1', label: t('products:auditState.Published') },
];
setTypes(newData);
}, [i18n.language]);
return types;
};
export const useProductsAuditStatesMapVal = (value) => {
const stateSets = useProductsAuditStates();
const stateMapVal = stateSets.reduce((r, c) => ({ ...r, [`${c.value}`]: c }), {});
return stateMapVal;
};