|
|
@@ -155,27 +155,44 @@ export const usePageRenameModal = (status?: RenameModalStatus): SWRResponse<Rena
|
|
|
/*
|
|
|
* PutBackPageModal
|
|
|
*/
|
|
|
+export type IPageForPagePutBackModal = {
|
|
|
+ pageId: string,
|
|
|
+ path: string
|
|
|
+}
|
|
|
+
|
|
|
+export type IPutBackPageModalOption = {
|
|
|
+ onPutBacked?: OnRenamedFunction,
|
|
|
+}
|
|
|
+
|
|
|
type PutBackPageModalStatus = {
|
|
|
isOpened: boolean,
|
|
|
- pageId?: string,
|
|
|
- path?: string,
|
|
|
+ page?: IPageForPagePutBackModal,
|
|
|
+ opts?: IPutBackPageModalOption,
|
|
|
}
|
|
|
|
|
|
type PutBackPageModalUtils = {
|
|
|
- open(pageId: string, path: string): Promise<PutBackPageModalStatus | undefined>
|
|
|
+ open(
|
|
|
+ page?: IPageForPagePutBackModal,
|
|
|
+ opts?: IPutBackPageModalOption,
|
|
|
+ ): Promise<PutBackPageModalStatus | undefined>
|
|
|
close():Promise<PutBackPageModalStatus | undefined>
|
|
|
}
|
|
|
|
|
|
export const usePutBackPageModal = (status?: PutBackPageModalStatus): SWRResponse<PutBackPageModalStatus, Error> & PutBackPageModalUtils => {
|
|
|
- const initialData = { isOpened: false, pageId: '', path: '' };
|
|
|
+ const initialData: PutBackPageModalStatus = {
|
|
|
+ isOpened: false,
|
|
|
+ page: { pageId: '', path: '' },
|
|
|
+ };
|
|
|
const swrResponse = useStaticSWR<PutBackPageModalStatus, Error>('putBackPageModalStatus', status, { fallbackData: initialData });
|
|
|
|
|
|
return {
|
|
|
...swrResponse,
|
|
|
- open: (pageId: string, path: string) => swrResponse.mutate({
|
|
|
- isOpened: true, pageId, path,
|
|
|
+ open: (
|
|
|
+ page: IPageForPagePutBackModal, opts?: IPutBackPageModalOption,
|
|
|
+ ) => swrResponse.mutate({
|
|
|
+ isOpened: true, page, opts,
|
|
|
}),
|
|
|
- close: () => swrResponse.mutate({ isOpened: false }),
|
|
|
+ close: () => swrResponse.mutate({ isOpened: false, page: { pageId: '', path: '' } }),
|
|
|
};
|
|
|
};
|
|
|
|