Skip to content

Commit

Permalink
Revert "[Graph Mindset] Add Seed Episodes logic to landing page"
Browse files Browse the repository at this point in the history
  • Loading branch information
Rassl authored Dec 1, 2024
1 parent 951a1fb commit 4df20bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 113 deletions.
108 changes: 4 additions & 104 deletions src/components/mindset/components/LandingPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { useEffect, useState } from 'react'
import { useState } from 'react'
import { FieldValues } from 'react-hook-form'
import styled from 'styled-components'
import { Flex } from '~/components/common/Flex'
import { NODE_ADD_ERROR } from '~/constants'
import { api } from '~/network/api'
import { useDataStore } from '~/stores/useDataStore'
import { useMindsetStore } from '~/stores/useMindsetStore'
import { NodeExtended, SubmitErrRes } from '~/types'
import { SubmitErrRes } from '~/types'
import { colors } from '~/utils/colors'
import { ChevronRight } from '../Icon/ChevronRight'
import { isValidMediaUrl } from './utils'
import ReactPlayer from 'react-player'
import { getAboutData, getNode } from '~/network/fetchSourcesData'
import { Avatar } from '~/components/common/Avatar'

export type FormData = {
input: string
Expand All @@ -22,12 +19,6 @@ export type FormData = {
latitude: string
}

const Media = ({ mediaLink }: { mediaLink: string }) => (
<PlayerWrapper>
<ReactPlayer controls height="121px" url={`${mediaLink}`} width="173px" />
</PlayerWrapper>
)

const handleSubmitForm = async (data: FieldValues): Promise<SubmitErrRes> => {
const endPoint = 'add_node'

Expand All @@ -49,32 +40,11 @@ const handleSubmitForm = async (data: FieldValues): Promise<SubmitErrRes> => {

export const LandingPage = () => {
const [inputValue, setInputValue] = useState('')
const [nodeData, setNodeData] = useState<NodeExtended[]>([])
const [error, setError] = useState(false)
const [requestError, setRequestError] = useState<string>('')
const { setRunningProjectId } = useDataStore((s) => s)
const { setSelectedEpisodeId, setSelectedEpisodeLink } = useMindsetStore((s) => s)

useEffect(() => {
const run = async () => {
const response = await getAboutData()

if (!response?.seed_questions) {
setNodeData([])

return
}

const refIds = response?.seed_questions.slice(0, 3)

const nodeResponses = await Promise.all(refIds.map((id: string) => getNode(id)))

setNodeData(nodeResponses)
}

run()
}, [])

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { value } = e.target

Expand Down Expand Up @@ -134,19 +104,6 @@ export const LandingPage = () => {
</IconWrapper>
</InputWrapper>
{requestError && <div>{requestError}</div>}
<SeedQuestionsWrapper>
{nodeData.map((node) => (
<SeedQuestion key={node?.properties?.episode_title}>
{node?.properties?.source_link && <Media mediaLink={node?.properties?.source_link} />}
{!node?.properties?.source_link && node?.properties?.image_url && (
<Cover>
<Avatar size={120} src={node?.properties?.image_url || ''} type="clip" />
</Cover>
)}
{node?.properties?.episode_title && <EpisodeTitle>{node?.properties?.episode_title}</EpisodeTitle>}
</SeedQuestion>
))}
</SeedQuestionsWrapper>
</Wrapper>
)
}
Expand Down Expand Up @@ -180,7 +137,7 @@ const Title = styled(Flex)`

const Input = styled.input<{ error?: boolean }>`
width: 100%;
max-width: 648px;
max-width: 450px;
padding: 12px 28px 12px 16px;
border-radius: 100px;
border: 1px solid ${(props) => (props.error ? 'red' : colors.DIVIDER_4)};
Expand All @@ -201,7 +158,7 @@ const Input = styled.input<{ error?: boolean }>`

const InputWrapper = styled.div`
position: relative;
width: 648px;
width: 450px;
display: flex;
align-items: center;
`
Expand All @@ -221,60 +178,3 @@ const IconWrapper = styled.div<{ error?: boolean }>`
color: ${colors.GRAY6};
}
`

const SeedQuestionsWrapper = styled.div`
display: flex;
align-items: center;
gap: 16px;
margin-top: 20px;
max-width: 648px;
height: 237px;
`

const SeedQuestion = styled.div`
background: ${colors.BG1};
width: 205px;
height: 200px;
color: ${colors.white};
padding: 16px;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: start;
flex-direction: column;
text-align: left;
&:hover {
background: ${colors.SEEDQUESTION_HOVER};
}
&:active {
background: ${colors.SEEDQUESTION};
}
svg {
width: 20px;
height: 20px;
}
path {
fill: ${colors.modalWhiteOverlayBg};
}
`

const PlayerWrapper = styled.div`
width: 100%;
cursor: pointer;
`

const EpisodeTitle = styled.p`
font-family: Inter;
font-weight: 500;
font-size: 16px;
`

const Cover = styled(Flex)`
width: 100%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
`
10 changes: 1 addition & 9 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,7 @@ export type NodeExtended = Node & {
latitude?: number
coordinates?: Coordinates
audio?: Audio[]
properties?: {
date?: number
episode_title?: string
image_url?: string
media_url?: string
pubkey?: string
source_link?: string
status?: string
}
properties?: { [key: string]: never | undefined }
}

export type Link<T = string> = {
Expand Down

0 comments on commit 4df20bc

Please sign in to comment.