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
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { renderHook, act } from '@testing-library/react';
import { useArtworkSubmissionForm } from '@/components/waves/memes/submission/hooks/useArtworkSubmissionForm';

jest.mock('@/components/waves/memes/traits/schema', () => ({ initialTraits: { title: '', description: '', artist: '', seizeArtistProfile: '' } }));
jest.mock('@/components/waves/memes/traits/schema', () => ({
getInitialTraitsValues: () => ({
title: '',
description: '',
artist: '',
seizeArtistProfile: '',
}),
}));
jest.mock('@/components/auth/Auth', () => ({ useAuth: jest.fn() }));

const { useAuth } = require('@/components/auth/Auth');
Expand Down
5 changes: 3 additions & 2 deletions __tests__/components/waves/memes/traits/schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getFormSections, initialTraits } from '@/components/waves/memes/traits/schema';
import { getFormSections, getInitialTraitsValues } from '@/components/waves/memes/traits/schema';

describe('traits schema helpers', () => {
it('replaces profile placeholder', () => {
Expand All @@ -7,7 +7,8 @@ describe('traits schema helpers', () => {
expect(artistField.placeholder).toBe('Bob');
});

it('provides initial trait values via constant', () => {
it('provides initial trait values via helper', () => {
const initialTraits = getInitialTraitsValues();
expect(initialTraits.pointsPower).toBe(0);
expect(initialTraits.punk6529).toBe(false);
});
Expand Down
2 changes: 1 addition & 1 deletion app/api/farcaster/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,5 +755,5 @@ export async function GET(request: NextRequest) {
}
}

// ts-prune-ignore-next-line: Next.js reads this named export as route config
export const dynamic = "force-dynamic";
export const revalidate = 0;
3 changes: 3 additions & 0 deletions app/api/open-graph/proxy-image/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function mapGuardErrorToResponse(error: UrlGuardError): NextResponse {
}
}

// ts-prune-ignore-next: Next.js uses exported HTTP verb handlers via convention.
export async function GET(request: NextRequest) {
const target = request.nextUrl.searchParams.get("url");

Expand All @@ -109,7 +110,9 @@ export async function GET(request: NextRequest) {
return proxyImage(remoteResult.url);
}

// ts-prune-ignore-next: Next.js framework consumes this export via route conventions.
export const dynamic = "force-dynamic";
// ts-prune-ignore-next: Next.js framework consumes this export via route conventions.
export const revalidate = 0;

function parseRemoteUrl(target: string): { url: URL } | { response: NextResponse } {
Expand Down
2 changes: 0 additions & 2 deletions app/api/open-graph/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,3 @@ export async function GET(request: NextRequest) {
}

export const dynamic = "force-dynamic";

export const revalidate = 0;
4 changes: 2 additions & 2 deletions app/api/pepe/resolve/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

const TOKENSCAN_BASE = "https://tokenscan.io/api";

export type PepeKind = "asset" | "collection" | "artist" | "set";
type PepeKind = "asset" | "collection" | "artist" | "set";

type Market = {
bestAskSats?: number;
Expand Down Expand Up @@ -814,6 +814,7 @@ async function resolveAsset(slug: string): Promise<AssetPreview> {
};
}

// ts-prune-ignore-next: Next.js uses exported HTTP verb handlers via convention.
export async function GET(request: NextRequest) {
const kind =
(request.nextUrl.searchParams.get("kind") as PepeKind | null) ?? null;
Expand Down Expand Up @@ -864,4 +865,3 @@ export async function GET(request: NextRequest) {
}

export const dynamic = "force-dynamic";
export const revalidate = 0;
1 change: 0 additions & 1 deletion app/api/tiktok/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,3 @@ export async function GET(request: NextRequest) {
}

export const dynamic = "force-dynamic";
export const revalidate = 0;
1 change: 0 additions & 1 deletion app/api/wikimedia-card/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,4 +1021,3 @@ export async function GET(request: NextRequest) {
}

export const dynamic = "force-dynamic";
export const revalidate = 0;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useReducer, useEffect, useCallback } from "react";
import { TraitsData } from "../types/TraitsData";
import { SubmissionStep } from "../types/Steps";
import { useAuth } from "@/components/auth/Auth";
import { getInitialTraitsValues } from "@/components/waves/memes/traits/schema";

/**
* Action types for the form reducer - drastically simplified
Expand Down Expand Up @@ -81,8 +82,8 @@ function formReducer(state: FormState, action: FormAction): FormState {
export function useArtworkSubmissionForm() {
const { connectedProfile } = useAuth();

// Import the pre-computed initial values
const { initialTraits } = require("@/components/waves/memes/traits/schema");
// Pre-compute initial values for traits without triggering circular dependencies
const initialTraits = getInitialTraitsValues();

// Create the initial state
const initialState: FormState = {
Expand Down
5 changes: 1 addition & 4 deletions components/waves/memes/submission/validation/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
export * from './validationTypes';
export * from './validationRules';
export * from './traitsValidation';
export * from './validationHooks';
export * from './validationHooks';
12 changes: 11 additions & 1 deletion components/waves/memes/traits/BooleanTrait.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
"use client";

import React, { useRef, useEffect, useCallback } from "react";
import { BooleanTraitProps } from "./types";
import type { TraitsData } from "../submission/types/TraitsData";
import { TraitWrapper } from "./TraitWrapper";

type BooleanTraitProps = {
readonly label: string;
readonly field: keyof TraitsData;
readonly className?: string;
readonly error?: string | null;
readonly onBlur?: (field: keyof TraitsData) => void;
readonly traits: TraitsData;
readonly updateBoolean: (field: keyof TraitsData, value: boolean) => void;
};

/**
* Simplified BooleanTrait component using a ref-based approach
* Similar to our solution for text and number inputs
Expand Down
13 changes: 12 additions & 1 deletion components/waves/memes/traits/DropdownTrait.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
"use client";

import type { TraitsData } from "../submission/types/TraitsData";
import React, { useCallback, useRef } from "react";
import { DropdownTraitProps } from "./types";
import { TraitWrapper } from "./TraitWrapper";

interface DropdownTraitProps {
readonly label: string;
readonly field: keyof TraitsData;
readonly className?: string;
readonly error?: string | null;
readonly onBlur?: (field: keyof TraitsData) => void;
readonly options: readonly string[];
readonly traits: TraitsData;
readonly updateText: (field: keyof TraitsData, value: string) => void;
}

/**
* Simplified DropdownTrait component with direct state management
*/
Expand Down
15 changes: 14 additions & 1 deletion components/waves/memes/traits/NumberTrait.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

import React, { useRef, useCallback, useMemo } from "react";
import { useDebounce } from "react-use";
import { NumberTraitProps } from "./types";
import type { TraitsData } from "../submission/types/TraitsData";
import { TraitWrapper } from "./TraitWrapper";

interface NumberTraitProps {
readonly label: string;
readonly field: keyof TraitsData;
readonly className?: string;
readonly error?: string | null;
readonly onBlur?: (field: keyof TraitsData) => void;
readonly readOnly?: boolean;
readonly min: number;
readonly max: number;
readonly traits: TraitsData;
readonly updateNumber: (field: keyof TraitsData, value: number) => void;
}

/**
* Improved number input component with better UX for handling zero values
* Without min/max constraints
Expand Down
7 changes: 6 additions & 1 deletion components/waves/memes/traits/Section.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React, { memo } from "react";
import { SectionProps } from "./types";

interface SectionProps {
readonly title: string;
readonly children: React.ReactNode;
readonly className?: string;
}

/**
* Base Section component
Expand Down
14 changes: 13 additions & 1 deletion components/waves/memes/traits/TextTrait.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
"use client";

import type { TraitsData } from "../submission/types/TraitsData";
import React, { useRef, useCallback, useMemo } from "react";
import { useDebounce } from "react-use";
import { TextTraitProps } from "./types";
import { TraitWrapper } from "./TraitWrapper";

type TextTraitProps = {
readonly label: string;
readonly field: keyof TraitsData;
readonly traits: TraitsData;
readonly updateText: (field: keyof TraitsData, value: string) => void;
readonly readOnly?: boolean;
readonly placeholder?: string;
readonly className?: string;
readonly error?: string | null;
readonly onBlur?: (field: keyof TraitsData) => void;
};

/**
* Extremely simplified TextTrait component using uncontrolled inputs
* This approach eliminates React render cycles during typing for maximum performance
Expand Down
12 changes: 11 additions & 1 deletion components/waves/memes/traits/TraitWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import React from "react";
import { TraitWrapperProps } from "./types";
import ValidationError from "../submission/ui/ValidationError";
import { CheckCircleIcon } from "@heroicons/react/24/outline";

interface TraitWrapperProps {
readonly label: string;
readonly readOnly?: boolean;
readonly children: React.ReactNode;
readonly isBoolean?: boolean;
readonly className?: string;
readonly error?: string | null;
readonly id?: string;
readonly isFieldFilled?: boolean;
}

export const TraitWrapper: React.FC<TraitWrapperProps> = ({
label,
readOnly = false,
Expand Down
5 changes: 0 additions & 5 deletions components/waves/memes/traits/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
export * from './TextTrait';
export * from './NumberTrait';
export * from './DropdownTrait';
export * from './BooleanTrait';
export * from './Section';
export * from './TraitField';
export * from './types';
5 changes: 1 addition & 4 deletions components/waves/memes/traits/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export function getFormSections(
}

// Get initial trait values
function getInitialTraitsValues(): TraitsData {
export function getInitialTraitsValues(): TraitsData {
const initialValues: Record<string, any> = {
title: "",
description: "",
Expand All @@ -521,9 +521,6 @@ function getInitialTraitsValues(): TraitsData {
return initialValues as TraitsData;
}

// Function to be imported directly in useArtworkSubmissionForm to avoid circular dependency
export const initialTraits: TraitsData = getInitialTraitsValues();

export const MEME_TRAITS_SORT_ORDER = [
"artist",
"memeName",
Expand Down
53 changes: 0 additions & 53 deletions components/waves/memes/traits/types.ts

This file was deleted.

4 changes: 2 additions & 2 deletions services/websocket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import { publicEnv } from "@/config/env";

// Types
export * from "./WebSocketTypes";
// Types (re-export only the publicly consumed ones)
Comment thread
simo6529 marked this conversation as resolved.
export type { WebSocketConfig } from "./WebSocketTypes";

// Context and Provider
// Hooks
Expand Down