11import { toFixed } from 'common/math' ;
22import { capitalize } from 'common/string' ;
33import { useBackend , useLocalState } from '../backend' ;
4- import { Box , Button , Section , Flex , Tabs , Stack , BlockQuote , Table , Dropdown , ProgressBar , NumberInput } from '../components' ;
4+ import { Box , Button , Section , Flex , Tabs , Stack , BlockQuote , Table , Dropdown , ProgressBar , NumberInput , Icon } from '../components' ;
55import { Window } from '../layouts' ;
66
77type Module = {
@@ -42,13 +42,26 @@ type SecRecord = {
4242 p_state : string ;
4343 m_state : string ;
4444 criminal_status : string ;
45- crimes : string [ ] ;
45+ crimes : Crime [ ] ;
4646 important_notes : string ;
47- comments : string [ ] ;
47+ comments : Comment [ ] ;
48+ }
49+
50+ type Crime = {
51+ crime_name : string ;
52+ crime_details : string ;
53+ author : string ;
54+ time_added : string ;
55+ }
56+
57+ type Comment = {
58+ comment_text : string ;
59+ author : string ;
60+ time : string ;
4861}
4962
5063type Data = {
51- modules : Data [ ] ;
64+ modules : string [ ] ;
5265 modules_list : Module [ ] ;
5366 modules_tabs : Module [ ] ;
5467 laws_zeroth : string ;
@@ -70,11 +83,11 @@ type Data = {
7083 color : string ;
7184 med_records : MedRecord [ ] ;
7285 sec_records : SecRecord [ ] ;
73- selected_med_record : MedRecord [ ] ;
74- selected_sec_record : SecRecord [ ] ;
86+ selected_med_record : MedRecord ;
87+ selected_sec_record : SecRecord ;
7588}
7689
77- export const AirlockJackTextSwitch = params => {
90+ const AirlockJackTextSwitch = params => {
7891 switch ( params ) {
7992 case 0 :
8093 return "Connection handshake" ;
@@ -101,12 +114,54 @@ export const MedRecordColour = (mental, physical) => {
101114 }
102115} ;
103116
117+ export const SecRecordColour = criminal_status => {
118+ switch ( criminal_status ) {
119+ case "Arrest" :
120+ return "#990000;" ;
121+ case "Discharged" :
122+ return "#5C4949;" ;
123+ case "None" :
124+ return "#740349;" ;
125+ case "Search" :
126+ return "#5C4949;" ;
127+ case "Parole" :
128+ return "#046713;" ;
129+ case "Incarcerated" :
130+ return "#181818;" ;
131+ case "Suspected" :
132+ return "#CD6500;" ;
133+ }
134+ } ;
135+
136+ const SecRecordIcon = criminal_status => {
137+ switch ( criminal_status ) {
138+ case "Arrest" :
139+ return "fingerprint" ;
140+ case "Discharged" :
141+ return "dove" ;
142+ case "None" :
143+ return "" ;
144+ case "Search" :
145+ return "search" ;
146+ case "Parole" :
147+ return "unlink" ;
148+ case "Incarcerated" :
149+ return "dungeon" ;
150+ case "Suspected" :
151+ return "exclamation" ;
152+ }
153+ return "" ;
154+ } ;
155+
156+ let custom_width ;
157+ custom_width = 650 ;
158+
104159export const PaiInterface = ( props , context ) => {
105160 const { act, data } = useBackend < Data > ( context ) ;
106161 const { modules_tabs = [ ] } = data ;
107162 const [ selectedMainTab , setMainTab ] = useLocalState ( context , "selectedMainTab" , 0 ) ;
108163 return (
109- < Window width = { 650 } height = { 550 } > { /* Width matters for medical records, height matters for download more software */ }
164+ < Window width = { custom_width } height = { 550 } > { /* Width matters for records, height matters for download more software */ }
110165 < Window . Content >
111166 < Flex >
112167 < Flex . Item grow = { 1 } >
@@ -141,8 +196,17 @@ const PaiBox = (props, context) => {
141196 const { hacking, hackprogress, cable, door } = data ;
142197 const { code, frequency, minFrequency, maxFrequency, color } = data ;
143198 const { med_records, sec_records } = data ;
144- const [ record_view , set_record_view ] = useLocalState ( context , "record_view" , 0 ) ;
145- const { selected_med_record } = data ;
199+ const { selected_med_record, selected_sec_record } = data ;
200+ switch ( modules_tabs [ selectedMainTab ] . module_name ) { // To actually make records readable without extending every other module unnecessarily
201+ case "medical records" :
202+ custom_width = 960 ;
203+ break ;
204+ case "security records" :
205+ custom_width = 850 ;
206+ break ;
207+ default :
208+ custom_width = 650 ;
209+ }
146210 switch ( modules_tabs [ selectedMainTab ] . module_name ) {
147211 case "directives" :
148212 return (
@@ -437,6 +501,9 @@ const PaiBox = (props, context) => {
437501 < Table . Cell textAlign = { "center" } bold = { 1 } >
438502 ID:
439503 </ Table . Cell >
504+ < Table . Cell textAlign = { "center" } bold = { 1 } >
505+ Fingerprints (F) | DNA (D):
506+ </ Table . Cell >
440507 < Table . Cell textAlign = { "center" } bold = { 1 } >
441508 Blood type:
442509 </ Table . Cell >
@@ -460,6 +527,10 @@ const PaiBox = (props, context) => {
460527 < Table . Cell backgroundColor = { MedRecordColour ( MedRecord . m_state , MedRecord . p_state ) } >
461528 { MedRecord . id }
462529 </ Table . Cell >
530+ < Table . Cell backgroundColor = { MedRecordColour ( MedRecord . m_state , MedRecord . p_state ) } textAlign = { "center" } >
531+ < Box > F: { MedRecord . fingerprint } </ Box >
532+ < Box > D: { MedRecord . dna } </ Box >
533+ </ Table . Cell >
463534 < Table . Cell backgroundColor = { MedRecordColour ( MedRecord . m_state , MedRecord . p_state ) } textAlign = { "center" } >
464535 { MedRecord . blood_type }
465536 </ Table . Cell >
@@ -475,6 +546,166 @@ const PaiBox = (props, context) => {
475546 </ Section >
476547 ) ;
477548 }
549+ case "security records" :
550+ if ( selected_sec_record ) {
551+ const { crimes } = data . selected_sec_record ;
552+ const { comments } = data . selected_sec_record ;
553+ return (
554+ < Section title = { modules_tabs [ selectedMainTab ] . title } >
555+ < Button icon = "arrow-left"
556+ onClick = { ( ) => act ( "sec_record back" ) } >
557+ Back
558+ </ Button >
559+ < Stack vertical ml = { 2 } >
560+ < Stack . Item >
561+ Name: { selected_sec_record . name }
562+ </ Stack . Item >
563+ < Stack . Item >
564+ ID: { selected_sec_record . id }
565+ </ Stack . Item >
566+ < Stack . Item >
567+ Gender: { selected_sec_record . gender }
568+ </ Stack . Item >
569+ < Stack . Item >
570+ Age: { selected_sec_record . age }
571+ </ Stack . Item >
572+ < Stack . Item >
573+ Rank: { selected_sec_record . rank }
574+ </ Stack . Item >
575+ < Stack . Item >
576+ Fingerprint: { selected_sec_record . fingerprint }
577+ </ Stack . Item >
578+ < Stack . Item >
579+ Physical Status: { selected_sec_record . p_state }
580+ </ Stack . Item >
581+ < Stack . Item >
582+ Mental Status: { selected_sec_record . m_state }
583+ </ Stack . Item >
584+ < br />
585+ < Stack . Item >
586+ Criminal Status: < Button backgroundColor = { SecRecordColour ( selected_sec_record . criminal_status ) } > { selected_sec_record . criminal_status } </ Button >
587+ </ Stack . Item >
588+ < br />
589+ < Table >
590+ < Table . Row >
591+ < Table . Cell textAlign = { "center" } bold = { 1 } >
592+ Crime:
593+ </ Table . Cell >
594+ < Table . Cell textAlign = { "center" } bold = { 1 } >
595+ Details:
596+ </ Table . Cell >
597+ < Table . Cell textAlign = { "center" } bold = { 1 } >
598+ Author:
599+ </ Table . Cell >
600+ < Table . Cell textAlign = { "center" } bold = { 1 } >
601+ Time Added:
602+ </ Table . Cell >
603+ </ Table . Row >
604+ { crimes . map ( crime => (
605+ < Table . Row
606+ key = { crime } >
607+ < Table . Cell >
608+ { crime . crime_name }
609+ </ Table . Cell >
610+ < Table . Cell >
611+ { crime . crime_details }
612+ </ Table . Cell >
613+ < Table . Cell >
614+ { crime . author }
615+ </ Table . Cell >
616+ < Table . Cell >
617+ { crime . time_added }
618+ </ Table . Cell >
619+ </ Table . Row >
620+ ) ) }
621+ </ Table >
622+ < br />
623+ < Table >
624+ < Table . Row >
625+ < Table . Cell textAlign = { "center" } bold = { 1 } >
626+ Comment:
627+ </ Table . Cell >
628+ < Table . Cell textAlign = { "center" } bold = { 1 } >
629+ Author:
630+ </ Table . Cell >
631+ < Table . Cell textAlign = { "center" } bold = { 1 } >
632+ Time Added:
633+ </ Table . Cell >
634+ </ Table . Row >
635+ { comments . map ( comment => (
636+ < Table . Row
637+ key = { comment } >
638+ < Table . Cell >
639+ { comment . comment_text }
640+ </ Table . Cell >
641+ < Table . Cell >
642+ { comment . author }
643+ </ Table . Cell >
644+ < Table . Cell >
645+ { comment . time }
646+ </ Table . Cell >
647+ </ Table . Row >
648+ ) ) }
649+ </ Table >
650+ </ Stack >
651+ </ Section >
652+ ) ;
653+ } else {
654+ return (
655+ < Section title = { modules_tabs [ selectedMainTab ] . title } >
656+ < Table >
657+ < Table . Row >
658+ < Table . Cell textAlign = { "center" } bold = { 1 } >
659+ Name:
660+ </ Table . Cell >
661+ < Table . Cell textAlign = { "center" } bold = { 1 } >
662+ ID:
663+ </ Table . Cell >
664+ < Table . Cell textAlign = { "center" } bold = { 1 } >
665+ Rank:
666+ </ Table . Cell >
667+ < Table . Cell textAlign = { "center" } bold = { 1 } >
668+ Fingerprints:
669+ </ Table . Cell >
670+ < Table . Cell textAlign = { "center" } bold = { 1 } >
671+ Criminal Status:
672+ </ Table . Cell >
673+ </ Table . Row >
674+ { sec_records . map ( SecRecord => (
675+ < Table . Row
676+ key = { SecRecord }
677+ height = { 3 } >
678+ < Table . Cell backgroundColor = { SecRecordColour ( SecRecord . criminal_status ) } >
679+ < Button
680+ onClick = { ( ) => act ( "sec_record" , { record : SecRecord . id } ) } m = { 1 } >
681+ { SecRecord . name }
682+ </ Button >
683+ </ Table . Cell >
684+ < Table . Cell backgroundColor = { SecRecordColour ( SecRecord . criminal_status ) } >
685+ { SecRecord . id }
686+ </ Table . Cell >
687+ < Table . Cell backgroundColor = { SecRecordColour ( SecRecord . criminal_status ) } >
688+ { SecRecord . rank }
689+ </ Table . Cell >
690+ < Table . Cell backgroundColor = { SecRecordColour ( SecRecord . criminal_status ) } >
691+ { SecRecord . fingerprint }
692+ </ Table . Cell >
693+ < Table . Cell backgroundColor = { SecRecordColour ( SecRecord . criminal_status ) } >
694+ < Box textAlign = "center" bold >
695+ { SecRecord . criminal_status }
696+ </ Box >
697+ { SecRecordIcon ( SecRecord . criminal_status ) && (
698+ < Box textAlign = "center" bold >
699+ < Icon name = { SecRecordIcon ( SecRecord . criminal_status ) } />
700+ </ Box >
701+ ) }
702+ </ Table . Cell >
703+ </ Table . Row >
704+ ) ) }
705+ </ Table >
706+ </ Section >
707+ ) ;
708+ }
478709 case "host scan" :
479710 return (
480711 < Section title = { modules_tabs [ selectedMainTab ] . title } >
@@ -572,5 +803,5 @@ const PaiBox = (props, context) => {
572803 ) ;
573804 }
574805 }
575- return null ;
806+ return null ; // Necessary to avoid "PaiBox cannot be used as a JSX Element. It's Return type 'Element | Undefined' is not a valid JSX component" runtiming
576807 } ;
0 commit comments