diff --git a/next.config.js b/next.config.js index 5006d160f..0fdde6242 100644 --- a/next.config.js +++ b/next.config.js @@ -6,7 +6,7 @@ module.exports = { typescript: { ignoreBuildErrors: false }, - generateEtags: false, + // generateEtags: false, webpack (config) { // required by @svgr/webpack lib const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg')) diff --git a/src/app/area/[...slug]/page.tsx b/src/app/area/[...slug]/page.tsx index 3ea77c8bb..776fcfe50 100644 --- a/src/app/area/[...slug]/page.tsx +++ b/src/app/area/[...slug]/page.tsx @@ -8,6 +8,11 @@ import { StickyHeaderContainer } from '@/app/components/ui/StickyHeaderContainer import BreadCrumbs from '@/components/ui/BreadCrumbs' +/** + * Cache duration in seconds + */ +export const revalidate = 30 + export interface PageWithCatchAllUuidProps { params: { slug: string[] diff --git a/src/app/editArea/[slug]/attributes/page.tsx b/src/app/editArea/[slug]/attributes/page.tsx index a62390686..6fde48829 100644 --- a/src/app/editArea/[slug]/attributes/page.tsx +++ b/src/app/editArea/[slug]/attributes/page.tsx @@ -4,6 +4,7 @@ import { DashboardPageProps, getPageDataForEdit, PageContainer } from '../page' export default async function AreaEditPage ({ params }: DashboardPageProps): Promise { const { area: { uuid, metadata: { lat, lng } } } = await getPageDataForEdit(params.slug) + console.log('#', lat, lng) return ( diff --git a/src/app/editArea/[slug]/general/AreaLatLngForm.tsx b/src/app/editArea/[slug]/general/AreaLatLngForm.tsx index e6b5f7cd5..ea186c115 100644 --- a/src/app/editArea/[slug]/general/AreaLatLngForm.tsx +++ b/src/app/editArea/[slug]/general/AreaLatLngForm.tsx @@ -28,7 +28,7 @@ export const AreaLatLngForm: React.FC<{ initLat: number, initLng: number, uuid: }} > { - const { area: { areaName, uuid, content: { description }, metadata: { lat, lng } } } = await getPageDataForEdit(params.slug) + const { area: { areaName, uuid, content: { description } } } = await getPageDataForEdit(params.slug) return ( diff --git a/src/components/crag/StickyHeader.tsx b/src/components/crag/StickyHeader.tsx index 5a9b5596f..da96739a1 100644 --- a/src/components/crag/StickyHeader.tsx +++ b/src/components/crag/StickyHeader.tsx @@ -1,4 +1,4 @@ -import { useRef, ReactNode } from 'react' +import { useRef } from 'react' import { useIntersection } from 'react-use' import clx from 'classnames' diff --git a/src/components/editor/plugins/ReactHookFormFieldPlugin.tsx b/src/components/editor/plugins/ReactHookFormFieldPlugin.tsx index 59d35892c..60950d28b 100644 --- a/src/components/editor/plugins/ReactHookFormFieldPlugin.tsx +++ b/src/components/editor/plugins/ReactHookFormFieldPlugin.tsx @@ -15,7 +15,6 @@ export const ReactHookFormFieldPlugin: React.FC<{ fieldName: string, rules?: Rul const onChange = useCallback((editorState: EditorState): void => { editorState.read(() => { const str = $getRoot().getTextContent() - console.log('#updating form') field.onChange(str) }) }, [editor]) diff --git a/src/components/ui/form/Input.tsx b/src/components/ui/form/Input.tsx index c4aa6e984..cedf1e963 100644 --- a/src/components/ui/form/Input.tsx +++ b/src/components/ui/form/Input.tsx @@ -1,4 +1,4 @@ -import { FormState, RegisterOptions, useFormContext, UseFormReturn } from 'react-hook-form' +import { RegisterOptions, useFormContext, UseFormReturn } from 'react-hook-form' import clx from 'classnames' import { SpinnerGap } from '@phosphor-icons/react/dist/ssr' diff --git a/src/js/hooks/useUpdateAreasCmd.tsx b/src/js/hooks/useUpdateAreasCmd.tsx index 9bedca07f..0a3a3fdb4 100644 --- a/src/js/hooks/useUpdateAreasCmd.tsx +++ b/src/js/hooks/useUpdateAreasCmd.tsx @@ -62,11 +62,13 @@ export default function useUpdateAreasCmd ({ areaId, accessToken = '', ...props }) } - const [updateAreaApi] = useMutation<{ updateAreaApi: UpdateAreaApiReturnType }, UpdateOneAreaInputType>( + const [updateAreaApi] = useMutation<{ updateArea: UpdateAreaApiReturnType }, UpdateOneAreaInputType>( MUTATION_UPDATE_AREA, { client: graphqlClient, onCompleted: (data) => { + console.log('#onCompleted', data) toast.info('Area updated successfully ✔️') + void updateCache(data.updateArea.uuid) void refreshPage(`/api/revalidate?s=${areaId}`) if (onUpdateCompleted != null) onUpdateCompleted(data) }, @@ -190,3 +192,7 @@ export const refreshPage = async (url: string): Promise => { await fetch(url) } catch {} } + +const updateCache = async (uuid: string): Promise => { + await fetch(`/editArea/${uuid}/updateCache`) +}