Skip to content
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
1 change: 1 addition & 0 deletions front_end/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"predictionUpcomingMessage": "This question is in the Upcoming stage, and will be open for predictions soon",
"predictionUnapprovedMessage": "This question must be approved by moderators before you can begin predicting",
"predictionClosedMessage": "This question is closed for predictions, and is waiting to be resolved",
"predictionConditionalPartiallyClosedMessage": "The question \"{closedQuestion}\" has closed, so these conditionals are closed for forecasting. They will resolve when the question \"{activeQuestion}\" resolves.",
"resolve": "Resolve",
"unresolve": "Unresolve",
"preview": "Preview",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
import classNames from "classnames";
import { round } from "lodash";
import { useTranslations } from "next-intl";
import React, { FC, useCallback, useMemo, useState } from "react";
import React, { FC, ReactNode, useCallback, useMemo, useState } from "react";

import { createForecasts } from "@/app/(main)/questions/actions";
import Button from "@/components/ui/button";
import { FormErrorMessage } from "@/components/ui/form_field";
import { useAuth } from "@/contexts/auth_context";
import { ErrorResponse } from "@/types/fetch";
import { Post, PostConditional } from "@/types/post";
import {
PredictionInputMessage,
QuestionWithNumericForecasts,
} from "@/types/question";
import { QuestionWithNumericForecasts } from "@/types/question";
import { extractPrevBinaryForecastValue } from "@/utils/forecasts";

import { sendGAConditionalPredictEvent } from "./ga_events";
Expand All @@ -32,7 +29,7 @@ type Props = {
prevYesForecast?: any;
prevNoForecast?: any;
canPredict: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
projects: Post["projects"];
};

Expand Down Expand Up @@ -276,7 +273,7 @@ const ForecastMakerConditionalBinary: FC<Props> = ({
<div className="my-5 flex flex-wrap items-center justify-center gap-3 px-4">
{predictionMessage && (
<div className="mb-2 text-center text-sm italic text-gray-700 dark:text-gray-700-dark">
{t(predictionMessage)}
{predictionMessage}
</div>
)}
{canPredict && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import classNames from "classnames";
import { useTranslations } from "next-intl";
import React, { FC, useCallback, useMemo, useState } from "react";
import React, { FC, ReactNode, useCallback, useMemo, useState } from "react";

import { createForecasts } from "@/app/(main)/questions/actions";
import { MultiSliderValue } from "@/components/sliders/multi_slider";
Expand All @@ -10,11 +10,7 @@ import { FormErrorMessage } from "@/components/ui/form_field";
import { useAuth } from "@/contexts/auth_context";
import { ErrorResponse } from "@/types/fetch";
import { Post, PostConditional } from "@/types/post";
import {
PredictionInputMessage,
Quartiles,
QuestionWithNumericForecasts,
} from "@/types/question";
import { Quartiles, QuestionWithNumericForecasts } from "@/types/question";
import { getDisplayValue } from "@/utils/charts";
import {
extractPrevNumericForecastValue,
Expand All @@ -39,7 +35,7 @@ type Props = {
prevYesForecast?: any;
prevNoForecast?: any;
canPredict: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
projects: Post["projects"];
};

Expand Down Expand Up @@ -388,7 +384,7 @@ const ForecastMakerConditionalContinuous: FC<Props> = ({
))}
{predictionMessage && (
<div className="mb-2 text-center text-sm italic text-gray-700 dark:text-gray-700-dark">
{t(predictionMessage)}
{predictionMessage}
</div>
)}
{canPredict && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useTranslations } from "next-intl";
import { FC } from "react";
import { FC, ReactNode } from "react";

import { PostConditional, PostWithForecasts } from "@/types/post";
import {
PredictionInputMessage,
QuestionType,
QuestionWithForecasts,
QuestionWithNumericForecasts,
Expand All @@ -17,7 +16,7 @@ type Props = {
post: PostWithForecasts;
conditional: PostConditional<QuestionWithForecasts>;
canPredict: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
};

const ForecastMakerConditional: FC<Props> = ({
Expand All @@ -41,6 +40,7 @@ const ForecastMakerConditional: FC<Props> = ({
: false;
const conditionClosedOrResolved =
parentSuccessfullyResolved || parentIsClosed;

return (
<ForecastMakerContainer
resolutionCriteria={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type Props = {
groupVariable: string;
canPredict: boolean;
canResolve: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
};

const ForecastMakerGroupBinary: FC<Props> = ({
Expand Down Expand Up @@ -268,7 +268,7 @@ const ForecastMakerGroupBinary: FC<Props> = ({
</table>
{predictionMessage && (
<div className="mb-2 text-center text-sm italic text-gray-700 dark:text-gray-700-dark">
{t(predictionMessage)}
{predictionMessage}
</div>
)}
{!!highlightedQuestion?.resolution && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import { differenceInMilliseconds } from "date-fns";
import { isNil } from "lodash";
import { useSearchParams } from "next/navigation";
import { useLocale, useTranslations } from "next-intl";
import React, { FC, useCallback, useEffect, useMemo, useState } from "react";
import React, {
FC,
ReactNode,
useCallback,
useEffect,
useMemo,
useState,
} from "react";

import { createForecasts } from "@/app/(main)/questions/actions";
import { MultiSliderValue } from "@/components/sliders/multi_slider";
Expand Down Expand Up @@ -51,7 +58,7 @@ type Props = {
groupVariable: string;
canPredict: boolean;
canResolve: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
};

const ForecastMakerGroupContinuous: FC<Props> = ({
Expand Down Expand Up @@ -338,7 +345,7 @@ const ForecastMakerGroupContinuous: FC<Props> = ({
})}
{predictionMessage && (
<div className="mb-2 text-center text-sm italic text-gray-700 dark:text-gray-700-dark">
{t(predictionMessage)}
{predictionMessage}
</div>
)}
{!!activeGroupOption &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useTranslations } from "next-intl";
import { FC } from "react";
import { FC, ReactNode } from "react";

import { PostWithForecasts } from "@/types/post";
import {
PredictionInputMessage,
QuestionType,
QuestionWithForecasts,
QuestionWithNumericForecasts,
Expand All @@ -22,7 +21,7 @@ type Props = {
groupVariable: string;
canPredict: boolean;
canResolve: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
};

const ForecastMakerGroup: FC<Props> = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { round } from "lodash";
import { useTranslations } from "next-intl";
import React, { FC, useEffect, useState } from "react";
import React, { FC, ReactNode, useEffect, useState } from "react";

import { createForecasts } from "@/app/(main)/questions/actions";
import { FormErrorMessage } from "@/components/ui/form_field";
Expand All @@ -10,10 +10,7 @@ import { useAuth } from "@/contexts/auth_context";
import { useServerAction } from "@/hooks/use_server_action";
import { ErrorResponse } from "@/types/fetch";
import { PostWithForecasts, ProjectPermissions } from "@/types/post";
import {
PredictionInputMessage,
QuestionWithNumericForecasts,
} from "@/types/question";
import { QuestionWithNumericForecasts } from "@/types/question";
import { extractPrevBinaryForecastValue } from "@/utils/forecasts";

import { sendGAPredictEvent } from "./ga_events";
Expand All @@ -30,7 +27,7 @@ type Props = {
permission?: ProjectPermissions;
canPredict: boolean;
canResolve: boolean;
predictionMessage?: PredictionInputMessage;
predictionMessage?: ReactNode;
};

const ForecastMakerBinary: FC<Props> = ({
Expand Down Expand Up @@ -99,7 +96,7 @@ const ForecastMakerBinary: FC<Props> = ({
/>
{predictionMessage && (
<div className="mb-2 text-center text-sm italic text-gray-700 dark:text-gray-700-dark">
{t(predictionMessage)}
{predictionMessage}
</div>
)}
<div className="flex flex-col items-center justify-center">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import { useTranslations } from "next-intl";
import React, { FC, useMemo, useState } from "react";
import React, { FC, ReactNode, useMemo, useState } from "react";

import { createForecasts } from "@/app/(main)/questions/actions";
import { MultiSliderValue } from "@/components/sliders/multi_slider";
Expand All @@ -11,10 +11,7 @@ import { useAuth } from "@/contexts/auth_context";
import { useServerAction } from "@/hooks/use_server_action";
import { ErrorResponse } from "@/types/fetch";
import { PostWithForecasts, ProjectPermissions } from "@/types/post";
import {
PredictionInputMessage,
QuestionWithNumericForecasts,
} from "@/types/question";
import { QuestionWithNumericForecasts } from "@/types/question";
import {
extractPrevNumericForecastValue,
getNumericForecastDataset,
Expand All @@ -36,7 +33,7 @@ type Props = {
permission?: ProjectPermissions;
canPredict: boolean;
canResolve: boolean;
predictionMessage?: PredictionInputMessage;
predictionMessage?: ReactNode;
};

const ForecastMakerContinuous: FC<Props> = ({
Expand Down Expand Up @@ -177,7 +174,7 @@ const ForecastMakerContinuous: FC<Props> = ({
)}
{predictionMessage && (
<div className="mb-2 text-center text-sm italic text-gray-700 dark:text-gray-700-dark">
{t(predictionMessage)}
{predictionMessage}
</div>
)}
<NumericForecastTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { faUserGroup } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { isNil, round } from "lodash";
import { useTranslations } from "next-intl";
import React, { FC, useCallback, useMemo, useState } from "react";
import React, { FC, ReactNode, useCallback, useMemo, useState } from "react";

import { createForecasts } from "@/app/(main)/questions/actions";
import Button from "@/components/ui/button";
Expand All @@ -16,7 +16,6 @@ import { ErrorResponse } from "@/types/fetch";
import { PostWithForecasts, ProjectPermissions } from "@/types/post";
import {
AggregateForecastHistory,
PredictionInputMessage,
Question,
QuestionWithMultipleChoiceForecasts,
UserForecastHistory,
Expand Down Expand Up @@ -48,7 +47,7 @@ type Props = {
permission?: ProjectPermissions;
canPredict: boolean;
canResolve: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
};

const ForecastMakerMultipleChoice: FC<Props> = ({
Expand Down Expand Up @@ -262,7 +261,7 @@ const ForecastMakerMultipleChoice: FC<Props> = ({
</table>
{predictionMessage && (
<div className="my-2 text-center text-sm italic text-gray-700 dark:text-gray-700-dark">
{t(predictionMessage)}
{predictionMessage}
</div>
)}
<div className="mt-5 flex flex-wrap items-center justify-center gap-4 border-b border-b-blue-400 pb-5 dark:border-b-blue-400-dark">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { parseISO } from "date-fns";
import { useLocale, useTranslations } from "next-intl";
import { FC } from "react";
import { FC, ReactNode } from "react";

import { PostWithForecasts, ProjectPermissions } from "@/types/post";
import {
PredictionInputMessage,
QuestionType,
QuestionWithForecasts,
} from "@/types/question";
import { QuestionType, QuestionWithForecasts } from "@/types/question";
import { formatResolution } from "@/utils/questions";

import ForecastMakerBinary from "./forecast_maker_binary";
Expand All @@ -22,7 +18,7 @@ type Props = {
permission?: ProjectPermissions;
canPredict: boolean;
canResolve: boolean;
predictionMessage: PredictionInputMessage;
predictionMessage: ReactNode;
};

const QuestionForecastMaker: FC<Props> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { parseISO } from "date-fns";
import { isNil } from "lodash";
import { FC } from "react";

import PredictionStatusMessage from "@/app/(main)/questions/[id]/components/forecast_maker/prediction_status_message";
import {
PostStatus,
PostWithForecasts,
ProjectPermissions,
} from "@/types/post";
import {
canPredictQuestion,
getPredictionInputMessage,
} from "@/utils/questions";
import { canPredictQuestion } from "@/utils/questions";

import ForecastMakerConditional from "./forecast_maker_conditional";
import ForecastMakerGroup from "./forecast_maker_group";
Expand All @@ -37,7 +35,8 @@ const ForecastMaker: FC<Props> = ({ post }) => {
parseISO(post.published_at) <= new Date() &&
[PostStatus.APPROVED, PostStatus.OPEN, PostStatus.CLOSED].includes(status);

const predictionMessage = getPredictionInputMessage(post);
const predictionMessage = <PredictionStatusMessage post={post} />;

if (groupOfQuestions) {
return (
<ForecastMakerGroup
Expand Down
Loading
Loading