Publicity.tsx 957 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { ProFormSelect } from "@ant-design/pro-components";
  2. import { useIntl } from "react-intl";
  3. import { publicityList, type TPublicity } from "./PublicitySelect"
  4. interface IWidget {
  5. width?: number | "md" | "sm" | "xl" | "xs" | "lg";
  6. disable?: TPublicity[];
  7. name?: string;
  8. readonly?: boolean;
  9. }
  10. const Publicity = ({
  11. width,
  12. disable = [],
  13. name = "status",
  14. readonly,
  15. }: IWidget) => {
  16. const intl = useIntl();
  17. const options = publicityList.map((item) => {
  18. return {
  19. value: item,
  20. label: intl.formatMessage({
  21. id: `forms.fields.publicity.${item}.label`,
  22. }),
  23. disable: disable.includes(item),
  24. };
  25. });
  26. return (
  27. <ProFormSelect
  28. options={options.filter((value) => value.disable === false)}
  29. readonly={readonly}
  30. width={width}
  31. name={name}
  32. allowClear={false}
  33. label={intl.formatMessage({ id: "forms.fields.publicity.label" })}
  34. />
  35. );
  36. };
  37. export default Publicity;