Skip to content

Commit

Permalink
fix: build issues and lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Github Actions committed Oct 9, 2023
1 parent 7b57fab commit cd16456
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
23 changes: 12 additions & 11 deletions src/components/App/Helper/TeachMe/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useRef } from 'react'
import styled from 'styled-components'
import { PropagateLoader } from 'react-spinners'
import { toast } from 'react-toastify'
import { Socket } from 'socket.io-client'
Expand All @@ -11,7 +12,7 @@ import useSocket from '~/hooks/useSockets'
import { postTeachMe, postInstagraph } from '~/network/fetchGraphData'
import { useAppStore } from '~/stores/useAppStore'
import { useDataStore } from '~/stores/useDataStore'
import { useTeachStore } from '~/stores/useTeachStore'
import { useTeachStore, InstagraphResponse } from '~/stores/useTeachStore'
import { colors } from '~/utils/colors'
import { AskQuestion } from '../AskQuestion'
import ReactFlow from 'reactflow'
Expand Down Expand Up @@ -46,10 +47,7 @@ export const TeachMe = () => {
)

const handleInstagraph = useCallback(
(response: ResponseType) => {
console.info('instgraph response', response.edges)
console.info('instgraph response', response.nodes)

(response: InstagraphResponse) => {
setInstagraphAnswer(response)

toast(<ToastMessage message="Instagraph is ready" />, {
Expand Down Expand Up @@ -126,9 +124,9 @@ export const TeachMe = () => {
}

return (
<Button kind="big" onClick={() => handleTutorialStart()}>
<ButtonStyled onClick={() => handleTutorialStart()}>
Teach me
</Button>
</ButtonStyled>
)
}

Expand All @@ -140,12 +138,10 @@ export const TeachMeText = () => {
s.hasInstagraphInProgress,
])

console.info('instagraph anwser', instgraphAnswser)

return (
<>
{!hasInstagraphInProgress ? (
<ReactFlow edges={instgraphAnswser.edges} nodes={instgraphAnswser.nodes} />
{!hasInstagraphInProgress && !!instgraphAnswser?.edges && !!instgraphAnswser?.nodes ? (
<ReactFlow edges={instgraphAnswser?.edges} nodes={instgraphAnswser?.nodes} />
) : (
<Flex align="center" justify="center" py={12}>
<Flex align="center" py={12}>
Expand Down Expand Up @@ -176,3 +172,8 @@ export const TeachMeText = () => {
</>
)
}


const ButtonStyled = styled(Button)`
`

36 changes: 24 additions & 12 deletions src/stores/useTeachStore/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import create from 'zustand'

type InstagraphResponse = {
edges: Array[{ direction: string; label: string; properties: object; source: string; target: string; color: string }]
nodes: Array[{
export type InstagraphResponse = {
instagraph: Instagraph
} | null

type Instagraph = {
edges: Array<{
direction: string
label: string
properties: object
source: string
target: string
color: string
id: string
}>
nodes: Array<{
color: string
id: string
data: { label: string }
position: { x: number; y: number }
properties: object
type: string
}]
}
}>
} | null

type TeachStore = {
askedQuestions: string[] | null
askedQuestionsAnswers: string[] | null
teachMeAnswer: string | null
instgraphAnswser: InstagraphResponse
instgraphAnswser: Instagraph
hasQuestionInProgress: boolean
hasTeachingInProgress: boolean
hasInstagraphInProgress: boolean
Expand Down Expand Up @@ -74,11 +86,11 @@ export const useTeachStore = create<TeachStore>((set) => ({
}),
setTeachMeAnswer: (answer: string) => set({ hasTeachingInProgress: false, teachMeAnswer: answer }),
setInstagraphAnswer: (answer: InstagraphResponse) => {
console.info(answer.instagraph)

set({
hasInstagraphInProgress: false,
instgraphAnswser: { edges: answer.instagraph.edges, nodes: answer.instagraph.nodes },
})
if (!!answer?.instagraph?.edges && !!answer?.instagraph?.nodes) {
set({
hasInstagraphInProgress: false,
instgraphAnswser: { edges: answer?.instagraph?.edges, nodes: answer?.instagraph?.nodes },
})
}
},
}))

0 comments on commit cd16456

Please sign in to comment.