Skip to content

Commit

Permalink
chore(GoalPreview): remove legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Aug 8, 2023
1 parent bdd7ec2 commit 1e2bd1d
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/components/GoalPreview/GoalPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useCallback, useMemo, useRef, useState } from 'react';
import React, { FC, useCallback, useMemo, useRef } from 'react';
import dynamic from 'next/dynamic';
import styled from 'styled-components';
import { danger0, gapM, gapS, gray7 } from '@taskany/colors';
Expand Down Expand Up @@ -106,22 +106,11 @@ export const GoalPreviewModal: React.FC<GoalPreviewProps> = ({ shortId, goal, de
return utils.goal.getById.invalidate(shortId);
}, [utils.goal.getById, shortId]);

const [goalEditModalVisible, setGoalEditModalVisible] = useState(false);

const onGoalEdit = useCallback(() => {
setGoalEditModalVisible(false);

dispatchModalEvent(ModalEvent.GoalEditModal)();
invalidateFn();
}, [invalidateFn]);

const onGoalEditModalShow = useCallback(() => {
setGoalEditModalVisible(true);
}, []);

const onGoalEditModalClose = useCallback(() => {
setGoalEditModalVisible(false);
}, []);

const stateChangeMutations = trpc.goal.switchState.useMutation();
const onGoalStateChange = useCallback(
async (nextState: GoalStateChangeSchema['state']) => {
Expand All @@ -138,7 +127,6 @@ export const GoalPreviewModal: React.FC<GoalPreviewProps> = ({ shortId, goal, de
);

const onPreviewClose = useCallback(() => {
setGoalEditModalVisible(false);
onClose?.();
}, [onClose]);

Expand Down Expand Up @@ -404,13 +392,7 @@ export const GoalPreviewModal: React.FC<GoalPreviewProps> = ({ shortId, goal, de
{nullable(goal, (g) =>
nullable(g._isEditable, () => (
<>
<ModalOnEvent
event={ModalEvent.GoalEditModal}
hotkeys={editGoalKeys}
visible={goalEditModalVisible}
onShow={onGoalEditModalShow}
onClose={onGoalEditModalClose}
>
<ModalOnEvent event={ModalEvent.GoalEditModal} hotkeys={editGoalKeys}>
<GoalEditForm goal={g} onSubmit={onGoalEdit} />
</ModalOnEvent>

Expand Down

0 comments on commit 1e2bd1d

Please sign in to comment.