Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Rewrite Ticker View to TypeScript #272

Merged
merged 6 commits into from
Jun 24, 2022
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"react-dom": "^17.0.0",
"react-hook-form": "^7.32.0",
"react-image-lightbox": "^5.1.4",
"react-leaflet": "^2.6.3",
"react-leaflet": "^3.0.0",
"react-leaflet-draw": "^0.19.0",
"react-markdown": "^8.0.3",
"react-moment": "^0.9.7",
Expand All @@ -32,6 +32,7 @@
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.17.12",
"@types/leaflet": "^1.7.11",
"@types/node": "^18.0.0",
"@types/react-dom": "^17.0.17",
"@types/react-router-dom": "^5.0.0",
Expand Down
15 changes: 2 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC } from 'react'
import { QueryClient, QueryClientProvider } from 'react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
import { BrowserRouter, Route, Switch, useParams } from 'react-router-dom'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import HomeView from './views/HomeView'
import LoginView from './views/LoginView'
import SettingsView from './views/SettingsView'
Expand All @@ -11,17 +11,6 @@ import 'semantic-ui-css/semantic.min.css'
import './index.css'
import '../leaflet.config.js'

interface TickerViewParams {
tickerId: string
}

//TODO: Can be removed if TickerView is rewritten
const TickerViewWrapper: FC = () => {
const { tickerId } = useParams<TickerViewParams>()

return <TickerView id={tickerId} />
}

const App: FC = () => {
const queryClient = new QueryClient()

Expand All @@ -31,7 +20,7 @@ const App: FC = () => {
<Switch>
<Route component={HomeView} exact path="/" />
<Route component={LoginView} exact path="/login" />
<Route component={TickerViewWrapper} path="/ticker/:tickerId" />
<Route component={TickerView} path="/ticker/:tickerId" />
<Route component={UsersView} path="/users" />
<Route component={SettingsView} path="/settings" />
</Switch>
Expand Down
43 changes: 0 additions & 43 deletions src/api/Message.js

This file was deleted.

56 changes: 56 additions & 0 deletions src/api/Message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ApiUrl, Response } from './Api'
import AuthSingleton from '../components/AuthService'

const Auth = AuthSingleton.getInstance()

interface MessagesResponseData {
messages: Array<Message>
}

interface MessageResponseData {
message: Message
}

export interface Message {
id: number
ticker: number
text: string
creation_date: Date
tweet_id: string
tweet_user: string
geo_information: string
// TODO
attachments: any[]
}

export function getMessages(
ticker: number
): Promise<Response<MessagesResponseData>> {
return Auth.fetch(`${ApiUrl}/admin/tickers/${ticker}/messages`)
}

// TODO: any
export function postMessage(
ticker: string,
text: string,
geoInformation: any,
attachments: any[]
): Promise<Response<MessageResponseData>> {
return Auth.fetch(`${ApiUrl}/admin/tickers/${ticker}/messages`, {
body: JSON.stringify({
text: text,
geo_information: geoInformation,
attachments: attachments,
}),
method: 'POST',
})
}

export function deleteMessage(
ticker: string,
message: string
): Promise<Response<any>> {
return Auth.fetch(`${ApiUrl}/admin/tickers/${ticker}/messages/${message}`, {
method: 'DELETE',
})
}
194 changes: 0 additions & 194 deletions src/components/Message.js

This file was deleted.

Loading