1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-27 14:59:37 +02:00

add bookmark sorting (#3)

This commit is contained in:
François Darveau 2021-06-26 16:22:54 -04:00 committed by François Darveau
parent 2530f2d089
commit 8fab9bc06c
5 changed files with 21 additions and 25 deletions

View file

@ -25,7 +25,7 @@ interface ComponentProps {
export enum ContentType {
category,
app
app,
}
const Apps = (props: ComponentProps): JSX.Element => {
@ -34,24 +34,26 @@ 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<Category>({
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<App>({
name: 'string',
url: 'string',
name: "string",
url: "string",
categoryId: -1,
icon: 'string',
icon: "string",
isPinned: false,
orderId: 0,
id: 0,

View file

@ -191,7 +191,9 @@ const BookmarkTable = (props: ComponentProps): JSX.Element => {
</div>
<div
className={classes.TableAction}
onClick={() => props.pinBookmarkCategory(category)}
onClick={() =>
props.pinBookmarkCategory(category)
}
onKeyDown={(e) =>
keyboardActionHandler(
e,

View file

@ -50,10 +50,10 @@ const Bookmarks = (props: ComponentProps): JSX.Element => {
updatedAt: new Date(),
});
const [bookmarkInUpdate, setBookmarkInUpdate] = useState<Bookmark>({
name: "string",
url: "string",
name: "",
url: "",
categoryId: -1,
icon: "string",
icon: "",
isPinned: false,
orderId: 0,
id: 0,

View file

@ -88,7 +88,9 @@ 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;
@ -243,16 +245,6 @@ 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<App>(category.apps, action.payload);
// });
// return {
// ...state,
// categories: tmpCategories,
// };
const sortedApps = sortData<App>(state.apps, action.payload);
return {