@@ -11,10 +11,13 @@ import logo2024 from "../assets/intel_logo/2024.jpg";
1111import amdLogo from "../assets/AMD_epyc_logo.svg" ;
1212import close from "../assets/close.png" ;
1313import ValueSelection from "../utility/ValueSelection.tsx" ;
14+ import ServerPresetsComponent from "./ServerPresets.tsx" ;
15+ import { ServerPresets } from "../assets/data.ts" ;
1416
1517export const RAM_CAPACITIES :number [ ] = [ 128 , 512 ] ;
1618export const SSD_CAPACITIES :number [ ] = [ 512 , 2048 ] ;
1719export const HDD_CAPACITIES :number [ ] = [ 0 , 4096 ] ;
20+ export const CUSTOM = 'Custom' as const ;
1821
1922const YEAR_LOGOS : Record < number , string > = {
2023 2013 : logo2013 ,
@@ -84,6 +87,7 @@ const Dropdown: React.FC<DropdownProps> = ({ label, thisServer, otherServer, sho
8487 const canToggle = label == NEW_LABEL ;
8588
8689 const [ showDropdown , setShowDropdown ] = useState < boolean > ( canToggle ? false : true ) ;
90+ const [ presetValue , setPresetValue ] = useState < keyof ServerPresets | typeof CUSTOM > ( CUSTOM )
8791
8892 // This is when new hardware is hidden, we set it equal to current hardware
8993 if ( canToggle && ! showDropdown ) {
@@ -98,10 +102,12 @@ const Dropdown: React.FC<DropdownProps> = ({ label, thisServer, otherServer, sho
98102 setShowDropdown ( ! showDropdown ) ;
99103 }
100104
101- const updateComponent = ( updates : Partial < ServerType > ) => {
105+ const updateComponent = ( updates : Partial < ServerType > , preset : false | string = false ) => {
102106 // Always update the current server
103107 updateServer ( thisServer , updates ) ;
108+ setPresetValue ( preset ? preset : CUSTOM ) ;
104109
110+ // TODO: fix bug here when changing presets after scaling option
105111 if ( advancedOptions === 'Mirror' ) {
106112 const { cpu, ...updatesWithoutCPU } = updates ;
107113 updateServer ( otherServer , updatesWithoutCPU ) ;
@@ -147,10 +153,10 @@ const Dropdown: React.FC<DropdownProps> = ({ label, thisServer, otherServer, sho
147153 } , [ advancedOptions ] )
148154
149155 return (
150- < div className = "col-span-1 z-10 flex flex-col gap-2 font-light relative" >
156+ < div className = "col-span-1 flex flex-col gap-2 font-light relative" >
151157 < div
152158 onClick = { toggleShow }
153- className = { `${ showDropdown ? 'opacity-0 pointer-events-none' : 'opacity-100 pointer-events-auto' } z-10 cursor-pointer duration-150 absolute top-0 left-0 w-full h-full bg-white border-2 border-slate-400 rounded-xl flex items-center justify-center group hover:border-slate-300` } >
159+ className = { `${ showDropdown ? 'opacity-0 pointer-events-none' : 'opacity-100 pointer-events-auto' } z-20 cursor-pointer duration-150 absolute top-0 left-0 w-full h-full bg-white border-2 border-slate-400 rounded-xl flex items-center justify-center group hover:border-slate-300` } >
154160 < p className = "text-6xl text-slate-500 group-hover:text-slate-400 duration-150" > +</ p >
155161 </ div >
156162 < div className = "flex justify-between" >
@@ -165,6 +171,7 @@ const Dropdown: React.FC<DropdownProps> = ({ label, thisServer, otherServer, sho
165171 className = "h-5" />
166172 </ button >
167173 </ div >
174+ < ServerPresetsComponent presetValue = { presetValue } updateServer = { updateComponent } />
168175 < div className = { `${ showDropdown ? 'opacity-100' : 'opacity-0 pointer-events-none' } relative duration-150` } >
169176 < select
170177 className = "block appearance-none text-base w-full bg-gray-100 border-2 border-gray-400 py-1 px-2 pr-8 rounded focus:outline-none focus:bg-white focus:border-gray-500"
0 commit comments