From b7d3fbff6c36471f502cbc96ebc76658d1c6ae1f Mon Sep 17 00:00:00 2001 From: aeolian <94939382+aeolianeth@users.noreply.github.com> Date: Tue, 11 Jun 2024 07:44:35 +1000 Subject: [PATCH] refactor: nuke project updates (#4354) --- codegen.yml | 2 +- scripts/graphql-codegen-override-pv.js | 2 +- .../ProjectDashboard/ProjectDashboard.tsx | 5 +- .../AddProjectUpdateModal.tsx | 267 ------------------ .../components/ProjectTabs/ProjectTabs.tsx | 14 - .../ProjectUpdatesProvider.tsx | 42 --- .../hooks/useFactoredProjectId.ts | 12 - .../hooks/useProjectUpdates.ts | 44 --- .../utils/projectUpdatesReducer.ts | 40 --- src/locales/messages.pot | 18 -- .../[projectId]/updates/[projectUpdateId].ts | 74 ----- .../api/projects/[projectId]/updates/index.ts | 86 ------ .../authenticateProjectUpdateOperation.ts | 45 --- 13 files changed, 3 insertions(+), 648 deletions(-) delete mode 100644 src/components/v2v3/V2V3Project/ProjectDashboard/components/AddProjectUpdateModal/AddProjectUpdateModal.tsx delete mode 100644 src/components/v2v3/V2V3Project/ProjectDashboard/components/ProjectUpdatesProvider/ProjectUpdatesProvider.tsx delete mode 100644 src/components/v2v3/V2V3Project/ProjectDashboard/components/ProjectUpdatesProvider/hooks/useFactoredProjectId.ts delete mode 100644 src/components/v2v3/V2V3Project/ProjectDashboard/components/ProjectUpdatesProvider/hooks/useProjectUpdates.ts delete mode 100644 src/components/v2v3/V2V3Project/ProjectDashboard/components/ProjectUpdatesProvider/utils/projectUpdatesReducer.ts delete mode 100644 src/pages/api/projects/[projectId]/updates/[projectUpdateId].ts delete mode 100644 src/pages/api/projects/[projectId]/updates/index.ts delete mode 100644 src/utils/authenticateProjectUpdateOperation.ts diff --git a/codegen.yml b/codegen.yml index 826d04611f..ab9d9b7d1b 100644 --- a/codegen.yml +++ b/codegen.yml @@ -2,7 +2,7 @@ overwrite: true schema: ${SUBGRAPH_URL} documents: 'src/graphql/**/*.graphql' generates: - src/generated/graphql.tsx: + src/generated/graphql.ts: plugins: - 'typescript' - 'typescript-operations' diff --git a/scripts/graphql-codegen-override-pv.js b/scripts/graphql-codegen-override-pv.js index ec4d23770f..1e48043632 100644 --- a/scripts/graphql-codegen-override-pv.js +++ b/scripts/graphql-codegen-override-pv.js @@ -1,6 +1,6 @@ const fs = require('fs') -const path = __dirname + '/../src/generated/graphql.tsx' +const path = __dirname + '/../src/generated/graphql.ts' try { // Load generated file diff --git a/src/components/v2v3/V2V3Project/ProjectDashboard/ProjectDashboard.tsx b/src/components/v2v3/V2V3Project/ProjectDashboard/ProjectDashboard.tsx index a8244f2362..c03f0e3ec7 100644 --- a/src/components/v2v3/V2V3Project/ProjectDashboard/ProjectDashboard.tsx +++ b/src/components/v2v3/V2V3Project/ProjectDashboard/ProjectDashboard.tsx @@ -10,7 +10,6 @@ import { PayRedeemCard } from './components/PayRedeemCard' import { ProjectHeader } from './components/ProjectHeader/ProjectHeader' import { ProjectHeaderCountdown } from './components/ProjectHeaderCountdown' import { ProjectTabs } from './components/ProjectTabs/ProjectTabs' -import { ProjectUpdatesProvider } from './components/ProjectUpdatesProvider/ProjectUpdatesProvider' import { ReduxProjectCartProvider } from './components/ReduxProjectCartProvider' import { SuccessPayView } from './components/SuccessPayView/SuccessPayView' import { useProjectPageQueries } from './hooks/useProjectPageQueries' @@ -72,9 +71,7 @@ const Wrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => { - - {children} - + {children} diff --git a/src/components/v2v3/V2V3Project/ProjectDashboard/components/AddProjectUpdateModal/AddProjectUpdateModal.tsx b/src/components/v2v3/V2V3Project/ProjectDashboard/components/AddProjectUpdateModal/AddProjectUpdateModal.tsx deleted file mode 100644 index 4efa225318..0000000000 --- a/src/components/v2v3/V2V3Project/ProjectDashboard/components/AddProjectUpdateModal/AddProjectUpdateModal.tsx +++ /dev/null @@ -1,267 +0,0 @@ -import { PhotoIcon, XCircleIcon } from '@heroicons/react/24/outline' -import { Trans, t } from '@lingui/macro' -import { Button } from 'antd' -import axios from 'axios' -import ExternalLink from 'components/ExternalLink' -import { JuiceVideoThumbnailOrImage } from 'components/JuiceVideo/JuiceVideoThumbnailOrImage' -import Loading from 'components/Loading' -import { JuiceModal } from 'components/modals/JuiceModal' -import { PV_V2 } from 'constants/pv' -import { useProjectMetadataContext } from 'contexts/shared/ProjectMetadataContext' -import { Formik } from 'formik' -import { useIpfsFilePicker } from 'hooks/useIpfsFilePicker/useIpfsFilePicker' -import { useContext } from 'react' -import { twMerge } from 'tailwind-merge' -import { getSubgraphIdForProject } from 'utils/graph' -import * as Yup from 'yup' -import { ProjectUpdatesContext } from '../ProjectUpdatesProvider/ProjectUpdatesProvider' - -const ValidationSchema = Yup.object().shape({ - title: Yup.string().required('Title is required').max(100, 'Too long'), - message: Yup.string().required('Message is required').max(3000, 'Too long'), - imageUrl: Yup.string().url('Invalid URL'), -}) -type AddProjectUpdateFormValues = Yup.InferType - -export const AddProjectUpdateModal = ({ - open, - setOpen, -}: { - open: boolean - setOpen: React.Dispatch> -}) => { - const { loadProjectUpdates } = useContext(ProjectUpdatesContext) - const { projectId } = useProjectMetadataContext() - const project = projectId - ? getSubgraphIdForProject(PV_V2, projectId) - : undefined - - if (!project) return - - return ( - - validationSchema={ValidationSchema} - initialValues={{ - title: '', - message: '', - }} - onSubmit={async (values, helper) => { - const { title, message, imageUrl } = values - await axios.post(`/api/projects/${project}/updates`, { - title, - message, - imageUrl, - }) - loadProjectUpdates() - setOpen(false) - setTimeout(() => { - helper.setSubmitting(false) - helper.resetForm() - }, 300) - }} - > - {props => ( -
- { - setOpen(false) - }} - > - - - Add an update that will be posted to your project page. - - -
-
- -
- - props.setFieldValue('title', e.currentTarget.value) - } - /> -
-
- {props.errors.title && props.touched.title && ( -
- {props.errors.title} -
- )} -
-
- -
- -
- - {props.values.message.length}/3000 - -