Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved type error using a custom method #10630

Merged
merged 28 commits into from
Feb 20, 2025
Merged
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ea4a69b
improved tablet view responsiveness
Tanuj1718 Feb 3, 2025
85bfad8
solved i18n issue
Tanuj1718 Feb 4, 2025
09f613a
Merge branch 'develop' into develop
Tanuj1718 Feb 4, 2025
158d709
update mobile view responsiveness
Tanuj1718 Feb 4, 2025
b39654d
Merge branch 'develop' into develop
Tanuj1718 Feb 4, 2025
c4586e6
added responsiveness in organization users page
Tanuj1718 Feb 5, 2025
ea48433
Merge branch 'develop' into develop
Tanuj1718 Feb 5, 2025
73c1773
minor change in button
Tanuj1718 Feb 5, 2025
5283828
Merge branch 'develop' of https://github.com/Tanuj1718/care_fe into d…
Tanuj1718 Feb 5, 2025
ffdb6df
draft pr
Tanuj1718 Feb 5, 2025
f46c2eb
modified date-field handlers
Jacobjeevan Feb 5, 2025
4dfd361
minor cleanup
Jacobjeevan Feb 5, 2025
70eca3e
Merge branch 'develop' into fix-issue
Tanuj1718 Feb 6, 2025
6f00675
Merge branch 'develop' into fix-issue
Tanuj1718 Feb 6, 2025
e1b3c37
revert unwanted changes
Tanuj1718 Feb 6, 2025
a32aeef
fix responsiveness
Tanuj1718 Feb 9, 2025
6d12bf1
Merge branch 'develop' into fix-ui
Tanuj1718 Feb 9, 2025
ebdc962
minor change
Tanuj1718 Feb 10, 2025
ad685aa
Merge remote-tracking branch 'upstream/develop' into fix-ui
Tanuj1718 Feb 10, 2025
fbe0648
Merge branch 'fix-ui' of https://github.com/Tanuj1718/care_fe into fi…
Tanuj1718 Feb 10, 2025
5a4a397
Merge remote-tracking branch 'upstream/develop' into fix-ui
Tanuj1718 Feb 11, 2025
0474c0b
Merge remote-tracking branch 'upstream/develop' into fix-ui
Tanuj1718 Feb 16, 2025
ffdbb95
solved type error
Tanuj1718 Feb 16, 2025
4db802e
updated with requested changes
Tanuj1718 Feb 17, 2025
87519e8
Merge branch 'develop' into fix-ui
nihal467 Feb 18, 2025
b366d3e
Merge remote-tracking branch 'upstream/develop' into fix-ui
Tanuj1718 Feb 20, 2025
abfe74e
done suggested changes
Tanuj1718 Feb 20, 2025
99444b7
Merge branch 'fix-ui' of https://github.com/Tanuj1718/care_fe into fi…
Tanuj1718 Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions src/components/Common/AvatarEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const AvatarEditModal = ({
const [selectedFile, setSelectedFile] = useState<File>();
const [preview, setPreview] = useState<string>();
const [isCameraOpen, setIsCameraOpen] = useState<boolean>(false);
const webRef = useRef<any>(null);
const [previewImage, setPreviewImage] = useState(null);
const webRef = useRef<Webcam>(null);
const [previewImage, setPreviewImage] = useState<string | null>(null);
const [isCaptureImgBeingUploaded, setIsCaptureImgBeingUploaded] =
useState(false);
const [constraint, setConstraint] = useState<IVideoConstraint>(
Expand All @@ -81,16 +81,35 @@ const AvatarEditModal = ({
}, []);

const captureImage = () => {
setPreviewImage(webRef.current.getScreenshot());
const canvas = webRef.current.getCanvas();
canvas?.toBlob((blob: Blob) => {
const myFile = new File([blob], "image.png", {
type: blob.type,
});
setSelectedFile(myFile);
if (webRef.current) {
setPreviewImage(webRef.current.getScreenshot());
}
const canvas = webRef.current?.getCanvas();
canvas?.toBlob((blob) => {
if (blob) {
const myFile = new File([blob], "image.png", {
type: blob.type,
});
setSelectedFile(myFile);
} else {
toast.error(t("failed_to_capture_image"));
}
});
};

const stopCamera = useCallback(() => {
try {
if (webRef.current) {
const openCamera = webRef.current?.video?.srcObject as MediaStream;
if (openCamera) {
openCamera.getTracks().forEach((track) => track.stop());
}
}
} catch (error: any) {
toast.error("Failed to stop camera: ", error);
} finally {
setIsCameraOpen(false);
}
}, []);
const closeModal = () => {
setPreview(undefined);
setIsProcessing(false);
Expand Down Expand Up @@ -410,7 +429,7 @@ const AvatarEditModal = ({
onClick={() => {
setPreviewImage(null);
setIsCameraOpen(false);
webRef.current.stopCamera();
stopCamera();
}}
disabled={isProcessing}
>
Expand Down
Loading