thunder_perfect

blank layout

Feb 14th, 2026 (edited)
3,508
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. import { Typography, Skeleton } from "antd";
  2. import { useMemo } from "react";
  3. import { SiteCodeStatus } from "../../types/SiteCodeStatus";
  4.  
  5. const { Title, Text } = Typography;
  6.  
  7. /* -----------------------------
  8. Domain Model
  9. ------------------------------*/
  10. export interface SiteCode {
  11. Id: number;
  12. Code: string; // e.g. FSA01928
  13. Name: string; // Orlando Field Office
  14. AgencyName: string; // CUSTOMS AND BORDER PROTECTION
  15. Status: SiteCodeStatus;
  16. }
  17.  
  18. /* -----------------------------
  19. Props
  20. ------------------------------*/
  21. interface SiteHeaderProps {
  22. SiteCode?: SiteCode;
  23. loading?: boolean;
  24. }
  25.  
  26. /* -----------------------------
  27. Badge Text (City Code)
  28. ------------------------------*/
  29. function getCityCode(code?: string): string {
  30. if (!code) return "";
  31.  
  32. const match = code.match(/[A-Z]{3}/);
  33. return match ? match[0] : code.slice(0, 3).toUpperCase();
  34. }
  35.  
  36. /* -----------------------------
  37. Status → Color Mapping
  38. (Replace with your exact palette)
  39. ------------------------------*/
  40. function getStatusColor(status: SiteCodeStatus): string {
  41. switch (status) {
  42. case SiteCodeStatus.PendingActive:
  43. return "#69c0ff"; // light blue (placeholder)
  44. case SiteCodeStatus.Active:
  45. return "#2f6f3e"; // green (placeholder)
  46. case SiteCodeStatus.PendingInactive:
  47. return "#d9d9d9"; // light gray (placeholder)
  48. case SiteCodeStatus.Inactive:
  49. return "#8c8c8c"; // gray (placeholder)
  50. default:
  51. return "#8c8c8c";
  52. }
  53. }
  54.  
  55. /* -----------------------------
  56. Component
  57. ------------------------------*/
  58. export default function SiteHeader({
  59. SiteCode,
  60. loading
  61. }: SiteHeaderProps) {
  62.  
  63. if (loading || !SiteCode) {
  64. return (
  65. <div
  66. style={{
  67. display: "flex",
  68. alignItems: "center",
  69. gap: 20,
  70. marginBottom: 24
  71. }}
  72. >
  73. <Skeleton.Input active style={{ width: 80, height: 72 }} />
  74. <div>
  75. <Skeleton.Input active style={{ width: 220 }} />
  76. <br />
  77. <Skeleton.Input active style={{ width: 260, marginTop: 8 }} />
  78. <br />
  79. <Skeleton.Input active style={{ width: 180, marginTop: 8 }} />
  80. </div>
  81. </div>
  82. );
  83. }
  84.  
  85. const badgeText = useMemo(
  86. () => getCityCode(SiteCode.Code),
  87. [SiteCode.Code]
  88. );
  89.  
  90. const badgeColor = getStatusColor(SiteCode.Status);
  91.  
  92. return (
  93. <div
  94. style={{
  95. display: "flex",
  96. alignItems: "center",
  97. gap: 20,
  98. marginBottom: 24
  99. }}
  100. >
  101. {/* Square Badge */}
  102. <div
  103. style={{
  104. width: 72,
  105. height: 72,
  106. borderRadius: 12,
  107. backgroundColor: badgeColor,
  108. color: "white",
  109. display: "flex",
  110. alignItems: "center",
  111. justifyContent: "center",
  112. fontSize: 22,
  113. fontWeight: 600,
  114. letterSpacing: 1,
  115. transition: "background-color 200ms ease"
  116. }}
  117. >
  118. {badgeText}
  119. </div>
  120.  
  121. {/* Text Block (3 Lines) */}
  122. <div style={{ display: "flex", flexDirection: "column" }}>
  123. {/* Line 1: Full Site Code */}
  124. <Title
  125. level={4}
  126. style={{
  127. margin: 0,
  128. lineHeight: 1.2
  129. }}
  130. >
  131. {SiteCode.Code}
  132. </Title>
  133.  
  134. {/* Line 2: Site Name */}
  135. <Text
  136. style={{
  137. fontSize: 15,
  138. marginTop: 4
  139. }}
  140. >
  141. {SiteCode.Name}
  142. </Text>
  143.  
  144. {/* Line 3: Agency */}
  145. <Text
  146. type="secondary"
  147. style={{
  148. fontSize: 13,
  149. marginTop: 4,
  150. letterSpacing: 0.5
  151. }}
  152. >
  153. {SiteCode.AgencyName}
  154. </Text>
  155. </div>
  156. </div>
  157. );
  158. }
Advertisement