improving processing times label and hide when screen width is too low

This commit is contained in:
orangecoding
2025-11-01 10:08:13 +01:00
parent 1104f200ac
commit 9bd05e1e73

View File

@@ -1,16 +1,32 @@
import React from 'react'; import React from 'react';
import { format } from '../../services/time/timeService'; import { format } from '../../services/time/timeService';
import { Button, Card, Col, Row, Toast } from '@douyinfe/semi-ui'; import { Button, Card, Col, Row, Toast } from '@douyinfe/semi-ui';
import { IconPlayCircle } from '@douyinfe/semi-icons'; import {
IconClock,
IconDoubleChevronLeft,
IconDoubleChevronRight,
IconPlayCircle,
IconSearch,
} from '@douyinfe/semi-icons';
import { xhrPost } from '../../services/xhr.js'; import { xhrPost } from '../../services/xhr.js';
import './ProsessingTimes.less'; import './ProsessingTimes.less';
import { useScreenWidth } from '../../hooks/screenWidth.js';
function InfoCard({ title, value }) { function InfoCard({ title, value, icon }) {
const { Meta } = Card;
return ( return (
<Card style={{ maxWidth: '13rem', margin: '1rem', background: 'rgb(53, 54, 60)' }} title={title}> <div
{value} style={{
</Card> margin: '1rem',
background: 'rgb(53, 54, 60)',
borderRadius: '.3rem',
padding: '1rem',
minHeight: '3rem',
}}
>
<Meta title={title} description={value} avatar={icon} />
</div>
); );
} }
@@ -18,24 +34,44 @@ export default function ProcessingTimes({ processingTimes = {} }) {
if (Object.keys(processingTimes).length === 0) { if (Object.keys(processingTimes).length === 0) {
return null; return null;
} }
const width = useScreenWidth();
const invisible = width <= 1180;
if (invisible) {
return null;
}
return ( return (
<Row> <Row>
<Col span={6}> <Col span={6}>
<InfoCard title="Processing Interval" value={`${processingTimes.interval} min`} /> <InfoCard
title="Search Interval"
value={`${processingTimes.interval} min`}
icon={<IconClock style={{ color: 'rgba(var(--semi-grey-4), 1)' }} />}
/>
</Col> </Col>
{processingTimes.lastRun && ( {processingTimes.lastRun && (
<> <>
<Col span={6}> <Col span={6}>
<InfoCard title="Last run" value={format(processingTimes.lastRun)} /> <InfoCard
title="Last search"
icon={<IconDoubleChevronLeft style={{ color: 'rgba(var(--semi-grey-4), 1)' }} />}
value={format(processingTimes.lastRun)}
/>
</Col> </Col>
<Col span={6}> <Col span={6}>
<InfoCard title="Next run" value={format(processingTimes.lastRun + processingTimes.interval * 60000)} /> <InfoCard
title="Next search"
icon={<IconDoubleChevronRight style={{ color: 'rgba(var(--semi-grey-4), 1)' }} />}
value={format(processingTimes.lastRun + processingTimes.interval * 60000)}
/>
</Col> </Col>
</> </>
)} )}
<Col span={6}> <Col span={6}>
<InfoCard <InfoCard
title="Find Listings Now" title="Search Now"
icon={<IconSearch style={{ color: 'rgba(var(--semi-grey-4), 1)' }} />}
value={ value={
<Button <Button
size="small" size="small"