Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validated number questions in multipart type #184

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/api/asset/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import tags from "@/lib/tags";
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest) {
Expand All @@ -13,7 +14,7 @@ export async function GET(request: NextRequest) {
try {
const response = await fetch(url, {
next: {
tags: ["datasets"],
tags: [tags.datasets],
},
});
const asset = await response.json();
Expand Down
6 changes: 5 additions & 1 deletion app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { revalidatePath } from "next/cache";
import { revalidatePath, revalidateTag } from "next/cache";
import { NextRequest } from "next/server";
import tags from "@/lib/tags";

const REVALIDATE_SECRET_TOKEN = process.env.CRAFT_SECRET_TOKEN;

Expand All @@ -25,6 +26,9 @@ export async function GET(request: NextRequest) {

if (uri) {
revalidatePath(`/[locale]/${uri}`, "page");
Object.entries(tags).forEach(([, tag]) => {
revalidateTag(tag);
});
return Response.json({ revalidated: true, now: Date.now() });
}

Expand Down
12 changes: 6 additions & 6 deletions app/api/xlsx/formatter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Cell as TableCell } from "@/components/layout/Table/helpers";
import { Option } from "@/components/shapes/option";
import text from "./text";
import select from "./select";
import multiPart from "./inline";
import multiPart from "./multipart";
import widget from "./widget";
import tabular from "./tabular";
import calculator from "./calculator";
import { InlineQuestionData, TextInput, WidgetInput } from "@/types/answers";
import { MultipartQuestionData, TextInput, WidgetInput } from "@/types/answers";
import {
InlineReviewProps,
MultipartReviewProps,
ReviewPart,
} from "@/components/questions/Review/Inline";
} from "@/components/questions/Review/Multipart";
import { Equation } from "@/types/calculators";
import { AnswerType } from "@/types/questions";

Expand All @@ -38,8 +38,8 @@ export interface TabularProps extends FormatterBaseProps<WidgetInput> {
}

export interface InlineFactoryProps
extends FormatterBaseProps<InlineQuestionData>,
Omit<InlineReviewProps, "number"> {
extends FormatterBaseProps<MultipartQuestionData>,
Omit<MultipartReviewProps, "number"> {
parts: Array<ReviewPart>;
}

Expand Down
3 changes: 2 additions & 1 deletion components/content-blocks/MagnitudeScatterPlot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BaseContentBlockProps } from "@/components/shapes";
import { ObservationsPlot } from "@rubin-epo/epo-widget-lib/LightCurvePlot";
import WidgetContainerWithModal from "@/components/layout/WidgetContainerWithModal";
import { useTranslation } from "@/lib/i18n";
import tags from "@/lib/tags";

const Fragment = graphql(`
fragment MagnitudeScatterPlotBlock on contentBlocks_magnitudeScatterPlot_BlockType {
Expand Down Expand Up @@ -31,7 +32,7 @@ const Fragment = graphql(`
const getDataset = async (url?: string): Promise<Array<string>> => {
if (url) {
const response = await fetch(url, {
next: { tags: ["datasets"] },
next: { tags: [tags.datasets] },
});
return await response.json();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BaseContentBlockProps } from "@/components/shapes";
import { FragmentType, graphql, useFragment } from "@/gql/public-schema";
import SupernovaDistanceDistribution from "@/components/dynamic/SupernovaDistanceDistribution";
import * as Styled from "./styles";
import tags from "@/lib/tags";

const Fragment = graphql(`
fragment SupernovaDistanceDistributionBlock on contentBlocks_supernovaDistanceDistribution_BlockType {
Expand Down Expand Up @@ -41,7 +42,7 @@ const SupernovaDistanceDistributionBlock: FunctionComponent<
const response = await fetch(url, {
cache: "force-cache",
headers: { "Content-Type": "application/json" },
next: { tags: ["datasets"] },
next: { tags: [tags.datasets] },
});
const supernovaData: Array<number> = await response.json();

Expand Down
38 changes: 3 additions & 35 deletions components/factories/QuestionFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { graphql, useFragment, FragmentType } from "@/gql/public-schema";
import { AnswerType } from "@/types/questions";
import SimpleQuestion from "@/components/questions/SimpleQuestion";
import TabularQuestion from "@/components/questions/TabularQuestion";
import InlineQuestion from "@/components/questions/InlineQuestion";
import MultipartQuestion from "@/components/questions/MultipartQuestion";
import CalculatorQuestion from "@/components/questions/Calculator";
import WidgetQuestion from "@/components/questions/Widget";
import NumberQuestion from "@/components/questions/Number";
Expand All @@ -18,45 +18,13 @@ const Fragment = graphql(`
...TabularQuestion
...WidgetQuestion
...NumberQuestion
...MultipartQuestion
options: answerOptions {
... on answerOptions_option_BlockType {
label: optionLabel
value: optionValue
}
}
parts: multiPartBlocks {
... on multiPartBlocks_select_BlockType {
id
type: typeHandle
options: answerOptions {
... on answerOptions_option_BlockType {
id
label: optionLabel
value: optionValue
}
}
}
... on multiPartBlocks_text_BlockType {
id
type: typeHandle
}
... on multiPartBlocks_multiselect_BlockType {
id
type: typeHandle
options: answerOptions {
... on answerOptions_option_BlockType {
id
label: optionLabel
value: optionValue
}
}
}
... on multiPartBlocks_readonlyText_BlockType {
id
type: typeHandle
text: questionText
}
}
}
`);

Expand All @@ -72,7 +40,7 @@ const QUESTION_MAP: Record<AnswerType, ComponentType<any>> = {
widget: WidgetQuestion,
calculator: CalculatorQuestion,
textarea: SimpleQuestion,
multiPart: InlineQuestion,
multiPart: MultipartQuestion,
number: NumberQuestion,
};

Expand Down
2 changes: 1 addition & 1 deletion components/factories/ReviewFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const QUESTION_MAP: Record<AnswerType, ComponentType<any>> = {
select: Review.Select,
widget: Review.Widget,
textarea: Review.Text,
multiPart: Review.Inline,
multiPart: Review.Multipart,
tabular: Review.Tabular,
calculator: Review.Calculator,
number: Review.Text,
Expand Down
35 changes: 0 additions & 35 deletions components/questions/InlineQuestion/Multiselect/index.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions components/questions/InlineQuestion/Readonly/index.tsx

This file was deleted.

33 changes: 0 additions & 33 deletions components/questions/InlineQuestion/Select/index.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions components/questions/InlineQuestion/Text/index.tsx

This file was deleted.

93 changes: 0 additions & 93 deletions components/questions/InlineQuestion/index.tsx

This file was deleted.

Loading
Loading