2022-06-08 13:40:22 +00:00
|
|
|
import React from "react";
|
2022-07-03 05:24:46 +00:00
|
|
|
import PropTypes from "prop-types";
|
2022-06-08 13:40:22 +00:00
|
|
|
import { ReactSVG } from "react-svg";
|
2022-07-04 01:57:58 +00:00
|
|
|
import { isMobile } from "react-device-detect";
|
2022-06-08 13:40:22 +00:00
|
|
|
|
2023-01-27 14:08:30 +00:00
|
|
|
import ArchiveSvg32Url from "PUBLIC_DIR/images/icons/32/room/archive.svg?url";
|
|
|
|
import CustomSvg32Url from "PUBLIC_DIR/images/icons/32/room/custom.svg?url";
|
|
|
|
import EditingSvg32Url from "PUBLIC_DIR/images/icons/32/room/editing.svg?url";
|
|
|
|
import FillingFormSvg32Url from "PUBLIC_DIR/images/icons/32/room/filling.form.svg?url";
|
|
|
|
import ReviewSvg32Url from "PUBLIC_DIR/images/icons/32/room/review.svg?url";
|
|
|
|
import ViewOnlySvg32Url from "PUBLIC_DIR/images/icons/32/room/view.only.svg?url";
|
2023-01-10 14:29:12 +00:00
|
|
|
|
2022-07-22 19:01:25 +00:00
|
|
|
import { RoomsType } from "@docspace/common/constants";
|
2022-06-26 09:43:08 +00:00
|
|
|
|
2022-07-03 05:24:46 +00:00
|
|
|
import Checkbox from "../checkbox";
|
2022-06-08 13:40:22 +00:00
|
|
|
|
2022-07-03 05:24:46 +00:00
|
|
|
import { StyledContainer, StyledLogoContainer } from "./styled-room-logo";
|
|
|
|
|
|
|
|
const RoomLogo = ({
|
|
|
|
id,
|
|
|
|
className,
|
|
|
|
style,
|
|
|
|
type,
|
|
|
|
isPrivacy,
|
|
|
|
isArchive,
|
|
|
|
withCheckbox,
|
|
|
|
isChecked,
|
|
|
|
isIndeterminate,
|
|
|
|
onChange,
|
|
|
|
}) => {
|
2022-06-08 13:40:22 +00:00
|
|
|
const getIcon = () => {
|
2022-06-26 09:43:08 +00:00
|
|
|
if (isArchive) {
|
2023-01-10 14:29:12 +00:00
|
|
|
return ArchiveSvg32Url;
|
2022-06-26 09:43:08 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 13:40:22 +00:00
|
|
|
switch (type) {
|
2022-06-26 09:43:08 +00:00
|
|
|
case RoomsType.ReadOnlyRoom:
|
2023-01-16 15:42:48 +00:00
|
|
|
return ViewOnlySvg32Url;
|
2022-06-26 09:43:08 +00:00
|
|
|
case RoomsType.ReviewRoom:
|
2023-01-16 15:42:48 +00:00
|
|
|
return ReviewSvg32Url;
|
2022-06-26 09:43:08 +00:00
|
|
|
case RoomsType.FillingFormsRoom:
|
2023-01-10 14:29:12 +00:00
|
|
|
return FillingFormSvg32Url;
|
2022-06-26 09:43:08 +00:00
|
|
|
case RoomsType.EditingRoom:
|
2023-01-10 14:29:12 +00:00
|
|
|
return EditingSvg32Url;
|
2022-06-26 09:43:08 +00:00
|
|
|
case RoomsType.CustomRoom:
|
2023-01-10 14:29:12 +00:00
|
|
|
return CustomSvg32Url;
|
2022-06-26 09:43:08 +00:00
|
|
|
default:
|
2023-01-10 14:29:12 +00:00
|
|
|
return "";
|
2022-06-08 13:40:22 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-07-04 01:57:58 +00:00
|
|
|
const onSelect = () => {
|
|
|
|
if (!isMobile) return;
|
|
|
|
|
|
|
|
onChange && onChange();
|
|
|
|
};
|
|
|
|
|
2022-06-08 13:40:22 +00:00
|
|
|
const icon = getIcon();
|
|
|
|
|
|
|
|
return (
|
2022-07-03 05:24:46 +00:00
|
|
|
<StyledContainer id={id} className={className} style={style}>
|
|
|
|
<StyledLogoContainer
|
|
|
|
className="room-logo_icon-container"
|
2022-07-04 01:57:58 +00:00
|
|
|
onClick={onSelect}
|
2022-07-03 05:24:46 +00:00
|
|
|
>
|
2023-01-16 15:42:48 +00:00
|
|
|
<img className="room-logo_icon" src={icon} />
|
2022-07-03 05:24:46 +00:00
|
|
|
</StyledLogoContainer>
|
|
|
|
|
|
|
|
{withCheckbox && (
|
|
|
|
<Checkbox
|
|
|
|
className="room-logo_checkbox checkbox"
|
|
|
|
isChecked={isChecked}
|
|
|
|
isIndeterminate={isIndeterminate}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</StyledContainer>
|
2022-06-08 13:40:22 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
RoomLogo.defaultProps = {
|
|
|
|
isPrivacy: false,
|
2022-06-26 12:56:20 +00:00
|
|
|
isArchive: false,
|
2022-07-03 05:24:46 +00:00
|
|
|
withCheckbox: false,
|
|
|
|
isChecked: false,
|
|
|
|
isIndeterminate: false,
|
2022-06-08 13:40:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
RoomLogo.propTypes = {
|
|
|
|
/** Accepts type of the room */
|
2022-06-26 09:43:08 +00:00
|
|
|
type: PropTypes.number,
|
2022-06-08 13:40:22 +00:00
|
|
|
/** Add privacy icon */
|
|
|
|
isPrivacy: PropTypes.bool,
|
2022-06-26 12:56:20 +00:00
|
|
|
/** Add archive icon */
|
|
|
|
isArchive: PropTypes.bool,
|
2022-07-03 05:24:46 +00:00
|
|
|
/** Add checkbox when row/tile is hovered or checked */
|
|
|
|
withCheckbox: PropTypes.bool,
|
|
|
|
/** Add checked state to checkbox */
|
|
|
|
isChecked: PropTypes.bool,
|
|
|
|
/** Add indeterminate state to checkbox */
|
|
|
|
isIndeterminate: PropTypes.bool,
|
|
|
|
/** Add onChange checkbox callback function */
|
|
|
|
onChange: PropTypes.func,
|
2022-06-08 13:40:22 +00:00
|
|
|
/** Accepts id */
|
|
|
|
id: PropTypes.string,
|
|
|
|
/** Accepts class name */
|
|
|
|
className: PropTypes.string,
|
|
|
|
/** Accepts css style */
|
|
|
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
|
|
};
|
|
|
|
|
|
|
|
export default React.memo(RoomLogo);
|