Merge branch 'Donkie:master' into master

This commit is contained in:
Patricio Suarez
2023-07-30 05:54:18 -04:00
committed by GitHub
5 changed files with 255 additions and 9 deletions

93
client/icons/spool.svg Normal file
View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="235"
height="500"
viewBox="0 0 235 500"
xml:space="preserve"
id="svg5"
sodipodi:docname="spool.svg"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview5"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="true"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.6588725"
inkscape:cx="132.92161"
inkscape:cy="209.47963"
inkscape:window-width="1350"
inkscape:window-height="1237"
inkscape:window-x="1189"
inkscape:window-y="48"
inkscape:window-maximized="0"
inkscape:current-layer="svg5" />&#10;<desc
id="desc1">Created with Fabric.js 5.3.0</desc>&#10;<defs
id="defs1">&#10;</defs>&#10;&#10;&#10;&#10;&#10;<path
style="stroke:rgb(110, 11, 48);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(52, 52, 52);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(0.58757483,0,0,3.9476902,197.13549,250.04675)"
d="M 0 -63.26949 C 34.92476 -63.26949 63.26949 -34.92476 63.26949 0 C 63.26949 34.92476 34.92476 63.26949 0 63.26949 C -34.92476 63.26949 -63.26949 34.92476 -63.26949 0 C -63.26949 -34.92476 -34.92476 -63.26949 0 -63.26949 z"
stroke-linecap="round"
id="path1"
inkscape:label="rightside" /><path
style="stroke:rgb(110, 11, 48);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(255, 0, 0);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(0.38157612,0,0,3.4623174,197.13549,250.04674)"
d="M 0 -63.26949 C 34.92476 -63.26949 63.26949 -34.92476 63.26949 0 C 63.26949 34.92476 34.92476 63.26949 0 63.26949 C -34.92476 63.26949 -63.26949 34.92476 -63.26949 0 C -63.26949 -34.92476 -34.92476 -63.26949 0 -63.26949 z"
stroke-linecap="round"
id="path2"
inkscape:label="filament_right" /><path
style="stroke:rgb(0, 0, 0);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(255, 0, 0);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(2.073642,0,0,3.3577086,117.29471,250.04674)"
d="M -38.50267 -65.24064 L 38.502680000000005 -65.24064 L 38.502680000000005 65.24064 L -38.50267 65.24064 z"
stroke-linecap="round"
id="path3"
inkscape:label="filament_main" /><g
transform="matrix(0.58757483,0,0,3.9476902,37.453957,250.04674)"
id="OvgM38-6CZm9R47a1TDIX"
inkscape:label="fg">&#10;<filter
id="SVGID_1"
y="-0.056899467"
height="1.1137989"
x="-0.056899467"
width="1.271853">&#10; <feGaussianBlur
in="SourceAlpha"
stdDeviation="3"
id="feGaussianBlur3" />&#10; <feOffset
dx="20"
dy="0"
result="oBlur"
id="feOffset3" />&#10; <feFlood
flood-color="rgb(0,0,0)"
flood-opacity="0.67"
id="feFlood3" />&#10; <feComposite
in2="oBlur"
operator="in"
id="feComposite3" />&#10; <feMerge
id="feMerge4">&#10; <feMergeNode
id="feMergeNode3" />&#10; <feMergeNode
in="SourceGraphic"
id="feMergeNode4" />&#10; </feMerge>&#10;</filter>&#10;&#10;<path
style="stroke:rgb(110, 11, 48);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(52, 52, 52);fill-rule:nonzero;opacity:1;filter:url(#SVGID_1)"
vector-effect="non-scaling-stroke"
transform="translate(8.4959392e-7)"
d="M 0 -63.26949 C 34.92476 -63.26949 63.26949 -34.92476 63.26949 0 C 63.26949 34.92476 34.92476 63.26949 0 63.26949 C -34.92476 63.26949 -63.26949 34.92476 -63.26949 0 C -63.26949 -34.92476 -34.92476 -63.26949 0 -63.26949 z"
stroke-linecap="round"
id="path4"
inkscape:label="leftside" /><path
style="stroke:rgb(110, 11, 48);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(17, 17, 17);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="scale(0.41451706)"
d="M 0 -63.26949 C 34.92476 -63.26949 63.26949 -34.92476 63.26949 0 C 63.26949 34.92476 34.92476 63.26949 0 63.26949 C -34.92476 63.26949 -63.26949 34.92476 -63.26949 0 C -63.26949 -34.92476 -34.92476 -63.26949 0 -63.26949 z"
stroke-linecap="round"
id="path5"
inkscape:label="hole" /></g>&#10;</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

89
client/icons/spoolman.svg Normal file
View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="220"
height="220"
viewBox="0 0 220 220"
xml:space="preserve"
id="svg8"
sodipodi:docname="spoolman.svg"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview8"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="true"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="5.3318182"
inkscape:cx="110"
inkscape:cy="106.53026"
inkscape:window-width="1898"
inkscape:window-height="1360"
inkscape:window-x="868"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg8" />&#10;<desc
id="desc1">Created with Fabric.js 5.3.0</desc>&#10;<defs
id="defs1">&#10;</defs>&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;<path
style="stroke:rgb(0, 0, 0);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(220, 119, 52);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(0.941963,0,0,0.941963,110,110)"
d="M -116.77741 -67.23295 C -116.77741 -94.5956 -94.5956 -116.77741 -67.23295 -116.77741 L 67.23295 -116.77741 L 67.23295 -116.77741 C 94.5956 -116.77741 116.77741 -94.5956 116.77741 -67.23295 L 116.77741 67.23295 L 116.77741 67.23295 C 116.77741 94.5956 94.5956 116.77741 67.23295 116.77741 L -67.23295 116.77741 L -67.23295 116.77741 C -94.5956 116.77741 -116.77741 94.5956 -116.77741 67.23295 z"
stroke-linecap="round"
id="path1"
inkscape:label="iconbg" /><path
style="stroke:rgb(89, 142, 199);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(52, 52, 52);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(4.0068,0,0,4.0068,110,110)"
d="M 0 -22.46181 C 12.39892 -22.46181 22.46181 -12.39892 22.46181 0 C 22.46181 12.39892 12.39892 22.46181 0 22.46181 C -12.39892 22.46181 -22.46181 12.39892 -22.46181 0 C -22.46181 -12.39892 -12.39892 -22.46181 0 -22.46181 z"
stroke-linecap="round"
id="path2"
inkscape:label="spoolface" /><path
style="stroke:rgb(255, 255, 255);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(17, 17, 17);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(-0.65629473,0.65629473,-0.65629473,-0.65629473,169.99999,109.99999)"
d="M -33.16071 25.30347 C -35.26675 24.713710000000003 -37.021860000000004 23.25476 -37.98653 21.29195 C -38.95121 19.32914 -39.0341 17.04834 -38.21447 15.020669999999999 L -38.21447 15.020669999999999 L -38.21447 15.020669999999999 C -28.42178 -9.205020000000001 -9.211359999999999 -28.41564 15.014230000000005 -38.20859 L 15.047580000000005 -38.22207 L 15.047580000000005 -38.22207 C 17.067020000000007 -39.03841 19.338600000000007 -38.95586 21.293460000000003 -37.995110000000004 C 23.248330000000003 -37.03435 24.701380000000004 -35.286350000000006 25.288750000000004 -33.188840000000006 L 37.998650000000005 12.198379999999993 L 37.998650000000005 12.198379999999993 C 40.03828000000001 19.481909999999992 37.990640000000006 27.299259999999993 32.64228000000001 32.64761999999999 C 27.293920000000007 37.99597999999999 19.476570000000006 40.04361999999999 12.193040000000007 38.00398999999999 z"
stroke-linecap="round"
id="path3"
inkscape:label="bean3_bg" /><path
style="stroke:rgb(255, 255, 255);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(190, 190, 190);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(-0.65629473,0.65629473,-0.65629473,-0.65629473,158.49213,110.08398)"
d="M -29.98183 19.80196 L -29.17187 17.09468 L -29.17187 17.09468 C -22.390079999999998 -5.573499999999999 -4.466099999999997 -23.18579 18.31756 -29.568920000000002 L 19.88717 -30.008660000000003 L 29.21402 3.473359999999996 L 29.21402 3.473359999999996 C 31.243070000000003 10.757369999999996 29.183770000000003 18.569419999999994 23.82768 23.906659999999995 C 18.47159 29.243899999999996 10.652330000000001 31.275649999999995 3.375510000000002 29.220929999999996 z"
stroke-linecap="round"
id="path4"
inkscape:label="bean3_fg" /><path
style="stroke:rgb(255, 255, 255);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(17, 17, 17);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(-0.24022054,-0.89651527,0.89651527,-0.24022054,81.095899,162.73972)"
d="M -33.16071 25.30347 C -35.26675 24.713710000000003 -37.021860000000004 23.25476 -37.98653 21.29195 C -38.95121 19.32914 -39.0341 17.04834 -38.21447 15.020669999999999 L -38.21447 15.020669999999999 L -38.21447 15.020669999999999 C -28.42178 -9.205020000000001 -9.211359999999999 -28.41564 15.014230000000005 -38.20859 L 15.047580000000005 -38.22207 L 15.047580000000005 -38.22207 C 17.067020000000007 -39.03841 19.338600000000007 -38.95586 21.293460000000003 -37.995110000000004 C 23.248330000000003 -37.03435 24.701380000000004 -35.286350000000006 25.288750000000004 -33.188840000000006 L 37.998650000000005 12.198379999999993 L 37.998650000000005 12.198379999999993 C 40.03828000000001 19.481909999999992 37.990640000000006 27.299259999999993 32.64228000000001 32.64761999999999 C 27.293920000000007 37.99597999999999 19.476570000000006 40.04361999999999 12.193040000000007 38.00398999999999 z"
stroke-linecap="round"
id="path5"
inkscape:label="bean2_bg" /><path
style="stroke:rgb(255, 255, 255);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(190, 190, 190);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(-0.24022054,-0.89651527,0.89651527,-0.24022054,86.7771,152.73163)"
d="M -29.98183 19.80196 L -29.17187 17.09468 L -29.17187 17.09468 C -22.390079999999998 -5.573499999999999 -4.466099999999997 -23.18579 18.31756 -29.568920000000002 L 19.88717 -30.008660000000003 L 29.21402 3.473359999999996 L 29.21402 3.473359999999996 C 31.243070000000003 10.757369999999996 29.183770000000003 18.569419999999994 23.82768 23.906659999999995 C 18.47159 29.243899999999996 10.652330000000001 31.275649999999995 3.375510000000002 29.220929999999996 z"
stroke-linecap="round"
id="path6"
inkscape:label="bean2_fg" /><path
style="stroke:rgb(255, 255, 255);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(17, 17, 17);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(0.89651527,0.24022054,-0.24022054,0.89651527,80.684929,58.484107)"
d="M -33.16071 25.30347 C -35.26675 24.713710000000003 -37.021860000000004 23.25476 -37.98653 21.29195 C -38.95121 19.32914 -39.0341 17.04834 -38.21447 15.020669999999999 L -38.21447 15.020669999999999 L -38.21447 15.020669999999999 C -28.42178 -9.205020000000001 -9.211359999999999 -28.41564 15.014230000000005 -38.20859 L 15.047580000000005 -38.22207 L 15.047580000000005 -38.22207 C 17.067020000000007 -39.03841 19.338600000000007 -38.95586 21.293460000000003 -37.995110000000004 C 23.248330000000003 -37.03435 24.701380000000004 -35.286350000000006 25.288750000000004 -33.188840000000006 L 37.998650000000005 12.198379999999993 L 37.998650000000005 12.198379999999993 C 40.03828000000001 19.481909999999992 37.990640000000006 27.299259999999993 32.64228000000001 32.64761999999999 C 27.293920000000007 37.99597999999999 19.476570000000006 40.04361999999999 12.193040000000007 38.00398999999999 z"
stroke-linecap="round"
id="path7"
inkscape:label="bean1_bg" /><path
style="stroke:rgb(255, 255, 255);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:rgb(190, 190, 190);fill-rule:nonzero;opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(0.89651527,0.24022054,-0.24022054,0.89651527,86.511593,68.408219)"
d="M -29.98183 19.80196 L -29.17187 17.09468 L -29.17187 17.09468 C -22.390079999999998 -5.573499999999999 -4.466099999999997 -23.18579 18.31756 -29.568920000000002 L 19.88717 -30.008660000000003 L 29.21402 3.473359999999996 L 29.21402 3.473359999999996 C 31.243070000000003 10.757369999999996 29.183770000000003 18.569419999999994 23.82768 23.906659999999995 C 18.47159 29.243899999999996 10.652330000000001 31.275649999999995 3.375510000000002 29.220929999999996 z"
stroke-linecap="round"
id="path8"
inkscape:label="bean1_fg" />&#10;</svg>

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="220"
height="220"
viewBox="0 0 220 220"
xml:space="preserve"
id="svg8"
sodipodi:docname="spoolman_monochrome.svg"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview8"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="true"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="2.6659091"
inkscape:cx="73.333333"
inkscape:cy="97.1526"
inkscape:window-width="1898"
inkscape:window-height="1360"
inkscape:window-x="684"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg8" />&#10;<desc
id="desc1">Created with Fabric.js 5.3.0</desc>&#10;<defs
id="defs1"><inkscape:path-effect
effect="powerclip"
id="path-effect13"
is_visible="true"
lpeversion="1"
inverse="true"
flatten="false"
hide_clip="false"
message="Use fill-rule evenodd on &lt;b&gt;fill and stroke&lt;/b&gt; dialog if no flatten result after convert clip to paths." />&#10;<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath13"><path
id="path13"
style="display:none;opacity:1;fill:#bebebe;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
inkscape:label="bean1_fg"
d="m -13.757715,-7.7471481 0.343537,-0.55719 v 0 c 2.876446,-4.6653799 7.9428216,-7.5315019 13.42331996,-7.5937639 l 0.37756065,-0.0043 0.0795148,8.0507248 v 0 c 0.0172956,1.7514341 -0.91182739,3.3759065 -2.43022861,4.2489907 -1.5184012,0.8730843 -3.3897584,0.8588954 -4.8947484,-0.037114 z M 0.4322926,16.185974 -0.22201757,16.167056 v 0 C -5.7005765,16.00867 -10.715899,13.054123 -13.510068,8.3390037 l -0.192495,-0.3248328 6.9323756,-4.0942248 v 0 c 1.5081376,-0.8906958 3.3795333,-0.8982879 4.894848,-0.019866 1.51531394,0.8784316 2.43870418,2.5061695 2.41523158,4.2575347 z m 13.3375784,-24.319362 0.310774,0.5761074 v 0 c 2.602114,4.8237643 2.551061,10.6444349 -0.135267,15.4218159 L 13.76031,8.1936583 6.7484202,4.2371568 v 0 C 5.2229859,3.3764201 4.2807128,1.7595388 4.2838,0.00802386 4.2868948,-1.7434936 5.2348557,-3.3570423 6.7633174,-4.2123972 Z" /><path
id="lpe_path-effect13"
style="opacity:1;fill:#bebebe;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
class="powerclip"
d="m -27.46181,-27.46181 h 54.92362 v 54.92362 h -54.92362 z m 13.704095,19.7146619 6.8989554,4.1073476 c 1.50499,0.8960094 3.3763472,0.9101983 4.8947484,0.037114 1.51840122,-0.8730842 2.44752421,-2.4975566 2.43022861,-4.2489907 v 0 l -0.0795148,-8.0507248 -0.37756065,0.0043 c -5.48049836,0.06226 -10.54687396,2.928384 -13.42331996,7.5937639 v 0 z M 0.4322926,16.185974 0.53989218,8.1576148 C 0.56336478,6.4062496 -0.36002546,4.7785117 -1.8753394,3.9000801 -3.3906541,3.0216582 -5.2620498,3.0292503 -6.7701874,3.9199461 v 0 l -6.9323756,4.0942248 0.192495,0.3248328 c 2.794169,4.7151193 7.8094915,7.6696663 13.28805043,7.8280523 v 0 z M 13.769871,-8.133388 6.7633174,-4.2123972 C 5.2348557,-3.3570423 4.2868948,-1.7434936 4.2838,0.00802386 4.2807128,1.7595388 5.2229859,3.3764201 6.7484202,4.2371568 v 0 l 7.0118898,3.9565015 0.185068,-0.329123 c 2.686328,-4.777381 2.737381,-10.5980516 0.135267,-15.4218159 v 0 z" /></clipPath></defs>&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;<path
style="stroke:rgb(89, 142, 199);stroke-width:0;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#000000;fill-rule:nonzero;opacity:1;fill-opacity:1"
vector-effect="non-scaling-stroke"
transform="matrix(4.0068,0,0,4.0068,110,110)"
d="M 0,-22.46181 C 12.39892,-22.46181 22.46181,-12.39892 22.46181,0 22.46181,12.39892 12.39892,22.46181 0,22.46181 -12.39892,22.46181 -22.46181,12.39892 -22.46181,0 -22.46181,-12.39892 -12.39892,-22.46181 0,-22.46181 Z"
stroke-linecap="round"
id="path2"
inkscape:label="spoolface"
clip-path="url(#clipPath13)"
inkscape:path-effect="#path-effect13"
inkscape:original-d="M 0 -22.46181 C 12.39892 -22.46181 22.46181 -12.39892 22.46181 0 C 22.46181 12.39892 12.39892 22.46181 0 22.46181 C -12.39892 22.46181 -22.46181 12.39892 -22.46181 0 C -22.46181 -12.39892 -12.39892 -22.46181 0 -22.46181 z" />&#10;</svg>

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -20,7 +20,7 @@ import { ISpool } from "./model";
import {
TableState,
useInitialTableState,
useShowArchive,
useSavedState,
useStoreInitialState,
} from "../../utils/saveload";
import {
@@ -55,7 +55,10 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
const initialState = useInitialTableState("spoolList");
// State for the switch to show archived spools
const [showArchived, setShowArchived] = useShowArchive("spoolList");
const [showArchived, setShowArchived] = useSavedState(
"spoolList-showArchived",
false
);
// Fetch data from the API
const {

View File

@@ -60,17 +60,17 @@ export function useStoreInitialState(tableId: string, state: TableState) {
}, [tableId, state.showColumns]);
}
export function useShowArchive(tableId: string) {
const [showArchive, setShowArchive] = React.useState(() => {
const savedShowArchive = isLocalStorageAvailable ? localStorage.getItem(`${tableId}-showArchive`) : null;
return savedShowArchive ? JSON.parse(savedShowArchive) : false;
export function useSavedState<T>(id: string, defaultValue: T) {
const [state, setState] = React.useState<T>(() => {
const savedState = isLocalStorageAvailable ? localStorage.getItem(`savedStates-${id}`) : null;
return savedState ? JSON.parse(savedState) : defaultValue;
});
React.useEffect(() => {
if (isLocalStorageAvailable) {
localStorage.setItem(`${tableId}-showArchive`, JSON.stringify(showArchive));
localStorage.setItem(`savedStates-${id}`, JSON.stringify(state));
}
}, [tableId, showArchive]);
}, [id, state]);
return [showArchive, setShowArchive] as const;
return [state, setState] as const;
}