import React from 'react'; import intl from 'react-intl-universal'; import styled from 'styled-components'; import { Menu, MenuItem, MenuDivider, Intent, Classes, } from '@blueprintjs/core'; import { Icon, If } from '../../../components'; import { safeCallback } from 'utils'; const WAREHOUSES_SKELETON_N = 4; /** * Warehouse grid item box context menu. * @returns {JSX.Element} */ export function WarehouseContextMenu({ onEditClick, onDeleteClick, onMarkPrimary, warehouse, }) { return ( } text={intl.get('warehouses.action.edit_warehouse')} onClick={safeCallback(onEditClick)} /> } text={intl.get('warehouses.action.make_as_parimary')} onClick={safeCallback(onMarkPrimary)} /> } intent={Intent.DANGER} onClick={safeCallback(onDeleteClick)} /> ); } /** * Warehouse grid item box skeleton. * @returns {JSX.Element} */ function WarehouseGridItemSkeletonBox() { return ( X X X X ); } /** * Warehouse grid item box. * @returns {JSX.Element} */ export function WarehousesGridItemBox({ title, code, city, country, email, phoneNumber, primary, }) { return ( {title} {primary && } {code} {city && {city}} {country && {country}} {email && {email}} {phoneNumber && {phoneNumber}} ); } export function WarehousesSkeleton() { return [...Array(WAREHOUSES_SKELETON_N)].map((key, value) => ( )); } export const WarehousesList = styled.div` display: flex; flex-wrap: wrap; margin: 15px; height: 100%; `; export const WarehouseBoxRoot = styled.div` display: flex; flex-direction: column; flex-shrink: 0; border-radius: 5px; border: 1px solid #c8cad0; background: #fff; margin: 5px 5px 8px; width: 200px; height: 160px; transition: all 0.1s ease-in-out; padding: 12px; position: relative; &:hover { border-color: #0153cc; } `; export const WarehouseHeader = styled.div` position: relative; padding-right: 24px; padding-top: 2px; `; export const WarehouseTitle = styled.div` font-size: 14px; font-style: inherit; color: #000; white-space: nowrap; font-weight: 500; line-height: 1; .bp3-icon { margin: 0; margin-left: 2px; vertical-align: top; color: #e1b31d; } `; const WarehouseCode = styled.div` display: block; font-size: 11px; color: #6b7176; margin-top: 4px; `; const WarehouseIcon = styled.div` position: absolute; top: 0; color: #abb3bb; right: 0; `; const WarehouseContent = styled.div` width: 100%; margin-top: auto; `; const WarehouseItem = styled.div` font-size: 11px; color: #000; text-overflow: ellipsis; overflow: hidden; &:not(:last-of-type) { margin-bottom: 5px; } `;