Extract common getStaticProps to single file

This commit is contained in:
rjmacarthy
2023-01-20 09:37:02 +00:00
parent 3fa2e637d2
commit 9b659191ca
21 changed files with 27 additions and 140 deletions
+7
View File
@@ -0,0 +1,7 @@
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
export const getDefaultStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale)),
},
});
+1 -7
View File
@@ -1,9 +1,9 @@
import { Box, Button, Center, Link, Text } from "@chakra-ui/react";
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { FiAlertTriangle } from "react-icons/fi";
import { EmptyState } from "src/components/EmptyState";
import { getTransparentHeaderLayout } from "src/components/Layout";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
function Error() {
return (
@@ -41,10 +41,4 @@ function Error() {
Error.getLayout = getTransparentHeaderLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default Error;
+1 -7
View File
@@ -1,9 +1,9 @@
import { Box, Button, Center, Link, Text } from "@chakra-ui/react";
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { FiAlertTriangle } from "react-icons/fi";
import { EmptyState } from "src/components/EmptyState";
import { getTransparentHeaderLayout } from "src/components/Layout";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
function ServerError() {
return (
@@ -44,10 +44,4 @@ function ServerError() {
ServerError.getLayout = getTransparentHeaderLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default ServerError;
+1 -7
View File
@@ -1,10 +1,10 @@
import Image from "next/image";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { CallToAction } from "src/components/CallToAction";
import { Container } from "src/components/Container";
import Roadmap from "src/components/Roadmap";
import Services from "src/components/Services";
import Vision from "src/components/Vision";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const AboutPage = () => {
return (
@@ -37,10 +37,4 @@ const AboutPage = () => {
);
};
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default AboutPage;
+1 -7
View File
@@ -2,9 +2,9 @@ import { Button, Input, InputGroup } from "@chakra-ui/react";
import Head from "next/head";
import Router from "next/router";
import { useSession } from "next-auth/react";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import React from "react";
import { Control, useForm, useWatch } from "react-hook-form";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
export default function Account() {
const { data: session } = useSession();
@@ -31,12 +31,6 @@ export default function Account() {
);
}
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
const EditForm = () => {
const { data: session } = useSession();
+1 -7
View File
@@ -2,8 +2,8 @@ import { Button } from "@chakra-ui/react";
import Head from "next/head";
import Link from "next/link";
import { useSession } from "next-auth/react";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import React from "react";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
export default function Account() {
const { data: session } = useSession();
@@ -32,9 +32,3 @@ export default function Account() {
</>
);
}
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
+1 -7
View File
@@ -1,10 +1,10 @@
import Head from "next/head";
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useEffect } from "react";
import { getAdminLayout } from "src/components/Layout";
import UsersCell from "src/components/UsersCell";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
/**
* Provides the admin index page that will display a list of users and give
@@ -45,10 +45,4 @@ const AdminIndex = () => {
AdminIndex.getLayout = getAdminLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default AdminIndex;
+1 -7
View File
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useCreateAssistantReply } from "src/hooks/tasks/useCreateReply";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const AssistantReply = () => {
const { tasks, isLoading, reset, trigger } = useCreateAssistantReply();
@@ -30,10 +30,4 @@ const AssistantReply = () => {
AssistantReply.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default AssistantReply;
+1 -7
View File
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useCreateInitialPrompt } from "src/hooks/tasks/useCreateReply";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const InitialPrompt = () => {
const { tasks, isLoading, reset, trigger } = useCreateInitialPrompt();
@@ -30,10 +30,4 @@ const InitialPrompt = () => {
InitialPrompt.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default InitialPrompt;
+1 -7
View File
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useCreatePrompterReply } from "src/hooks/tasks/useCreateReply";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const UserReply = () => {
const { tasks, isLoading, reset, trigger } = useCreatePrompterReply();
@@ -30,10 +30,4 @@ const UserReply = () => {
UserReply.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default UserReply;
+1 -7
View File
@@ -1,9 +1,9 @@
import { Flex } from "@chakra-ui/react";
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { LeaderboardTable, TaskOption, WelcomeCard } from "src/components/Dashboard";
import { getDashboardLayout } from "src/components/Layout";
import { TaskCategory } from "src/components/Tasks/TaskTypes";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const Dashboard = () => {
return (
@@ -23,10 +23,4 @@ const Dashboard = () => {
Dashboard.getLayout = (page) => getDashboardLayout(page);
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default Dashboard;
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useRankAssistantRepliesTask } from "src/hooks/tasks/useRankReplies";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const RankAssistantReplies = () => {
const { tasks, isLoading, reset, trigger } = useRankAssistantRepliesTask();
@@ -30,10 +30,4 @@ const RankAssistantReplies = () => {
RankAssistantReplies.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default RankAssistantReplies;
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useRankInitialPromptsTask } from "src/hooks/tasks/useRankReplies";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const RankInitialPrompts = () => {
const { tasks, isLoading, reset, trigger } = useRankInitialPromptsTask();
@@ -30,10 +30,4 @@ const RankInitialPrompts = () => {
RankInitialPrompts.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default RankInitialPrompts;
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useRankPrompterRepliesTask } from "src/hooks/tasks/useRankReplies";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const RankUserReplies = () => {
const { tasks, isLoading, reset, trigger } = useRankPrompterRepliesTask();
@@ -30,10 +30,4 @@ const RankUserReplies = () => {
RankUserReplies.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default RankUserReplies;
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useLabelAssistantReplyTask } from "src/hooks/tasks/useLabelingTask";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const LabelAssistantReply = () => {
const { tasks, isLoading, trigger, reset } = useLabelAssistantReplyTask();
@@ -30,10 +30,4 @@ const LabelAssistantReply = () => {
LabelAssistantReply.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default LabelAssistantReply;
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useLabelInitialPromptTask } from "src/hooks/tasks/useLabelingTask";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const LabelInitialPrompt = () => {
const { tasks, isLoading, trigger, reset } = useLabelInitialPromptTask();
@@ -30,10 +30,4 @@ const LabelInitialPrompt = () => {
LabelInitialPrompt.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default LabelInitialPrompt;
@@ -1,10 +1,10 @@
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { TaskEmptyState } from "src/components/EmptyState";
import { getDashboardLayout } from "src/components/Layout";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Task } from "src/components/Tasks/Task";
import { useLabelPrompterReplyTask } from "src/hooks/tasks/useLabelingTask";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const LabelPrompterReply = () => {
const { tasks, isLoading, trigger, reset } = useLabelPrompterReplyTask();
@@ -30,10 +30,4 @@ const LabelPrompterReply = () => {
LabelPrompterReply.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default LabelPrompterReply;
+1 -7
View File
@@ -1,8 +1,8 @@
import { Box, Heading, Tab, TabList, TabPanel, TabPanels, Tabs } from "@chakra-ui/react";
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { getDashboardLayout } from "src/components/Layout";
import { LeaderboardGridCell } from "src/components/LeaderboardGridCell";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
import { LeaderboardTimeFrame } from "src/types/Leaderboard";
const Leaderboard = () => {
@@ -46,10 +46,4 @@ const Leaderboard = () => {
Leaderboard.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default Leaderboard;
+1 -7
View File
@@ -1,10 +1,10 @@
import { Box, CircularProgress, SimpleGrid, Text, useColorModeValue } from "@chakra-ui/react";
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { getDashboardLayout } from "src/components/Layout";
import { MessageTable } from "src/components/Messages/MessageTable";
import { get } from "src/lib/api";
import useSWRImmutable from "swr/immutable";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const MessagesDashboard = () => {
const boxBgColor = useColorModeValue("white", "gray.800");
@@ -55,10 +55,4 @@ const MessagesDashboard = () => {
MessagesDashboard.getLayout = getDashboardLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default MessagesDashboard;
+1 -7
View File
@@ -1,9 +1,9 @@
import { Box, Heading, Link, Stack, Text, useColorModeValue } from "@chakra-ui/react";
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { getTransparentHeaderLayout } from "src/components/Layout";
import { PolicyChapterCard } from "src/components/PolicyCards/PolicyChapterCard";
import { PolicySectionCard } from "src/components/PolicyCards/PolicySectionCard";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const PrivacyPolicy = () => {
const backgroundColor = useColorModeValue("gray.100", "gray.800");
@@ -225,10 +225,4 @@ const PrivacyPolicy = () => {
PrivacyPolicy.getLayout = getTransparentHeaderLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default PrivacyPolicy;
+1 -7
View File
@@ -1,9 +1,9 @@
import { Box, Heading, Stack } from "@chakra-ui/react";
import Head from "next/head";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { getTransparentHeaderLayout } from "src/components/Layout";
import { PolicyChapterCard } from "src/components/PolicyCards/PolicyChapterCard";
import { PolicySectionCard } from "src/components/PolicyCards/PolicySectionCard";
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
const TermsOfService = () => {
const TermsData = [
@@ -190,10 +190,4 @@ const TermsOfService = () => {
TermsOfService.getLayout = getTransparentHeaderLayout;
export const getStaticProps = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, ["common"])),
},
});
export default TermsOfService;