Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | 2x 33x 2x 11x 11x 11x 11x 11x 11x 11x 4x 11x 6x 2x 11x 1x 11x 11x 11x 11x 9x 11x 11x 11x 4x 4x 4x 4x 4x 11x | import { useEffect, useMemo, useState } from "react"; import { Navigate, useParams } from "react-router"; import { isCmsUser } from "shared-utils"; import { useGetUser } from "@/api/useGetUser"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ExpandCollapseBtn, LeftNavigation, Search, StatusLabel, SupportSubNavHeader, ToggleGroup, ToggleGroupItem, } from "@/components"; import { useFeatureFlag } from "@/hooks/useFeatureFlag"; import { cn } from "@/utils"; import { oneMACCMSContent, oneMACStateFAQContent, QuestionAnswer } from "./SupportMockContent"; const FaqAccordion = ({ question, latestOpened, }: { question: QuestionAnswer[]; latestOpened: string; }) => { return ( <> {question.map(({ anchorText, answerJSX, question, statusLabel }) => { const oulineLatest = latestOpened === anchorText ? "border-blue-500 border-2 " : ""; return ( <AccordionItem value={anchorText} id={`${anchorText}-support`} data-testid={`${anchorText}-support`} key={anchorText} className="my-6 border-none" > <AccordionTrigger showPlusMinus className={cn( "text-left font-bold bg-neutral-100 px-5 hover:no-underline", oulineLatest, )} > <div className="flex"> {statusLabel && <StatusLabel type={statusLabel} />}{" "} <span className="hover:underline">{question}</span> </div> </AccordionTrigger> <AccordionContent className="bg-white pt-4">{answerJSX}</AccordionContent> </AccordionItem> ); })} </> ); }; export const SupportPage = () => { const { id } = useParams<{ id: string }>(); const isSupportPageShown = useFeatureFlag("TOGGLE_FAQ"); const [openAccordions, setOpenAccordions] = useState<string[]>([]); const { data: userObj } = useGetUser(); const isCmsView = isCmsUser(userObj.user); const [tgValue, setTGValue] = useState<"cms" | "state">(isCmsView ? "cms" : "state"); const supportContent = useMemo(() => { Eif (tgValue === "cms") return oneMACCMSContent; return oneMACStateFAQContent; }, [tgValue]); const expandAll = () => { const allIds = supportContent.flatMap(({ qanda }) => qanda.map(({ anchorText }) => anchorText)); setOpenAccordions(allIds); }; const collapseAll = () => { setOpenAccordions([]); }; const areAllAccordionsOpen = (function () { const totalQandas = supportContent.reduce((total, section) => { return total + section.qanda.length; }, 0); if (openAccordions.length >= totalQandas) return true; return false; })(); const latestOpenedFAQ = areAllAccordionsOpen ? "" : openAccordions[openAccordions.length - 1]; const onSearch = (s: string) => { // search logic will be added here console.log("searching... ", s); }; useEffect(() => { Eif (id) { const element = document.getElementById(id); Eif (element) { setOpenAccordions([id]); window.scrollTo({ top: element.offsetTop, behavior: "smooth", }); } } }, [id]); if (!isSupportPageShown || !userObj?.user) return <Navigate to="/" replace />; return ( <div className="min-h-screen flex flex-col"> <SupportSubNavHeader> <h1 className="text-4xl font-semibold">OneMAC Support</h1> <Search placeholderText="Search OneMAC support" handleSearch={onSearch} /> </SupportSubNavHeader> {/* only display the toggle CMS/State view when the user is CMS */} {isCmsView && ( <div className="max-w-screen-xl m-auto px-4 lg:px-8 w-full pt-8"> <div className="flex justify-end"> <div className="w-2/3 px-4 lg:px-8"> <ToggleGroup type="single" aria-label="CMS State Toggle" data-testid="cms-toggle-group" value={tgValue} onValueChange={(value: "cms" | "state") => { if (value) setTGValue(value); }} > <ToggleGroupItem value="cms" aria-label="cms"> CMS </ToggleGroupItem> <ToggleGroupItem value="state" aria-label="state"> States </ToggleGroupItem> </ToggleGroup> </div> </div> <hr className="bg-slate-100 h-[1.2px]" /> </div> )} {/* Main Layout Wrapper with explicit widths */} <div className="max-w-screen-xl m-auto px-4 lg:px-8 pt-4 w-full"> <div className="flex"> {/* Left Navigation - Fixed width with explicit max-width */} <div className="w-1/3 sticky top-20 h-[calc(100vh-5rem)] sm:-z-10"> <LeftNavigation topics={supportContent.flatMap(({ sectionTitle }) => sectionTitle)} /> </div> {/* Content - Force minimum width */} <section className="w-2/3 block max-w-screen-xl m-auto px-4 lg:px-8 gap-10"> <div className=""> <div className="flex justify-end py-4"> <ExpandCollapseBtn collapseAll={collapseAll} expandAll={expandAll} areAllOpen={areAllAccordionsOpen} /> </div> <hr className="bg-gray-300 h-[1.2px]" /> </div> <div className="flex-1 mt-8"> <Accordion type="multiple" value={openAccordions} onValueChange={setOpenAccordions}> {supportContent.map(({ sectionTitle, qanda }) => ( <article key={sectionTitle} className="mb-8"> <h2 className="text-2xl font-bold mb-4">{sectionTitle}</h2> <hr className="bg-gray-300 h-[1.7px]" /> <FaqAccordion question={qanda} latestOpened={latestOpenedFAQ} /> </article> ))} </Accordion> </div> </section> </div> </div> </div> ); }; |