diff --git a/client/src/components/Apps/Apps.tsx b/client/src/components/Apps/Apps.tsx index c7718da..a62a941 100644 --- a/client/src/components/Apps/Apps.tsx +++ b/client/src/components/Apps/Apps.tsx @@ -25,7 +25,7 @@ interface ComponentProps { export enum ContentType { category, - app, + app } const Apps = (props: ComponentProps): JSX.Element => { @@ -34,26 +34,24 @@ const Apps = (props: ComponentProps): JSX.Element => { const [modalIsOpen, setModalIsOpen] = useState(false); const [formContentType, setFormContentType] = useState(ContentType.category); const [isInEdit, setIsInEdit] = useState(false); - const [tableContentType, setTableContentType] = useState( - ContentType.category - ); + const [tableContentType, setTableContentType] = useState(ContentType.category); const [isInUpdate, setIsInUpdate] = useState(false); const [categoryInUpdate, setCategoryInUpdate] = useState({ - name: "", + name: '', id: -1, isPinned: false, orderId: 0, - type: "apps", + type: 'apps', apps: [], bookmarks: [], createdAt: new Date(), - updatedAt: new Date(), - }); + updatedAt: new Date() + }) const [appInUpdate, setAppInUpdate] = useState({ - name: "string", - url: "string", + name: 'string', + url: 'string', categoryId: -1, - icon: "string", + icon: 'string', isPinned: false, orderId: 0, id: 0, diff --git a/client/src/components/Bookmarks/BookmarkTable/BookmarkTable.tsx b/client/src/components/Bookmarks/BookmarkTable/BookmarkTable.tsx index 0fca8fb..7909da5 100644 --- a/client/src/components/Bookmarks/BookmarkTable/BookmarkTable.tsx +++ b/client/src/components/Bookmarks/BookmarkTable/BookmarkTable.tsx @@ -191,9 +191,7 @@ const BookmarkTable = (props: ComponentProps): JSX.Element => {
- props.pinBookmarkCategory(category) - } + onClick={() => props.pinBookmarkCategory(category)} onKeyDown={(e) => keyboardActionHandler( e, diff --git a/client/src/store/actions/app.ts b/client/src/store/actions/app.ts index 91fa3b8..dc25f66 100644 --- a/client/src/store/actions/app.ts +++ b/client/src/store/actions/app.ts @@ -138,30 +138,29 @@ export interface AddAppAction { payload: App; } -export const addApp = - (formData: NewApp | FormData) => async (dispatch: Dispatch) => { - try { - const res = await axios.post>("/api/apps", formData); +export const addApp = (formData: NewApp | FormData) => async (dispatch: Dispatch) => { + try { + const res = await axios.post>("/api/apps", formData); - dispatch({ - type: ActionTypes.createNotification, - payload: { - title: "Success", - message: `App ${res.data.data.name} added`, - }, - }); + dispatch({ + type: ActionTypes.createNotification, + payload: { + title: "Success", + message: `App ${res.data.data.name} added`, + }, + }); - await dispatch({ - type: ActionTypes.addAppSuccess, - payload: res.data.data, - }); + await dispatch({ + type: ActionTypes.addAppSuccess, + payload: res.data.data, + }); - // Sort apps - dispatch(sortApps()); - } catch (err) { - console.log(err); - } - }; + // Sort apps + dispatch(sortApps()); + } catch (err) { + console.log(err); + } +}; /** * PIN CATEGORY diff --git a/client/src/store/reducers/app.ts b/client/src/store/reducers/app.ts index 37eb1c3..e01650a 100644 --- a/client/src/store/reducers/app.ts +++ b/client/src/store/reducers/app.ts @@ -88,9 +88,7 @@ const pinCategory = (state: State, action: Action): State => { const pinApp = (state: State, action: Action): State => { const tmpApps = [...state.apps]; - const changedApp = tmpApps.find( - (app: App) => app.id === action.payload.id - ); + const changedApp = tmpApps.find((app: App) => app.id === action.payload.id); if (changedApp) { changedApp.isPinned = action.payload.isPinned; @@ -245,6 +243,16 @@ const reorderApps = (state: State, action: Action): State => { }; const sortApps = (state: State, action: Action): State => { + // const tmpCategories = [...state.categories]; + + // tmpCategories.forEach((category: Category) => { + // category.apps = sortData(category.apps, action.payload); + // }); + + // return { + // ...state, + // categories: tmpCategories, + // }; const sortedApps = sortData(state.apps, action.payload); return {