mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-08 04:15:18 +02:00
Created WeatherWidget
This commit is contained in:
parent
38f5d3b66a
commit
e170f56a03
11 changed files with 462 additions and 57 deletions
|
@ -1,7 +1,7 @@
|
|||
import axios from 'axios';
|
||||
import { Dispatch } from 'redux';
|
||||
import { ActionTypes } from './actionTypes';
|
||||
import { App, AppResponse, NewApp } from '../../interfaces/App';
|
||||
import { App, ApiResponse, NewApp } from '../../interfaces';
|
||||
|
||||
export interface GetAppsAction<T> {
|
||||
type: ActionTypes.getApps | ActionTypes.getAppsSuccess | ActionTypes.getAppsError;
|
||||
|
@ -15,7 +15,7 @@ export const getApps = () => async (dispatch: Dispatch) => {
|
|||
});
|
||||
|
||||
try {
|
||||
const res = await axios.get<AppResponse<App[]>>('/api/apps');
|
||||
const res = await axios.get<ApiResponse<App[]>>('/api/apps');
|
||||
|
||||
dispatch<GetAppsAction<App[]>>({
|
||||
type: ActionTypes.getAppsSuccess,
|
||||
|
@ -36,7 +36,7 @@ export interface PinAppAction {
|
|||
|
||||
export const pinApp = (id: number, isPinned: boolean) => async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const res = await axios.put<AppResponse<App>>(`/api/apps/${id}`, { isPinned: !isPinned });
|
||||
const res = await axios.put<ApiResponse<App>>(`/api/apps/${id}`, { isPinned: !isPinned });
|
||||
|
||||
dispatch<PinAppAction>({
|
||||
type: ActionTypes.pinApp,
|
||||
|
@ -54,7 +54,7 @@ export interface AddAppAction {
|
|||
|
||||
export const addApp = (formData: NewApp) => async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const res = await axios.post<AppResponse<App>>('/api/apps', formData);
|
||||
const res = await axios.post<ApiResponse<App>>('/api/apps', formData);
|
||||
|
||||
dispatch<AddAppAction>({
|
||||
type: ActionTypes.addAppSuccess,
|
||||
|
@ -72,7 +72,7 @@ export interface DeleteAppAction {
|
|||
|
||||
export const deleteApp = (id: number) => async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const res = await axios.delete<AppResponse<{}>>(`/api/apps/${id}`);
|
||||
const res = await axios.delete<ApiResponse<{}>>(`/api/apps/${id}`);
|
||||
|
||||
dispatch<DeleteAppAction>({
|
||||
type: ActionTypes.deleteApp,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue