Skip to content

Commit

Permalink
Merge pull request #923 from stakwork/hotfix/revert-add-content
Browse files Browse the repository at this point in the history
fix: revert add content modal changes
  • Loading branch information
Rassl authored Feb 14, 2024
2 parents fcce125 + dd045ee commit 026d553
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 68 deletions.
52 changes: 4 additions & 48 deletions src/components/AddContentModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ export type FormData = {
latitude: string
}

interface ApiResponse {
status: number
source?: string
content?: string
}

interface ApiError {
status: number
message?: string
}

const handleSubmitForm = async (
data: FieldValues,
close: () => void,
Expand Down Expand Up @@ -159,8 +148,6 @@ export const AddContentModal = () => {
const form = useForm<FormData>({ mode: 'onChange' })
const { watch, setValue, reset } = form
const [loading, setLoading] = useState(false)
const [isSourceRes, setIsSourceRes] = useState(false)
const [isContentRes, setIsContentRes] = useState(false)

useEffect(
() => () => {
Expand Down Expand Up @@ -188,38 +175,8 @@ export const AddContentModal = () => {
close()
}

const onNextStep = async () => {
if (currentStep === 0) {
try {
const data = { source }

const response = (await api.post('/validate_content', JSON.stringify(data))) as ApiResponse

if (response.status === 404 || response.status === 400) {
notify('Please enter a valid URL')
reset()

return
}

if (response.source) {
setIsSourceRes(true)
setCurrentStep(currentStep + 1)
}

if (response.content) {
setIsContentRes(true)
setCurrentStep(currentStep + 1)
}
} catch (e) {
const error = e as ApiError

if (error.status === 404 || error.status === 400) {
notify('Please enter a valid URL')
reset()
}
}
}
const onNextStep = () => {
setCurrentStep(currentStep + 1)
}

const onPrevStep = () => {
Expand All @@ -245,10 +202,9 @@ export const AddContentModal = () => {
{currentStep === 0 && <SourceStep allowNextStep={isValidSource} onNextStep={onNextStep} type={type} />}
{currentStep === 1 && (
<>
{isSourceRes && (
{!isSource(type) ? (
<LocationStep form={form} latitude={latitude} longitude={longitude} onNextStep={onNextStep} />
)}
{isContentRes && (
) : (
<SourceTypeStep onNextStep={onNextStep} onPrevStep={onPrevStep} type={type} value={sourceValue} />
)}
</>
Expand Down
2 changes: 0 additions & 2 deletions src/components/App/SideBar/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export const Image = () => {

const imageName = selectedNode?.name

console.log(selectedNode)

return (
<Flex direction="column" px={24} py={16}>
<Avatar data-testid="person-image" size={80} src={selectedNode?.source_link || ''} type="image" />
Expand Down
9 changes: 5 additions & 4 deletions src/components/App/SideBar/Relevance/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from '@mui/material'
import { useCallback, useMemo, useRef, useState } from 'react'
import { memo, useCallback, useMemo, useRef, useState } from 'react'
import styled from 'styled-components'
import { ScrollView } from '~/components/ScrollView'
import { Flex } from '~/components/common/Flex'
Expand All @@ -15,7 +15,8 @@ type Props = {
isSearchResult: boolean
}

export const Relevance = ({ isSearchResult }: Props) => {
// eslint-disable-next-line no-underscore-dangle
const _Relevance = ({ isSearchResult }: Props) => {
const scrollViewRef = useRef<HTMLDivElement | null>(null)

const pageSize = !isSearchResult ? 10 : 80
Expand All @@ -28,8 +29,6 @@ export const Relevance = ({ isSearchResult }: Props) => {

const filteredNodes = useFilteredNodes()

console.log(filteredNodes)

const startSlice = currentPage * pageSize
const endSlice = startSlice + pageSize

Expand Down Expand Up @@ -115,6 +114,8 @@ export const Relevance = ({ isSearchResult }: Props) => {
)
}

export const Relevance = memo(_Relevance)

const LoadMoreWrapper = styled(Flex)`
flex: 0 0 86px;
`
3 changes: 0 additions & 3 deletions src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,13 @@ export const App = () => {
console.error('Socket connection error:', error)
})

socket.on('connect', () => console.log('connected'))
socket.on('disconnect', () => console.log('disconnected'))
socket.on('newnode', handleNewNode)
}
}, [socket, handleNewNode])

useEffect(
() => () => {
if (socket) {
console.log('disc')
socket.disconnect()
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const Body = () => {
const [topicIsLoading, setTopicIsLoading] = useState(false)
const [selectedTopic, setSelectedTopic] = useState<Topic | null>(null)

console.log(topicIsLoading)

const [actualNode, setActualNode] = useState<null | Topic>()

const selectedNode = useSelectedNode()
Expand All @@ -45,7 +43,6 @@ export const Body = () => {
setActualNode(node)
} catch (error) {
console.log(error)

Check warning on line 45 in src/components/ModalsContainer/AddNodeEdgeModal/Body/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
console.log(error)
} finally {
setTopicIsLoading(false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const DropdownSearch: React.FC<Props> = ({ onSelect, selectedTopic }) =>
try {
const responseData: FetchTopicResponse = await getTopicsData(filters)

console.log(responseData.data)

setOptions(responseData.data)
} catch (error) {
setOptions([])
Expand Down
2 changes: 0 additions & 2 deletions src/components/SettingsModal/SettingsView/General/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const General: FC<Props> = ({ initialValues }) => {
try {
const res = (await postAboutData(data)) as Awaited<{ status: string }>

console.log(res)

if (res.status === 'success') {
setAppMetaData(data)
}
Expand Down
2 changes: 0 additions & 2 deletions src/components/SettingsModal/SettingsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export const SettingsView: React.FC<Props> = ({ onClose }) => {
const [isAdmin, pubKey] = useUserStore((s) => [s.isAdmin, s.setPubKey, s.pubKey])
const appMetaData = useAppStore((s) => s.appMetaData)

console.log(appMetaData)

const getSettingsLabel = () => (isAdmin ? 'Admin Settings' : 'Settings')

const SettingsHeader = ({ children }: { children: React.ReactNode }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const DropdownSearch: React.FC<Props> = ({ onSelect, selectedTopic }) =>
try {
const responseData: FetchTopicResponse = await getTopicsData(filters)

console.log(responseData.data)

setOptions(responseData.data)
} catch (error) {
setOptions([])
Expand Down

0 comments on commit 026d553

Please sign in to comment.