|
|
@@ -33,6 +33,9 @@ export const usePageCreateModal = (status?: CreateModalStatus): SWRResponse<Crea
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+/*
|
|
|
+* PageDeleteModal
|
|
|
+*/
|
|
|
export type IDeleteModalOption = {
|
|
|
onDeleted?: OnDeletedFunction,
|
|
|
emptyTrash?: true,
|
|
|
@@ -71,6 +74,46 @@ export const usePageDeleteModal = (status?: DeleteModalStatus): SWRResponse<Dele
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+/*
|
|
|
+* EmptyTrashModal
|
|
|
+*/
|
|
|
+export type IEmptyTrashModalOption = {
|
|
|
+ onEmptiedTrash?: () => void,
|
|
|
+}
|
|
|
+
|
|
|
+type EmptyTrashModalStatus = {
|
|
|
+ isOpened: boolean,
|
|
|
+ pages?: IPageToDeleteWithMeta[],
|
|
|
+ opts?: IEmptyTrashModalOption,
|
|
|
+}
|
|
|
+
|
|
|
+type EmptyTrashModalStatusUtils = {
|
|
|
+ open(
|
|
|
+ pages?: IPageToDeleteWithMeta[],
|
|
|
+ opts?: IEmptyTrashModalOption,
|
|
|
+ ): Promise<EmptyTrashModalStatus | undefined>,
|
|
|
+ close(): Promise<EmptyTrashModalStatus | undefined>,
|
|
|
+}
|
|
|
+
|
|
|
+export const useEmptyTrashModal = (status?: EmptyTrashModalStatus): SWRResponse<EmptyTrashModalStatus, Error> & EmptyTrashModalStatusUtils => {
|
|
|
+ const initialData: EmptyTrashModalStatus = {
|
|
|
+ isOpened: false,
|
|
|
+ pages: [],
|
|
|
+ };
|
|
|
+ const swrResponse = useStaticSWR<EmptyTrashModalStatus, Error>('emptyTrashModalStatus', status, { fallbackData: initialData });
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...swrResponse,
|
|
|
+ open: (
|
|
|
+ pages?: IPageToDeleteWithMeta[],
|
|
|
+ opts?: IEmptyTrashModalOption,
|
|
|
+ ) => swrResponse.mutate({
|
|
|
+ isOpened: true, pages, opts,
|
|
|
+ }),
|
|
|
+ close: () => swrResponse.mutate({ isOpened: false }),
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
/*
|
|
|
* PageDuplicateModal
|
|
|
*/
|