-
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 (#1280)
- Loading branch information
1 parent
666d157
commit 043c3a4
Showing
13 changed files
with
151 additions
and
543 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 = { | ||
libraryID: string; | ||
sliceID: string; | ||
sliceName: 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 slice “${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.