diff --git a/frontend/src/components/tags-select/index.tsx b/frontend/src/components/tags-select/index.tsx index c3a947f6c1..e33a36137c 100644 --- a/frontend/src/components/tags-select/index.tsx +++ b/frontend/src/components/tags-select/index.tsx @@ -24,21 +24,26 @@ const DropdownIndicator = (props: DropdownIndicatorProps) => { }; export const TagsSelect = ({ tags, onChange }: TagsSelectProps) => { - const { data } = useTagsQuery(); + const conferenceCode = process.env.conferenceCode; + const { data } = useTagsQuery({ + variables: { + conference: conferenceCode, + }, + }); const isClient = useIsClient(); - const submissionTags = [...data!.submissionTags]! + if (!isClient) { + return null; + } + + const proposalTags = [...data.conference.proposalTags] .sort((a, b) => a.name.localeCompare(b.name)) .map((t) => ({ value: t.id, label: t.name, })); - const value = tags.map((t) => submissionTags.find((s) => s.value === t)!); - - if (!isClient) { - return null; - } + const value = tags.map((t) => proposalTags.find((s) => s.value === t)); return ( { isMulti={true} isOptionDisabled={() => value.length >= 5} name="tags" - options={submissionTags} + options={proposalTags} placeholder="Add tags" components={{ DropdownIndicator }} /> diff --git a/frontend/src/components/tags-select/tags.graphql b/frontend/src/components/tags-select/tags.graphql index f85cbe21fb..1bd34bd5de 100644 --- a/frontend/src/components/tags-select/tags.graphql +++ b/frontend/src/components/tags-select/tags.graphql @@ -1,6 +1,9 @@ -query Tags { - submissionTags { - name +query Tags($conference: String!) { + conference(code: $conference) { id + proposalTags { + name + id + } } } diff --git a/frontend/src/pages/cfp/index.tsx b/frontend/src/pages/cfp/index.tsx index 0aed654634..f7fada16b3 100644 --- a/frontend/src/pages/cfp/index.tsx +++ b/frontend/src/pages/cfp/index.tsx @@ -6,17 +6,14 @@ import { Spacer, Text, } from "@python-italia/pycon-styleguide"; -import { Fragment } from "react"; import { FormattedMessage } from "react-intl"; import type { GetServerSideProps, GetStaticProps } from "next"; import { addApolloState, getApolloClient } from "~/apollo/client"; -import { Alert } from "~/components/alert"; import { Introduction } from "~/components/cfp-introduction"; import { CfpSendSubmission } from "~/components/cfp-send-submission"; import { MetaTags } from "~/components/meta-tags"; -import { useLoginState } from "~/components/profile/hooks"; import { prefetchSharedQueries } from "~/helpers/prefetch"; import { queryCfpForm, @@ -100,7 +97,9 @@ export const getServerSideProps: GetServerSideProps = async ({ queryCfpForm(client, { conference: process.env.conferenceCode, }), - queryTags(client), + queryTags(client, { + conference: process.env.conferenceCode, + }), ]); } catch (e) { return { diff --git a/frontend/src/pages/submission/[id]/edit/index.tsx b/frontend/src/pages/submission/[id]/edit/index.tsx index c8d8b3f24f..82f1c628df 100644 --- a/frontend/src/pages/submission/[id]/edit/index.tsx +++ b/frontend/src/pages/submission/[id]/edit/index.tsx @@ -136,7 +136,9 @@ export const getServerSideProps: GetServerSideProps = async ({ queryCfpForm(client, { conference: process.env.conferenceCode, }), - queryTags(client), + queryTags(client, { + conference: process.env.conferenceCode, + }), queryGetSubmission(client, { id, language: locale,