--import Debug.Trace
main :: IO ()
main = ready $ do
  Actions.doExports
  _ <- initOverlay
  renderSpinner
  ajaxRequest POST "api/plan/getData" noParams buildQuestionnaire
    where
    buildQuestionnaire :: Maybe String -> IO ()
    buildQuestionnaire maybeDataString = do
      let maybeFormData = readMaybe (fromMaybe "" maybeDataString) :: Maybe FormData
      --let tabMaybes = map (Element.makeChapter $ traceShow maybeFormData maybeFormData) Questionnaire.formItems
      let tabMaybes = map (Element.makeChapter maybeFormData) Questionnaire.formItems
      if any isNothing tabMaybes then do
        errorIO "Error generating tabs"
        return ()
      else do
        let tabs = catMaybes tabMaybes
        --generateForm (traceShow tabs tabs)
        generateForm tabs
main :: IO ()
main = ready $ do
  Actions.doExports
  _ <- initOverlay
  renderSpinner
  ajaxRequest POST "api/plan/getData" noParams buildQuestionnaire
    where
    buildQuestionnaire :: Maybe String -> IO ()
    buildQuestionnaire maybeDataString = do
      let maybeFormData = readMaybe (fromMaybe "" maybeDataString) :: Maybe FormData
      --let tabMaybes = map (Element.makeChapter $ traceShow maybeFormData maybeFormData) Questionnaire.formItems
      let tabMaybes = map (Element.makeChapter maybeFormData) Questionnaire.formItems
      if any isNothing tabMaybes then do
        errorIO "Error generating tabs"
        return ()
      else do
        let tabs = catMaybes tabMaybes
        --generateForm (traceShow tabs tabs)
        generateForm tabs
main = ready $ do
  Actions.doExports
  _ <- initOverlay
  renderSpinner
  ajaxRequest POST "api/plan/getData" noParams buildQuestionnaire
    where
    buildQuestionnaire :: Maybe String -> IO ()
    buildQuestionnaire maybeDataString = do
      let maybeFormData = readMaybe (fromMaybe "" maybeDataString) :: Maybe FormData
      --let tabMaybes = map (Element.makeChapter $ traceShow maybeFormData maybeFormData) Questionnaire.formItems
      let tabMaybes = map (Element.makeChapter maybeFormData) Questionnaire.formItems
      if any isNothing tabMaybes then do
        errorIO "Error generating tabs"
        return ()
      else do
        let tabs = catMaybes tabMaybes
        --generateForm (traceShow tabs tabs)
        generateForm tabs