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

fix: side menu - kaynak butonu twitter yönlendirme sorunu #482 #496

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
29984dc
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
bd9ffda
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
c509f9a
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
d701090
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
325c798
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
01c0b43
Merge branch 'acikkaynak:development' into development
bb7hn Feb 8, 2023
caa87fe
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
d561aca
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
5174a66
Merge branch 'acikkaynak:development' into development
bb7hn Feb 8, 2023
5a42bab
Merge branch 'development' of https://github.com/bb7hn/deprem-yardim-…
bb7hn Feb 8, 2023
bb13ceb
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
8fd4d6f
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
7a264fa
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
68dd208
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
4c18f21
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
f82ef31
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
aab0b07
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
87f8653
fix: side menu - kaynak butonu twitter yönlendirme sorunu #482
bb7hn Feb 8, 2023
16ccb3f
Merge branch 'acikkaynak:development' into development
bb7hn Feb 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 60 additions & 7 deletions components/UI/Drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ import React, {
useState,
} from "react";
import styles from "./Drawer.module.css";
import { useRouter } from "next/router";

import Alert from "@mui/material/Alert";
import Stack from "@mui/material/Stack";
import RenderIf from "../Common/RenderIf";
// or
bb7hn marked this conversation as resolved.
Show resolved Hide resolved
interface MapsButton {
label: string;
// eslint-disable-next-line no-unused-vars
Expand Down Expand Up @@ -79,7 +84,10 @@ const Drawer = () => {
const isOpen = useIsDrawerOpen();
const data = useDrawerData();
const size = useWindowSize();
const [error, setError] = useState(false);

const [openBillboardSnackbar, setOpenBillboardSnackbar] = useState(false);

const anchor = useMemo(
() => (size.width > 768 ? "left" : "bottom"),
[size.width]
Expand Down Expand Up @@ -113,7 +121,7 @@ const Drawer = () => {
}

const { handleMarkerClick: toggler } = useMapClickHandlers();

const router = useRouter();
const list = useMemo(() => {
if (!data) {
return null;
Expand All @@ -125,6 +133,19 @@ const Drawer = () => {
geometry.location.lng,
]).format();

const openSourceUrl = () => {
if (source.channel === "twitter" && source.extra_parameters) {
bb7hn marked this conversation as resolved.
Show resolved Hide resolved
const extraParams = JSON.parse(source.extra_parameters);
bb7hn marked this conversation as resolved.
Show resolved Hide resolved
if (extraParams.user_id && extraParams.tweet_id) {
router.push(
`https://twitter.com/${extraParams.user_id}/status/${extraParams.tweet_id}`
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTwitterLink tarzı bi util mi yazsak? google maps linkinde olduğu gibi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyuser direkt kullanılabilinir bu arada burada. user id belirtilmeye gerek yok diye biliyorum. Önceki halide zaten bu şekilde çalışıyordu.

}
return;
}
setError(true);
};

return (
<Box
sx={{
Expand Down Expand Up @@ -193,11 +214,7 @@ const Drawer = () => {
className={styles.clipboard}
fullWidth
size="small"
onClick={() =>
window.open(
`https://twitter.com/anyuser/status/${source.tweet_id}`
)
}
onClick={openSourceUrl}
startIcon={<OpenInNew className={styles.btnIcon} />}
color="secondary"
>
Expand Down Expand Up @@ -238,8 +255,16 @@ const Drawer = () => {
<CloseIcon onClick={(e) => toggler(e)} className={styles.closeButton} />
</Box>
);
}, [data, size.width, toggler, showSavedData]);
}, [data, size.width, showSavedData, toggler, router]);

useEffect(() => {
if (error) {
bb7hn marked this conversation as resolved.
Show resolved Hide resolved
const timeOut = setTimeout(() => {
setError(false);
}, 3500);
return () => clearTimeout(timeOut);
}
}, [error]);
const handleClose = useCallback((e: MouseEvent) => toggler(e), [toggler]);

return (
Expand All @@ -250,6 +275,34 @@ const Drawer = () => {
onClose={() => setOpenBillboardSnackbar(false)}
message="Adres Kopyalandı"
/>
<RenderIf condition={error}>
<Stack
sx={{
position: "absolute",
top: 5,
right: 5,
width: "320px",
zIndex: 9999,
transition: "all",
}}
spacing={2}
>
<Alert
severity="error"
action={
<CloseIcon
onClick={() => setError(false)}
style={{
cursor: "pointer",
margin: "auto",
}}
/>
}
>
Kaynak açılamadı
</Alert>
</Stack>
</RenderIf>
<MuiDrawer
className="drawer"
anchor={anchor}
Expand Down
3 changes: 3 additions & 0 deletions mocks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export type Raw = {
tweet_id: string;
name?: string;
screen_name?: string;
source?:string;
extra_parameters?:null|string;
channel?:string
};

export type LocationsResponse = {
Expand Down