Skip to content

Commit

Permalink
fix : 유담이가 말한 수정사항
Browse files Browse the repository at this point in the history
  • Loading branch information
ayden94 committed Jan 4, 2024
1 parent 64c6a0d commit a1490b1
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 31 deletions.
3 changes: 3 additions & 0 deletions components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const Header = () => {
const [myData, setMyData] = useState<ExtendedUserType>();

const dashboardList = useAtomValue(dashboardListAtom);
const dashboard = dashboardList.find((item) => {
return item.id === Number(boardId);
});

const isOwner = memberList?.find((v) => v.userId === myData?.id)?.isOwner;
const [title, setTitle] = useState(dashboard?.title);
Expand Down
5 changes: 3 additions & 2 deletions components/MenuLayout/MenuLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ const MenuLayout = ({ children }: Props) => {
</div>
<div className={styles.grid__header}>
<Header />
<div className={styles.grid__main} ref={dragRef}>
{children}
<div className={styles.grid__main} ref={dragRef}>
{children}
</div>
</div>
</div>
);
Expand Down
21 changes: 16 additions & 5 deletions pages/dashboard/[boardId]/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const accessToken = getAccessTokenFromCookie(context) as string;
const boardId = Number(context.query["boardId"]);

const boardId = context.params?.boardId;

if (!accessToken) {
return {
redirect: {
Expand All @@ -35,6 +33,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
};
}

const {
data: { dashboards },
} = await sender.get({ path: "dashboards", method: "pagination", size: 999, accessToken: accessToken });

const {
data: { members },
} = await sender.get({ path: "members", id: Number(boardId), accessToken });
Expand All @@ -53,29 +55,38 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
}

return {
props: { accessToken, members, invitations },
props: { accessToken, members, dashboards, invitations },
};
};

const DashboardEdit = ({
members,
accessToken,
dashboards,
invitations,
}: InferGetServerSidePropsType<typeof getServerSideProps>) => {
const [dashboardList, setDashboardList] = useAtom(dashboardListAtom);
if (!dashboardList.length) {
setDashboardList(dashboards);
}

const router = useRouter();
const boardId = router?.query.boardId;

const dashboard = dashboardList.find((item) => {
return item.id === Number(boardId);
});

const dashboardData = dashboardList.find((v) => v.id === Number(boardId));

const [prevColor, setPrevColor] = useState(dashboardData?.color ?? "#760dde");

const [color, setColor] = useState<ColorType>(prevColor);

const [memberList, setMemberList] = useState<(Member | InvitationData)[]>(members);

const [invitationList, setInvitationList] = useState<(Member | InvitationData)[]>(invitations);

const [boardName, setBoardName] = useState(dashboard?.title);

const [isOpenDashboardDeleteModal, setIsOpenDashboardDeleteModal] = useState(false);
Expand Down Expand Up @@ -129,7 +140,7 @@ const DashboardEdit = ({
<Head>
<title>Taskify - 대시보드 수정</title>
</Head>

<MenuLayout>
<div className={styles.body}>
<Link href={`/dashboard/${boardId}`} className={styles.back_button}>
Expand Down
11 changes: 5 additions & 6 deletions pages/dashboard/[boardId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const accessToken = getAccessTokenFromCookie(context) as string;
const boardId = Number(context.query["boardId"]);

const { data: dashboard } = await sender.get({ path: "dashboard", id: boardId, accessToken });

const {
data: { data: columnData },
} = await sender.get({ path: "columns", id: boardId, accessToken });
Expand All @@ -38,6 +36,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
columnOrder: [],
};

const {
data: { dashboards },
} = await sender.get({ path: "dashboards", method: "pagination", size: 999, accessToken: accessToken });

for (const value of columnData) {
entireData.columnOrder.push(value.id);
entireData.columns[value.id] = value;
Expand All @@ -57,7 +59,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
}

return {
props: { accessToken, assigneeList, boardId, dashboard, entireData },
props: { accessToken, assigneeList, boardId, dashboards, entireData },
};
};

Expand Down Expand Up @@ -154,9 +156,6 @@ const Dashboard = ({
[entireList]
);


if (!mount) return null;

return (
<>
<Head>
Expand Down
2 changes: 2 additions & 0 deletions pages/mydashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export default function Mydashboard({
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
const [isOpen, setIsOpen] = useState(false);

const router = useRouter();

const [dashboardList, setDashboardList] = useAtom(dashboardListAtom);
if (!dashboardList.length) {
setDashboardList(dashboards);
Expand Down
42 changes: 24 additions & 18 deletions pages/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,30 @@ const Signup = ({ accessToken }: InferGetServerSidePropsType<typeof getServerSid
<title>Taskify - 회원가입</title>
</Head>
<div className={styles.container}>
<Image priority width={200} height={279} src="/images/logo-purple-vertical.png" alt="이전 페이지로 돌아갑니다." />
<p className={styles.title}>첫 방문을 환영합니다!</p>
<form className={styles.form} onSubmit={handleSubmit}>
{inputs.map(([wrapper, input], index) => {
return (
<InputWrapper {...wrapper} key={index}>
<Input inputRef={inputRef} {...input} />
</InputWrapper>
);
})}
<Button buttonType="login" color="violet" disabled={isError()}>
가입하기
</Button>
</form>
<p className={styles.link__text}>
이미 가입하셨나요? <Link href="/signin">로그인하기</Link>
</p>
</div>
<Image
priority
width={200}
height={279}
src="/images/logo-purple-vertical.png"
alt="이전 페이지로 돌아갑니다."
/>
<p className={styles.title}>첫 방문을 환영합니다!</p>
<form className={styles.form} onSubmit={handleSubmit}>
{inputs.map(([wrapper, input], index) => {
return (
<InputWrapper {...wrapper} key={index}>
<Input inputRef={inputRef} {...input} />
</InputWrapper>
);
})}
<Button buttonType="login" color="violet" disabled={isError()}>
가입하기
</Button>
</form>
<p className={styles.link__text}>
이미 가입하셨나요? <Link href="/signin">로그인하기</Link>
</p>
</div>
</>
);
};
Expand Down

0 comments on commit a1490b1

Please sign in to comment.