-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(slices): Remove deleteSliceSaga
- Loading branch information
1 parent
20ab957
commit bac62a7
Showing
13 changed files
with
150 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/slice-machine/src/features/slices/actions/deleteSlice.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { toast } from "react-toastify"; | ||
|
||
import { managerClient } from "@src/managerClient"; | ||
|
||
type DeleteSliceArgs = { | ||
sliceName: string; | ||
sliceID: string; | ||
libraryID: string; | ||
onSuccess: () => void; | ||
}; | ||
|
||
export async function deleteSlice(args: DeleteSliceArgs) { | ||
const { sliceName, sliceID, libraryID, onSuccess } = args; | ||
|
||
try { | ||
const { errors } = await managerClient.slices.deleteSlice({ | ||
libraryID, | ||
sliceID, | ||
}); | ||
|
||
if (errors.length > 0) { | ||
throw errors; | ||
} | ||
|
||
onSuccess(); | ||
|
||
toast.success(`Successfully deleted Slice “${sliceName}”`); | ||
} catch (e) { | ||
const errorMessage = `An unexpected error happened while deleting “${sliceName}”.`; | ||
console.error(errorMessage, e); | ||
toast.error(errorMessage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.