-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '131-user-should-be-able-to-set-their-availability-statu…
…s' into make-webapp-responsive
- Loading branch information
Showing
25 changed files
with
752 additions
and
34 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
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
52 changes: 52 additions & 0 deletions
52
raven-app/src/components/feature/userSettings/DeleteImageModal.tsx
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,52 @@ | ||
import { useFrappeUpdateDoc } from 'frappe-react-sdk' | ||
import { AlertDialog, Button, Flex, Text } from '@radix-ui/themes' | ||
import { Loader } from '@/components/common/Loader' | ||
import { toast } from 'sonner' | ||
import { ErrorBanner } from '@/components/layout/AlertBanner' | ||
import { useUserData } from '@/hooks/useUserData' | ||
|
||
interface DeleteImageModalProps { | ||
onClose: () => void | ||
} | ||
|
||
export const DeleteImageModal = ({ onClose }: DeleteImageModalProps) => { | ||
|
||
const { updateDoc, error, loading } = useFrappeUpdateDoc() | ||
const userData = useUserData() | ||
|
||
const deleteImage = () => { | ||
updateDoc('Raven User', userData.name, { | ||
'user_image': null | ||
}).then(() => { | ||
onClose() | ||
toast.success("Image deleted successfully") | ||
}).catch(() => { | ||
toast("Could not delete image") | ||
}) | ||
} | ||
|
||
return ( | ||
<> | ||
<AlertDialog.Title>Delete Image</AlertDialog.Title> | ||
|
||
<Flex direction={'column'} gap='2'> | ||
<ErrorBanner error={error} /> | ||
<Text>Are you sure you want to delete this image?</Text> | ||
</Flex> | ||
|
||
<Flex gap="3" mt="4" justify="end"> | ||
<AlertDialog.Cancel> | ||
<Button variant="soft" color="gray"> | ||
Cancel | ||
</Button> | ||
</AlertDialog.Cancel> | ||
<AlertDialog.Action> | ||
<Button variant="solid" color="red" onClick={deleteImage} disabled={loading}> | ||
{loading && <Loader />} | ||
{loading ? "Deleting" : "Delete"} | ||
</Button> | ||
</AlertDialog.Action> | ||
</Flex> | ||
</> | ||
) | ||
} |
Oops, something went wrong.