Skip to content

Commit

Permalink
Merge pull request #228 from gruz0/refactor/remove-feedback-form
Browse files Browse the repository at this point in the history
Remove feedbacks
  • Loading branch information
gruz0 authored Jan 17, 2025
2 parents 92ca80f + 67ab025 commit c761eea
Show file tree
Hide file tree
Showing 26 changed files with 51 additions and 626 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export IDEA_SERVICE_API_BASE="http://localhost:3000/api"
# Used to interact with Concept API from the backend side.
export CONCEPT_SERVICE_API_BASE="http://localhost:3000/api"

# Used to interact with Feedback API from the backend side.
export FEEDBACK_SERVICE_API_BASE="http://localhost:3000/api"

# Maximum number of allowed requests per timeframe for creating ideas. Default: 30.
export CREATE_IDEA_LIMITER_LIMIT=30

Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ ARG DOMAIN \
CREATE_IDEA_LIMITER_LIMIT \
CREATE_IDEA_LIMITER_TIMEFRAME \
IDEA_SERVICE_API_BASE \
CONCEPT_SERVICE_API_BASE \
FEEDBACK_SERVICE_API_BASE
CONCEPT_SERVICE_API_BASE

# Set environment variables for the build
ENV NODE_ENV=production \
Expand All @@ -44,8 +43,7 @@ ENV NODE_ENV=production \
CREATE_IDEA_LIMITER_LIMIT=$CREATE_IDEA_LIMITER_LIMIT \
CREATE_IDEA_LIMITER_TIMEFRAME=$CREATE_IDEA_LIMITER_TIMEFRAME \
IDEA_SERVICE_API_BASE=$IDEA_SERVICE_API_BASE \
CONCEPT_SERVICE_API_BASE=$CONCEPT_SERVICE_API_BASE \
FEEDBACK_SERVICE_API_BASE=$FEEDBACK_SERVICE_API_BASE
CONCEPT_SERVICE_API_BASE=$CONCEPT_SERVICE_API_BASE

RUN npm run build && \
rm -rf .next/cache && \
Expand Down
1 change: 0 additions & 1 deletion docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ services:
- CREATE_IDEA_LIMITER_TIMEFRAME=${CREATE_IDEA_LIMITER_TIMEFRAME}
- IDEA_SERVICE_API_BASE=${IDEA_SERVICE_API_BASE}
- CONCEPT_SERVICE_API_BASE=${CONCEPT_SERVICE_API_BASE}
- FEEDBACK_SERVICE_API_BASE=${FEEDBACK_SERVICE_API_BASE}
- NEXT_PUBLIC_URL=${NEXT_PUBLIC_URL}
env_file: .env
stdin_open: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the `feedbacks` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "feedbacks";
PRAGMA foreign_keys=on;
9 changes: 0 additions & 9 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,3 @@ model TargetAudience {
@@map("target_audiences")
}

model Feedback {
id String @id @default(uuid())
payload String
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
@@map("feedbacks")
}
62 changes: 0 additions & 62 deletions src/app/api/feedback/ideas/route.ts

This file was deleted.

52 changes: 0 additions & 52 deletions src/app/api/ideas/[id]/feedback/route.ts

This file was deleted.

97 changes: 8 additions & 89 deletions src/app/ideas/[id]/IdeaAnalysisReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useRouter } from 'next/navigation'
import { usePlausible } from 'next-plausible'
import React, { useEffect, useState } from 'react'
import BackToTopButton from '@/components/BackToTopButton'
import FeedbackForm from '@/components/FeedbackForm'
import HorizontalLine from '@/components/HorizontalLine'
import MessageBox from '@/components/MessageBox'
import { Goals } from '@/lib/goals'
Expand Down Expand Up @@ -114,8 +113,6 @@ export const IdeaAnalysisReport = ({ data }: Props) => {
const plausible = usePlausible()
const router = useRouter()

const [showFeedbackForm, setShowFeedbackForm] = useState(false)
const [wrongSection, setWrongSection] = useState<string | null>(null)
const [readyForReport, setReadyForReport] = useState<boolean>(false)

useEffect(() => {
Expand Down Expand Up @@ -182,53 +179,6 @@ export const IdeaAnalysisReport = ({ data }: Props) => {
}
}

const onReport = (section: string) => {
if (!section) {
return
}

setWrongSection(section)

setShowFeedbackForm(true)
}

const handleFeedbackSubmit = async (feedback: string, contact: string) => {
if (!wrongSection) {
return
}

try {
setWrongSection(null)
setShowFeedbackForm(false)

const res = await fetch(`/api/ideas/${data.id}/feedback`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
section: wrongSection,
feedback: feedback.trim(),
contact: contact.trim(),
}),
})

if (res.status === 201) {
setWrongSection(null)
setShowFeedbackForm(false)
} else {
const errorData = await res.json()

alert(errorData.error || 'Something went wrong.')

setWrongSection(null)
setShowFeedbackForm(false)
}
} catch (error) {
alert(`Error submitting report: ${error}`)
}
}

return (
<div className="p-4 md:p-6 lg:p-8">
<div className="flex flex-col md:flex-row">
Expand Down Expand Up @@ -262,21 +212,9 @@ export const IdeaAnalysisReport = ({ data }: Props) => {

<HorizontalLine />

{showFeedbackForm && (
<div className="fixed inset-0 flex items-center justify-center bg-gray-800/50">
<div className="max-w-2xl rounded bg-white p-4 shadow-md md:p-8 dark:bg-gray-900">
<FeedbackForm
onSubmit={handleFeedbackSubmit}
onClose={() => setShowFeedbackForm(false)}
/>
</div>
</div>
)}

<AboutReport />

<SectionContext
onReport={onReport}
data={{
problem: data.problem,
marketExistence: data.marketExistence,
Expand All @@ -285,59 +223,40 @@ export const IdeaAnalysisReport = ({ data }: Props) => {

<HorizontalLine />

<SectionMarketAnalysis
onReport={onReport}
data={data.marketAnalysis}
/>
<SectionMarketAnalysis data={data.marketAnalysis} />

<HorizontalLine />

<SectionCompetitors
onReport={onReport}
data={data.competitorAnalysis}
/>
<SectionCompetitors data={data.competitorAnalysis} />

<HorizontalLine />

<SectionValueProposition
onReport={onReport}
data={data.valueProposition}
/>
<SectionValueProposition data={data.valueProposition} />

<HorizontalLine />

<SectionTargetAudiences
onReport={onReport}
data={data.targetAudiences}
/>
<SectionTargetAudiences data={data.targetAudiences} />

<HorizontalLine />

<SectionSWOTAnalysis onReport={onReport} data={data.swotAnalysis} />
<SectionSWOTAnalysis data={data.swotAnalysis} />

<HorizontalLine />

<SectionElevatorPitch
onReport={onReport}
data={data.elevatorPitches}
/>
<SectionElevatorPitch data={data.elevatorPitches} />

<HorizontalLine />

<SectionProductNames onReport={onReport} data={data.productNames} />
<SectionProductNames data={data.productNames} />

<HorizontalLine />

<SectionGoogleTrends
onReport={onReport}
data={data.googleTrendsKeywords}
/>
<SectionGoogleTrends data={data.googleTrendsKeywords} />

<HorizontalLine />

<SectionContentIdeas
ideaId={data.id}
onReport={onReport}
data={data.contentIdeasForMarketing}
/>

Expand Down
21 changes: 3 additions & 18 deletions src/app/ideas/[id]/components/SectionCompetitors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import SectionWrapper from '@/components/SectionWrapper'
import SimpleUnorderedList from '@/components/SimpleUnorderedList'

interface SectionCompetitorsProps {
onReport: (section: string) => void
data: {
competitors: Array<{
name: string
Expand All @@ -31,10 +30,7 @@ interface SectionCompetitorsProps {
} | null
}

const SectionCompetitors: React.FC<SectionCompetitorsProps> = ({
onReport,
data,
}) => {
const SectionCompetitors: React.FC<SectionCompetitorsProps> = ({ data }) => {
const [isExpanded, setIsExpanded] = useState<boolean>(false)

return (
Expand Down Expand Up @@ -63,9 +59,6 @@ const SectionCompetitors: React.FC<SectionCompetitorsProps> = ({
<Section
key={competitor.url}
header={`${idx + 1}. ${competitor.name}`}
onReport={() =>
onReport(`competitor_analysis.competitors.${idx}`)
}
>
<div className="flex flex-col rounded-lg border border-gray-200 bg-gray-50 p-4 pb-0 hover:shadow-lg md:p-6 lg:pb-0 dark:bg-gray-900/50">
<h3 className="mb-2 text-lg font-semibold md:text-xl">
Expand Down Expand Up @@ -117,10 +110,7 @@ const SectionCompetitors: React.FC<SectionCompetitorsProps> = ({
</Section>
))}

<Section
header="Comparison:"
onReport={() => onReport('competitor_analysis.comparison')}
>
<Section header="Comparison:">
<h3 className="mb-2 text-lg font-semibold md:text-xl">
Strengths:
</h3>
Expand All @@ -132,12 +122,7 @@ const SectionCompetitors: React.FC<SectionCompetitorsProps> = ({
<SimpleUnorderedList items={data.comparison.weaknesses} />
</Section>

<Section
header="Differentiation Suggestions:"
onReport={() =>
onReport('competitor_analysis.differentiation_suggestions')
}
>
<Section header="Differentiation Suggestions:">
<SimpleUnorderedList items={data.differentiationSuggestions} />
</Section>
</>
Expand Down
Loading

0 comments on commit c761eea

Please sign in to comment.