Skip to content

Commit

Permalink
SurveyResponse: replace link to switch survey response view
Browse files Browse the repository at this point in the history
This reverts commit 77d565e.
  • Loading branch information
JohannaPeanut committed Apr 8, 2024
1 parent 77d565e commit 5ef5dd4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { BlitzPage, Routes, useParam } from "@blitzjs/next"
import { BlitzPage, useParam } from "@blitzjs/next"
import { useQuery } from "@blitzjs/rpc"
import router from "next/router"
import { Suspense } from "react"
import { Spinner } from "src/core/components/Spinner"
import { Link } from "src/core/components/links"
import { PageHeader } from "src/core/components/pages/PageHeader"
import { H2 } from "src/core/components/text"
import { useSlugs } from "src/core/hooks"
Expand Down Expand Up @@ -73,27 +71,15 @@ export const SurveyResponseWithLocation = () => {
<H2>Beiträge mit Ortsangabe </H2>

<div className="flex flex-col lg:flex-row gap-2">
<div className="lg:w-[46%] shrink-0">
<section className="w-full lg:mb-6">
<SurveyFeedbackWithLocationOverviewMap
maptilerStyleUrl={maptilerStyleUrl}
defaultViewState={defaultViewState}
selectedSurveyResponse={selectedSurveyResponse}
surveyResponsesFeedbackPartWithLocation={surveyResponsesFeedbackPartWithLocation}
locationRef={locationRef!}
/>
</section>
<Link
className="hidden lg:block"
href={Routes.SurveyResponsePage({
projectSlug: projectSlug!,
surveyId: surveyId!,
haslocation: "true",
})}
>
Alle verorteten Beiträge öffnen
</Link>
</div>
<section className="lg:w-[46%] shrink-0">
<SurveyFeedbackWithLocationOverviewMap
maptilerStyleUrl={maptilerStyleUrl}
defaultViewState={defaultViewState}
selectedSurveyResponse={selectedSurveyResponse}
surveyResponsesFeedbackPartWithLocation={surveyResponsesFeedbackPartWithLocation}
locationRef={locationRef!}
/>
</section>
<section className="rounded-md drop-shadow-md">
<EditableSurveyResponseListItem
key={selectedSurveyResponse?.id}
Expand All @@ -105,16 +91,6 @@ export const SurveyResponseWithLocation = () => {
/>
</section>
</div>
<Link
className="lg:hidden"
href={Routes.SurveyResponsePage({
projectSlug: projectSlug!,
surveyId: surveyId!,
haslocation: "true",
})}
>
Alle verorteten Beiträge öffnen
</Link>
</div>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function EditableSurveyResponseFilterForm<S extends z.ZodType<any, any>>(
statuses: [...Object.keys(surveyResponseStatus)], // default: all checked
topics: [...topics.map((t) => String(t.id)), "0"], // default: all checked
hasnotes: "ALL", // default: radio "ALL"
haslocation: queryHaslocation || "ALL", // default: radio "ALL"
haslocation: "ALL", // default: radio "ALL"
//@ts-expect-error
categories: [...feedbackQuestion?.props?.responses.map((r: TResponse) => String(r.id))], // default: all checked
searchterm: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
LabeledTextField,
LabeledTextareaField,
} from "src/core/components/forms"
import { blueButtonStyles } from "src/core/components/links"
import { Link, blueButtonStyles } from "src/core/components/links"
import { useSlugs } from "src/core/hooks"
import createSurveyResponseTopicsOnSurveyResponses from "src/survey-response-topics-on-survey-responses/mutations/createSurveyResponseTopicsOnSurveyResponses"
import deleteSurveyResponseTopicsOnSurveyResponses from "src/survey-response-topics-on-survey-responses/mutations/deleteSurveyResponseTopicsOnSurveyResponses"
Expand All @@ -22,6 +22,7 @@ import updateSurveyResponse from "../../mutations/updateSurveyResponse"
import { EditableSurveyResponseFormMap } from "./EditableSurveyResponseFormMap"
import { EditableSurveyResponseListItemProps } from "./EditableSurveyResponseListItem"
import { surveyResponseStatus } from "./surveyResponseStatus"
import { Routes, useParam } from "@blitzjs/next"

type FormProps<S extends z.ZodType<any, any>> = Omit<
PropsWithoutRef<JSX.IntrinsicElements["form"]>,
Expand Down Expand Up @@ -59,6 +60,7 @@ export function EditableSurveyResponseForm<S extends z.ZodType<any, any>>({
})

const { projectSlug } = useSlugs()
const surveyId = useParam("surveyId", "string")

const [updateSurveyResponseMutation] = useMutation(updateSurveyResponse)
const [surveyResponseTopicsOnSurveyResponsesMutation] = useMutation(
Expand Down Expand Up @@ -215,6 +217,22 @@ export function EditableSurveyResponseForm<S extends z.ZodType<any, any>>({
maptilerStyleUrl={maptilerStyleUrl}
defaultViewState={defaultViewState}
/>
{
// @ts-expect-error `data` is unkown
response.data[userLocationQuestionId] && (
<div className="pt-4">
<Link
href={Routes.SurveyResponseWithLocationPage({
projectSlug: projectSlug!,
surveyId: surveyId!,
surveyResponseId: response.id,
})}
>
Alle verorteten Beiträge öffnen
</Link>
</div>
)
}
</div>
)}

Expand Down

0 comments on commit 5ef5dd4

Please sign in to comment.