mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-27 23:09:35 +02:00
add bookmark sorting (#3)
This commit is contained in:
parent
2530f2d089
commit
8fab9bc06c
5 changed files with 21 additions and 25 deletions
|
@ -25,7 +25,7 @@ interface ComponentProps {
|
||||||
|
|
||||||
export enum ContentType {
|
export enum ContentType {
|
||||||
category,
|
category,
|
||||||
app
|
app,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Apps = (props: ComponentProps): JSX.Element => {
|
const Apps = (props: ComponentProps): JSX.Element => {
|
||||||
|
@ -34,24 +34,26 @@ const Apps = (props: ComponentProps): JSX.Element => {
|
||||||
const [modalIsOpen, setModalIsOpen] = useState(false);
|
const [modalIsOpen, setModalIsOpen] = useState(false);
|
||||||
const [formContentType, setFormContentType] = useState(ContentType.category);
|
const [formContentType, setFormContentType] = useState(ContentType.category);
|
||||||
const [isInEdit, setIsInEdit] = useState(false);
|
const [isInEdit, setIsInEdit] = useState(false);
|
||||||
const [tableContentType, setTableContentType] = useState(ContentType.category);
|
const [tableContentType, setTableContentType] = useState(
|
||||||
|
ContentType.category
|
||||||
|
);
|
||||||
const [isInUpdate, setIsInUpdate] = useState(false);
|
const [isInUpdate, setIsInUpdate] = useState(false);
|
||||||
const [categoryInUpdate, setCategoryInUpdate] = useState<Category>({
|
const [categoryInUpdate, setCategoryInUpdate] = useState<Category>({
|
||||||
name: '',
|
name: "",
|
||||||
id: -1,
|
id: -1,
|
||||||
isPinned: false,
|
isPinned: false,
|
||||||
orderId: 0,
|
orderId: 0,
|
||||||
type: 'apps',
|
type: "apps",
|
||||||
apps: [],
|
apps: [],
|
||||||
bookmarks: [],
|
bookmarks: [],
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date()
|
updatedAt: new Date(),
|
||||||
})
|
});
|
||||||
const [appInUpdate, setAppInUpdate] = useState<App>({
|
const [appInUpdate, setAppInUpdate] = useState<App>({
|
||||||
name: 'string',
|
name: "string",
|
||||||
url: 'string',
|
url: "string",
|
||||||
categoryId: -1,
|
categoryId: -1,
|
||||||
icon: 'string',
|
icon: "string",
|
||||||
isPinned: false,
|
isPinned: false,
|
||||||
orderId: 0,
|
orderId: 0,
|
||||||
id: 0,
|
id: 0,
|
||||||
|
|
|
@ -191,7 +191,9 @@ const BookmarkTable = (props: ComponentProps): JSX.Element => {
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={classes.TableAction}
|
className={classes.TableAction}
|
||||||
onClick={() => props.pinBookmarkCategory(category)}
|
onClick={() =>
|
||||||
|
props.pinBookmarkCategory(category)
|
||||||
|
}
|
||||||
onKeyDown={(e) =>
|
onKeyDown={(e) =>
|
||||||
keyboardActionHandler(
|
keyboardActionHandler(
|
||||||
e,
|
e,
|
||||||
|
|
|
@ -50,10 +50,10 @@ const Bookmarks = (props: ComponentProps): JSX.Element => {
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
});
|
});
|
||||||
const [bookmarkInUpdate, setBookmarkInUpdate] = useState<Bookmark>({
|
const [bookmarkInUpdate, setBookmarkInUpdate] = useState<Bookmark>({
|
||||||
name: "string",
|
name: "",
|
||||||
url: "string",
|
url: "",
|
||||||
categoryId: -1,
|
categoryId: -1,
|
||||||
icon: "string",
|
icon: "",
|
||||||
isPinned: false,
|
isPinned: false,
|
||||||
orderId: 0,
|
orderId: 0,
|
||||||
id: 0,
|
id: 0,
|
||||||
|
|
|
@ -88,7 +88,9 @@ const pinCategory = (state: State, action: Action): State => {
|
||||||
|
|
||||||
const pinApp = (state: State, action: Action): State => {
|
const pinApp = (state: State, action: Action): State => {
|
||||||
const tmpApps = [...state.apps];
|
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) {
|
if (changedApp) {
|
||||||
changedApp.isPinned = action.payload.isPinned;
|
changedApp.isPinned = action.payload.isPinned;
|
||||||
|
@ -243,16 +245,6 @@ const reorderApps = (state: State, action: Action): State => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortApps = (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);
|
const sortedApps = sortData<App>(state.apps, action.payload);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue