fix: edit story link

This commit is contained in:
MTG2000
2022-09-20 18:48:12 +03:00
parent ac5cde06e8
commit 3f3786c076
2 changed files with 10 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import { NotificationsService } from "src/services/notifications.service";
import { useAppDispatch } from "src/utils/hooks";
import { useReduxEffect } from "src/utils/hooks/useReduxEffect";
import { openModal } from "src/redux/features/modals.slice";
import { createRoute } from "src/utils/routing";
const CONFIRM_DELETE_STORY = createAction<{ confirmed?: boolean }>('DELETE_STORY_CONFIRMED')({})
@@ -31,7 +32,7 @@ export const useUpdateStory = (story: Story) => {
cover_image: story.cover_image ? { id: null, name: null, url: story.cover_image } : null,
}))
navigate("/blog/create-post?type=story")
navigate(createRoute({ type: "write-story" }))
};
const onConfirmDelete = useCallback(({ payload: { confirmed } }: typeof CONFIRM_DELETE_STORY) => {

View File

@@ -14,6 +14,10 @@ type RouteOptions =
title?: string,
username?: string,
}
| {
type: "write-story",
id?: number,
}
| {
type: "bounty",
id: string | number,
@@ -51,6 +55,10 @@ export function createRoute(options: RouteOptions) {
+ (!onlyId ? "-" : "")
+ `${options.id}`
}
if (options.type === 'write-story')
return "/story/write?type=story"
if ((options.type === "post" && options.postType.toLowerCase() === 'bounty')
|| options.type === "bounty")
return `/blog/post/bounty/${options.id}`