Skip to content

Commit

Permalink
Use conference proposal tags in the CFP
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoacierno committed Oct 23, 2024
1 parent 11bf392 commit df11d81
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
21 changes: 13 additions & 8 deletions frontend/src/components/tags-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@ const DropdownIndicator = (props: DropdownIndicatorProps<any, true>) => {
};

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 (
<ReactSelect
Expand Down Expand Up @@ -161,7 +166,7 @@ export const TagsSelect = ({ tags, onChange }: TagsSelectProps) => {
isMulti={true}
isOptionDisabled={() => value.length >= 5}
name="tags"
options={submissionTags}
options={proposalTags}
placeholder="Add tags"
components={{ DropdownIndicator }}
/>
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/tags-select/tags.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
query Tags {
submissionTags {
name
query Tags($conference: String!) {
conference(code: $conference) {
id
proposalTags {
name
id
}
}
}
7 changes: 3 additions & 4 deletions frontend/src/pages/cfp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/submission/[id]/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit df11d81

Please sign in to comment.