source: pages/forge/utils/RenderSpecs.tsx@ 1d8f088

main
Last change on this file since 1d8f088 was 1d8f088, checked in by Mihail <mihail2.naumov@…>, 5 months ago

Added +- buttons for ram and storage, rmeoved them from optional components.

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[1d8f088]1import { Chip, Typography } from '@mui/material';
2import React from "react";
3
4export function renderSpecs(c: any, type: string) {
5 if (!c) return null;
6 const data = {...c, ...(c.details || {})};
7 const chipStyle = {height: 24, fontSize: '0.75rem', bgcolor: 'rgba(0,0,0,0.05)'};
8 const specs: string[] = [];
9 const val = (k: string) => data[k] || data[k.toLowerCase()] || data[k.replace('_', '')];
10
11 switch (type) {
12 case 'cpu':
13 if (val('socket')) specs.push(val('socket'));
14 if (val('cores')) specs.push(`${val('cores')} Cores / ${val('threads')} Threads`);
15 const base = data.baseclock || data.baseClock || data.base_clock;
16 const boost = data.boostclock || data.boostClock || data.boost_clock;
17 if (base) specs.push(`Base: ${base}GHz`);
18 if (boost) specs.push(`Boost: ${boost}GHz`);
19 break;
20 case 'gpu':
21 if (val('vram')) specs.push(`${val('vram')}GB VRAM`);
22 if (val('chipset')) specs.push(val('chipset'));
23 if (val('length')) specs.push(`L: ${val('length')}mm`);
24 break;
25 case 'motherboard':
26 if (val('socket')) specs.push(val('socket'));
27 if (val('formfactor')) specs.push(val('formfactor'));
28 if (val('ramtype')) specs.push(val('ramtype'));
29 break;
30 case 'memory':
31 if (val('capacity')) specs.push(`${val('capacity')}GB`);
32 if (val('type')) specs.push(val('type'));
33 if (val('speed')) specs.push(`${val('speed')} MHz`);
34 if (val('modules')) specs.push(`${val('modules')}x`);
35 break;
36 case 'storage':
37 if (val('capacity')) specs.push(`${val('capacity')}GB`);
38 if (val('type')) specs.push(val('type'));
39 break;
40 case 'power_supply':
41 if (val('wattage')) specs.push(`Wattage: ${val('wattage')}W`);
42 if (val('type')) specs.push(val('type'));
43 break;
44 case 'case':
45 if (val('gpuMaxLength')) specs.push(`Max GPU Length: ${val('gpuMaxLength')}mm`);
46 if (val('coolerMaxHeight')) specs.push(`Max CPU Cooler Height: ${val('coolerMaxHeight')}mm`);
47 break;
48 case 'cooler':
49 if (val('type')) specs.push(`${val('type')} Cooler`);
50 if (val('height')) specs.push(`${val('height')}mm`);
51 break;
52 default:
53 if (data.brand) specs.push(data.brand);
54 }
55
56 if (specs.length === 0) {
57 if (data.brand) return <Chip label={data.brand} sx={chipStyle}/>;
58 return <Typography variant="caption" color="text.secondary">...</Typography>;
59 }
60
61 return specs.map((label, i) => <Chip key={i} label={label} sx={chipStyle}/>);
62}
Note: See TracBrowser for help on using the repository browser.