Skip to content

Commit

Permalink
Merge pull request #618 from systemli/Fix-eslint-errors
Browse files Browse the repository at this point in the history
🚨 Fix eslint errors
  • Loading branch information
0x46616c6b authored Apr 26, 2024
2 parents 0040e00 + 90f8401 commit 7d220b0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
20 changes: 15 additions & 5 deletions src/api/Message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApiUrl, Response } from './Api'
import { FeatureCollection, Geometry } from 'geojson'

interface MessagesResponseData {
messages: Array<Message>
Expand All @@ -16,8 +17,12 @@ export interface Message {
telegramUrl?: string
mastodonUrl?: string
geoInformation: string
// TODO
attachments: any[]
attachments?: Attachment[]
}

export interface Attachment {
url: string
contentType: string
}

export function useMessageApi(token: string) {
Expand All @@ -43,8 +48,13 @@ export function useMessageApi(token: string) {
}).then(response => response.json())
}

// TODO: any
const postMessage = (ticker: string, text: string, geoInformation: any, attachments: any[]): Promise<Response<MessageResponseData>> => {
const postMessage = (
ticker: string,
text: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
geoInformation: FeatureCollection<Geometry, any>,
attachments: number[]
): Promise<Response<MessageResponseData>> => {
return fetch(`${ApiUrl}/admin/tickers/${ticker}/messages`, {
headers: headers,
body: JSON.stringify({
Expand All @@ -56,7 +66,7 @@ export function useMessageApi(token: string) {
}).then(response => response.json())
}

const deleteMessage = (message: Message): Promise<Response<any>> => {
const deleteMessage = (message: Message): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/tickers/${message.ticker}/messages/${message.id}`, {
headers: headers,
method: 'delete',
Expand Down
8 changes: 4 additions & 4 deletions src/api/Ticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function useTickerApi(token: string) {
'Content-Type': 'application/json',
}

const deleteTicker = (ticker: Ticker): Promise<Response<any>> => {
const deleteTicker = (ticker: Ticker): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/tickers/${ticker.id}`, {
headers: headers,
method: 'delete',
Expand All @@ -92,7 +92,7 @@ export function useTickerApi(token: string) {
}).then(response => response.json())
}

const deleteTickerUser = (ticker: Ticker, user: User): Promise<Response<any>> => {
const deleteTickerUser = (ticker: Ticker, user: User): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/tickers/${ticker.id}/users/${user.id}`, {
headers: headers,
method: 'delete',
Expand All @@ -107,15 +107,15 @@ export function useTickerApi(token: string) {
return fetch(`${ApiUrl}/admin/tickers/${id}`, { headers: headers }).then(response => response.json())
}

const postTicker = (data: any): Promise<Response<TickerResponseData>> => {
const postTicker = (data: Ticker): Promise<Response<TickerResponseData>> => {
return fetch(`${ApiUrl}/admin/tickers`, {
headers: headers,
body: JSON.stringify(data),
method: 'post',
}).then(response => response.json())
}

const putTicker = (data: any, id: number): Promise<Response<TickerResponseData>> => {
const putTicker = (data: Ticker, id: number): Promise<Response<TickerResponseData>> => {
return fetch(`${ApiUrl}/admin/tickers/${id}`, {
headers: headers,
body: JSON.stringify(data),
Expand Down
2 changes: 1 addition & 1 deletion src/api/Upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function useUploadApi(token: string) {
Authorization: `Bearer ${token}`,
}

const postUpload = (formData: any): Promise<Response<UploadeResponseData>> => {
const postUpload = (formData: FormData): Promise<Response<UploadeResponseData>> => {
return fetch(`${ApiUrl}/admin/upload`, {
headers: headers,
body: formData,
Expand Down
2 changes: 1 addition & 1 deletion src/api/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function useUserApi(token: string) {
}).then(response => response.json())
}

const deleteUser = (user: User): Promise<Response<any>> => {
const deleteUser = (user: User): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/users/${user.id}`, {
headers: headers,
method: 'delete',
Expand Down
5 changes: 2 additions & 3 deletions src/lib/leafletFitBoundsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ export const leafletOnDataAddFitToBounds = (event: LeafletEvent) => {

if (
features.length === 1 &&
// type is currently not defined
// @ts-ignore
// @ts-expect-error type is currently not defined
features[0].feature.geometry.type === 'Point'
) {
// @ts-ignore
// @ts-expect-error type is currently not defined
const coords = features[0].feature.geometry.coordinates
leafletLayer._map.setView([coords[1], coords[0]], 13)
} else if (features.length > 1) {
Expand Down

0 comments on commit 7d220b0

Please sign in to comment.