Skip to content

Commit

Permalink
Removed API weather controller
Browse files Browse the repository at this point in the history
Update package.json

Update store.ts

Update setupTests.config.tsx

Update helpers.test.ts

Update helpers.ts
  • Loading branch information
miksrv committed Aug 31, 2024
1 parent 33cb667 commit be585e6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 120 deletions.
20 changes: 11 additions & 9 deletions client/api/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import { API } from './api'
import applicationSlice from './applicationSlice'
import authSlice from './authSlice'

export const reducer = {
application: applicationSlice,
auth: authSlice,
loginModal: loginModalSlice,
sidebar: sidebarSlice,

[API.reducerPath]: API.reducer,
[APIMeteo.reducerPath]: APIMeteo.reducer
}

export const store = () =>
configureStore({
devTools: process.env.NODE_ENV !== 'production',
middleware: (gDM) => gDM().concat(API.middleware, APIMeteo.middleware),
reducer: {
application: applicationSlice,
auth: authSlice,
loginModal: loginModalSlice,
sidebar: sidebarSlice,

[API.reducerPath]: API.reducer,
[APIMeteo.reducerPath]: APIMeteo.reducer
}
reducer
})

export type AppStore = ReturnType<typeof store>
Expand Down
2 changes: 1 addition & 1 deletion client/functions/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('helpers', () => {

describe('timeAgo function', () => {
it('returns "обновлено недавно" for null or non-positive seconds', () => {
expect(timeAgo(null)).toBe('обновлено недавно')
expect(timeAgo(undefined)).toBe('')
expect(timeAgo(0)).toBe('обновлено недавно')
expect(timeAgo(-5)).toBe('обновлено недавно')
})
Expand Down
3 changes: 2 additions & 1 deletion client/functions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ export const dateAddMonth = (
export const timeAgo = (seconds?: number | string): string => {
let sec = Number(seconds)

if (!sec || sec <= 0) return ''
if (!sec || sec < 0) return ''
if (sec === 0) return 'обновлено недавно'

let h = (sec / 3600) ^ 0
let m = ((sec - h * 3600) / 60) ^ 0
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astronomy-portal",
"version": "3.4.6",
"version": "3.4.7",
"private": true,
"engines": {
"node": ">=20.11.0"
Expand Down
4 changes: 2 additions & 2 deletions client/setupTests.config.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API } from '@/api/api'
import { RootState, reducers } from '@/api/store'
import { RootState, reducer } from '@/api/store'
import { configureStore } from '@reduxjs/toolkit'
import '@testing-library/jest-dom'
import { render } from '@testing-library/react'
Expand All @@ -20,7 +20,7 @@ export const testStore = (state: Partial<RootState>) => {
return configureStore({
middleware: (gDM) => gDM().concat(API.middleware) as any,
preloadedState: state,
reducer: reducers as any
reducer: reducer as any
})
}

Expand Down
3 changes: 0 additions & 3 deletions server/app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
/**
* @var RouteCollection $routes
*/
$routes->get('weather/current', 'Weather::current');
$routes->get('weather/statistic', 'Weather::statistic');
$routes->options('weather/(:any)', 'Weather');

// Events
$routes->get('events', 'Events::list');
Expand Down
103 changes: 0 additions & 103 deletions server/app/Controllers/Weather.php

This file was deleted.

0 comments on commit be585e6

Please sign in to comment.