Skip to content

Commit

Permalink
fix: Browser Back button not functioning after redirecting to the Ana…
Browse files Browse the repository at this point in the history
…lytics page from the Project details page gf-540 (#542)

* feat: add check for initial load in use search filters hook gf-540

* feat: add contributor name search preselected on redirection gf-540

* fix: add link to contributor item activity chart gf-540
  • Loading branch information
s1rserg authored Sep 26, 2024
1 parent a6b96c4 commit 4c8d9dd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 8 additions & 2 deletions apps/frontend/src/libs/components/chart/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import styles from "./styles.module.css";

type Properties = {
data: ChartData;
isCursorPointer: boolean;
};

const Chart = ({ data }: Properties): JSX.Element => {
const Chart = ({ data, isCursorPointer }: Properties): JSX.Element => {
return (
<LineChart data={data} height={40} width={120}>
<LineChart
data={data}
height={40}
style={{ cursor: isCursorPointer ? "pointer" : "default" }}
width={120}
>
<Line className={styles["line"] as string} dataKey="y" dot={false} />
</LineChart>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ const useSearchFilters = ({
: "";
const [search, setSearch] = useState<string>(searchParameter);

const [isInitialLoad, setIsInitialLoad] = useState<boolean>(true);

useEffect(() => {
if (isInitialLoad) {
setIsInitialLoad(false);

return;
}

if (isSavedToUrl) {
const updatedSearchParameters = new URLSearchParams(searchParameters);
updatedSearchParameters.set(queryParameterName, search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ContributorCard = ({
}: Properties): JSX.Element => {
const analyticsRoute = configureQueryString(AppRoute.ANALYTICS, [
[QueryParameterName.PROJECT_ID, projectId],
[QueryParameterName.SEARCH, contributor.name],
]);

const currentDate = getStartOfDay(new Date());
Expand Down Expand Up @@ -94,7 +95,11 @@ const ContributorCard = ({
{hasActivityIndicator && (
<ActivityIndicator label={lastUpdateLabel} status={colorStatus} />
)}
{hasActivityData && <Chart data={activityData} />}
{hasActivityData && (
<NavLink to={analyticsRoute}>
<Chart data={activityData} isCursorPointer />
</NavLink>
)}
<ContributorMenu
contributorId={contributor.id}
hasEditPermission={hasEditPermission}
Expand Down

0 comments on commit 4c8d9dd

Please sign in to comment.