From dfa0f6ad58168600de0b07ed4747b94e92fa9bb0 Mon Sep 17 00:00:00 2001 From: Liam Goldfinch Date: Wed, 21 Aug 2024 21:37:25 +0100 Subject: [PATCH] feat: add confirmation message to question submit form --- .../Components/Form/QAndAQuestionController.cs | 17 ++++++++++------- .../Form/QAndAQuestionFormConfirmation.cshtml | 5 +++++ 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionFormConfirmation.cshtml diff --git a/src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionController.cs b/src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionController.cs index 3e4fc158..9c0ec27c 100644 --- a/src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionController.cs +++ b/src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionController.cs @@ -52,20 +52,23 @@ public async Task CreateQuestion(QAndAQuestionFormSubmissionViewM var questionsParent = await mediator.Send(new QAndAQuestionsRootPageQuery(channelContext.WebsiteChannelName)); var questionMonthFolder = await mediator.Send(new QAndAMonthFolderQuery(questionsParent, channelContext.WebsiteChannelName, now.Year, now.Month, channelContext.WebsiteChannelID)); - return await mediator.Send(new QAndAQuestionCreateCommand( + var result = await mediator.Send(new QAndAQuestionCreateCommand( member, questionMonthFolder, channelContext.WebsiteChannelID, requestModel.Title, requestModel.Content, SystemTaxonomies.QAndADiscussionTypeTaxonomy.QuestionTag.GUID, - Maybe.None)) - .Match(_ => - { - Response.Htmx(h => h.Redirect("/q-and-a")); + Maybe.None)); - return Ok(); - }, LogAndReturnError("CREATE_QUESTION")); + if (result.IsSuccess) + { + return PartialView("~/Features/QAndA/Components/Form/QAndAQuestionFormConfirmation.cshtml"); + } + else + { + return LogAndReturnError("CREATE_QUESTION")(result.Error); + } } [HttpPost] diff --git a/src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionFormConfirmation.cshtml b/src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionFormConfirmation.cshtml new file mode 100644 index 00000000..b42d00ee --- /dev/null +++ b/src/Kentico.Community.Portal.Web/Features/QAndA/Components/Form/QAndAQuestionFormConfirmation.cshtml @@ -0,0 +1,5 @@ +