File size: 4,939 Bytes
d97b8f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import React from 'react';
import { useSystemDetailsByAsset } from '@/hooks/asset-management/useSystemDetails';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { LoadingSpinner } from './shared';
import { Monitor, Cpu, HardDrive, MemoryStick, Palette } from 'lucide-react';

interface SystemDetailsExampleProps {
  assetId: number;
}

const SystemDetailsExample: React.FC<SystemDetailsExampleProps> = ({ assetId }) => {
  const { data: systemDetails, isLoading, error } = useSystemDetailsByAsset(assetId);

  if (isLoading) {
    return (
      <Card>

        <CardContent className="p-6">

          <LoadingSpinner size="md" text="Loading system details..." />

        </CardContent>

      </Card>
    );
  }

  if (error) {
    return (
      <Card>

        <CardContent className="p-6">

          <div className="text-center text-red-600">

            Error loading system details: {error.message}

          </div>

        </CardContent>

      </Card>
    );
  }

  if (!systemDetails) {
    return (
      <Card>

        <CardContent className="p-6">

          <div className="text-center text-muted-foreground">

            No system details found for this asset.

          </div>

        </CardContent>

      </Card>
    );
  }

  return (
    <Card>

      <CardHeader>

        <CardTitle className="flex items-center gap-2">

          <Monitor className="h-5 w-5" />

          System Details

          <Badge variant="outline">ID: {systemDetails.systemDetailsID}</Badge>

        </CardTitle>

      </CardHeader>

      <CardContent className="space-y-4">

        <div className="grid grid-cols-1 md:grid-cols-2 gap-4">

          <div className="space-y-3">

            <div className="flex items-center gap-2">

              <Monitor className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">System Model</div>

                <div className="text-sm text-muted-foreground">{systemDetails.systemModel}</div>

              </div>

            </div>

            

            <div className="flex items-center gap-2">

              <Cpu className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">Processor</div>

                <div className="text-sm text-muted-foreground">{systemDetails.processor}</div>

              </div>

            </div>

            

            <div className="flex items-center gap-2">

              <MemoryStick className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">Installed RAM</div>

                <div className="text-sm text-muted-foreground">{systemDetails.installedRAM}</div>

              </div>

            </div>

            

            <div className="flex items-center gap-2">

              <Palette className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">Graphics</div>

                <div className="text-sm text-muted-foreground">{systemDetails.graphics}</div>

              </div>

            </div>

          </div>

          

          <div className="space-y-3">

            <div className="flex items-center gap-2">

              <Monitor className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">Screen Resolution</div>

                <div className="text-sm text-muted-foreground">{systemDetails.screenResolution}</div>

              </div>

            </div>

            

            <div className="flex items-center gap-2">

              <HardDrive className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">Disk Model</div>

                <div className="text-sm text-muted-foreground">{systemDetails.diskModel}</div>

              </div>

            </div>

            

            <div className="flex items-center gap-2">

              <HardDrive className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">Disk Size</div>

                <div className="text-sm text-muted-foreground">{systemDetails.diskSize}</div>

              </div>

            </div>

            

            <div className="flex items-center gap-2">

              <Monitor className="h-4 w-4 text-muted-foreground" />

              <div>

                <div className="text-sm font-medium">Manufacturer</div>

                <div className="text-sm text-muted-foreground">{systemDetails.manufacturer}</div>

              </div>

            </div>

          </div>

        </div>

      </CardContent>

    </Card>
  );
};

export default SystemDetailsExample;