Skip to content
Merged
1 change: 0 additions & 1 deletion src/app/(with-header-sidebar)/layout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

.sideBarWrapper {
border-right: 1px solid var(--gray-300);
padding: 22px;
}

.mainWrapper {
Expand Down
10 changes: 5 additions & 5 deletions src/app/(with-header-sidebar)/mydashboard/_hooks/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axiosInstance from '../_utils/axiosInstance';

type UseApiFetchReturnType<T> = {
data: T | null;
loading: boolean;
isLoading: boolean;
error: AxiosError | null;
refetch: () => Promise<void>;
};
Expand All @@ -27,12 +27,12 @@ export default function useApi<
options: RequestOptions<TParams, TBody>
): UseApiFetchReturnType<T> {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState<boolean>(true);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<AxiosError | null>(null);

const fetchData = useCallback(async () => {
// TODO if (loading) return; add?
setLoading(true);
setIsLoading(true);
setError(null);

const config = {
Expand All @@ -48,13 +48,13 @@ export default function useApi<
} catch (err) {
setError(err as AxiosError);
} finally {
setLoading(false);
setIsLoading(false);
}
}, [url, JSON.stringify(options)]);

useEffect(() => {
fetchData();
}, [fetchData]);

return { data, loading, error, refetch: fetchData };
return { data, isLoading, error, refetch: fetchData };
}
2 changes: 2 additions & 0 deletions src/app/reset.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ button {
a {
text-decoration: none;
color: inherit;
display: inherit;
width: inherit;
Comment on lines +40 to +41
Copy link
Collaborator Author

@devmanta devmanta Nov 17, 2024

Choose a reason for hiding this comment

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

이거.. Linkμ‚¬μš© μ‹œ active μΆ”κ°€ν•  λ•Œ λ‚΄λ§˜λŒ€λ‘œ css ν΄λž˜μŠ€κ°€ μΆ”κ°€κ°€ μ•ˆλ˜λ”λΌκ΅¬μš”..
λ‚œλΆ„λͺ…νžˆ μΆ”κ°€λ₯Όν–ˆλŠ”λ° λ„₯μŠ€νŠΈκ°€ Link λ§ˆμš΄νŠΈν• λ•Œ 뭐 λ”°λ‘œ 처리λ₯Ό ν•˜λŠ”κ²ƒκ°™μ€λ° ν΄λž˜μŠ€κ°€ μ μš©μ΄μ•ˆλΌμš”γ… 

<Link
        href={`/dashboard/${id}`}
        className={`link ${isActive ? styles.active : styles.aaa}`}
      >

μ΄λŸ°μ‹μœΌλ‘œ μΆ”κ°€ν•˜λ©΄ aaa μ–˜λŠ” μ–΄λ–»κ²Œ 해도 μ μš©μ΄μ•ˆλ˜λ˜λ°... 뭐 λ”°λ‘œ legacybasis?인지먼지 속성 μΆ”κ°€ν•˜κ³  μžμ‹μš”μ†Œλ‘œ aνƒœκ·Έ λ„£κ³  해도 μ•ˆλκ³ .. css λͺ¨λ“ˆμ•ˆμ—μ„œλŠ” νƒœκ·Έμ„ νƒμžλŠ” μ•ˆλ˜κ°€μ§€κ³  그것도 μ μš©μ•ˆλŒ€κ³ ...
κ²°κ΅­.. reset으둜 μ™€μ„œ
aνƒœκ·ΈλŠ” displayλž‘ witdh λΆ€λͺ¨κΊΌ css μƒμ†λ°›κ²Œ μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€

Copy link
Owner

@najitwo najitwo Nov 18, 2024

Choose a reason for hiding this comment

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

className={link ${isActive ? styles.active : styles.aaa}}
μ—¬κΈ°μ„œ link μ• λŠ” λ­ν•˜λŠ” μ• μΈκ°€μš”???
<li></li> νƒœκ·Έλ‘œ κ°μ‹Έμ Έμžˆλ˜λ° 여기에 μŠ€νƒ€μΌμ„ μ μš©ν•˜λ©΄ λ˜μ§€μ•Šμ„κΉŒμš”???
그리고 μ•„λ§ˆ <li> νƒœκ·Έ μ—†μ• λ©΄ Link μŠ€νƒ€μΌ 잘 적용 될 것 κ°™μŠ΅λ‹ˆλ‹€.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@najitwo μ œκ°€ ν•˜κ³ μ‹Άμ—‡λ˜κ²Œ κ²°κ΅­ aνƒœκ·Έλ₯Ό display block처럼 전체 widthλ₯Ό λ¨ΉλŠ”κ±΄λ°
li에 μŠ€νƒ€μΌ μ μš©ν•΄λ„ κ·Έ μžμ‹μΈ aνƒœκ·ΈλŠ” inline μŠ€νƒ€μΌμ΄λΌ 전체 widthλ₯Ό μ•ˆλ¨Ήλ”λΌκ΅¬μš”πŸ« 

}
8 changes: 4 additions & 4 deletions src/components/header/Header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
font-size: 16px;
}

.icon {
display: block;
}

.userInfoWrapper {
margin-left: 36px;
}
Expand All @@ -84,8 +88,4 @@
.header {
padding-right: 80px;
}

.icon {
display: block;
}
}
88 changes: 86 additions & 2 deletions src/components/sidebar/Dashboards.module.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,94 @@
.dashBoards {
.dashboards {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
gap: 6px;
}

.active {
color: salmon;
border-radius: 4px;
background: var(--violet-light);
}

.titleContainer {
display: flex;
justify-content: center;
align-items: center;
padding: 16px;
}

.dot {
width: 8px;
height: 8px;
border-radius: 999px;
}

.title,
.crown {
display: none;
color: var(--gray-500);
font-size: 18px;
font-weight: 500;
}

.arrowLeft,
.arrowRight {
border: 1px solid var(--gray-300);
border-right: none;
border-radius: 0;
background: var(--white);
height: 35px;
}

.arrowRight {
border-top: none;
}

.arrowLeft:disabled,
.arrowRight:disabled {
background: var(--white);
}

@media screen and (min-width: 768px) {
.dashboardsWrapper {
margin-top: 10px;
display: flex;
flex-direction: column;
gap: 15px;
}

.title,
.crown {
display: inline;
}

.crown {
margin-left: -8px;
}

.titleContainer {
justify-content: flex-start;
gap: 16px;
padding: 8px 10px;
}

.arrowWrapper {
margin-top: 20px;
}

.arrowLeft,
.arrowRight {
border: 1px solid var(--gray-300);
width: 40px;
height: 40px;
}

.arrowLeft {
border-radius: 4px 0px 0px 4px;
}

.arrowRight {
border-radius: 0px 4px 4px 0px;
}
}
130 changes: 113 additions & 17 deletions src/components/sidebar/Dashboards.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,127 @@
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import type { GetDashboardsResponse } from '@/app/(with-header-sidebar)/mydashboard/_types/dashboards';
import styles from './Dashboards.module.css';
import type {
Dashboard,
GetDashboardsResponse,
} from '@/app/(with-header-sidebar)/mydashboard/_types/dashboards';
import useApi from '@/app/(with-header-sidebar)/mydashboard/_hooks/useApi';
import Image from 'next/image';
import Button from '../Button';
import { useState } from 'react';
import styles from './Dashboards.module.css';

export default function Dashboards() {
const pathname = usePathname();
const PAGE_SIZE = 12;

export default function Dashboards() {
const [page, setPage] = useState(1);
const { data } = useApi<GetDashboardsResponse>('/dashboards', {
method: 'GET',
params: { navigationMethod: 'infiniteScroll', page: 1, size: 10 },
params: { navigationMethod: 'pagination', page, size: PAGE_SIZE },
});

const dashboards = data?.dashboards;
const dashboards = data?.dashboards ?? [];
const totalCount = data?.totalCount ?? 0;
const totalPages = Math.ceil(totalCount / PAGE_SIZE);

const handlePageChange = (direction: 'next' | 'prev') => {
setPage((prevPage) => {
if (direction === 'next' && prevPage < totalPages) return prevPage + 1;
if (direction === 'prev' && prevPage > 1) return prevPage - 1;
return prevPage;
});
};

return (
<div className={styles.dashboards}>
<DashboardList dashboards={dashboards} />
<Pagination
currentPage={page}
totalPages={totalPages}
onPageChange={handlePageChange}
/>
</div>
);
}

function DashboardList({ dashboards }: { dashboards: Dashboard[] }) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이런거 μ—¬κΈ°μ—μ„œλ§Œ 쓸꺼라 λ”°λ‘œ 파일둜 μ•ˆλΉΌκ³  κ·Έλƒ₯ ν•œκ°œνŒŒμΌ μ•ˆμ—μ„œ μ§„ν–‰ν–ˆλŠ”λ°
λ¨Όκ°€ κΈΈμ–΄λ³΄μ΄λŠ”κ±°κ°™κΈ°λ„ν•˜κ³ ... 걍 냅둬도 λ κ²ƒκ°™κΈ°λ„ν•˜κ³ ........κ·ΈλŸ¬λ„€μš”...γ…‹γ…‹γ…‹γ…‹γ…‹

Copy link
Owner

Choose a reason for hiding this comment

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

μ €λŠ” 파일이 100 쀄 정도 λ„˜μ–΄κ°€λ©΄ 뢄리λ₯Ό μƒκ°ν•˜κΈ΄ ν•©λ‹ˆλ‹€.😊
근데 νŒŒμΌμ— Dashboards, DabshboadList κ°€ ν˜Όμš©λ˜μ„œ μ²˜μŒλ΄€μ„λ•Œ ν—·κ°ˆλ¦΄μˆ˜μžˆκ² λ„€μš”... πŸ˜‡

Copy link
Collaborator Author

@devmanta devmanta Nov 18, 2024

Choose a reason for hiding this comment

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

@najitwo κ·ΈλŸ¬λ„€μš”γ…œγ…‹γ…‹ s둜 μ“°κΈ°λ‘œν–‡λŠ”λ° λ¬΄μ§€μ„±μœΌλ‘œ 듀어가버렸넀..πŸ˜…
ν•¨μˆ˜ μ§€μ› μŠ΅λ‹ˆλ‹Ή

(λΉΌλ³΄λ €κ³ ν–ˆλŠ”λ°... cssλ­”κ°€κ°€ ν‹€μ–΄μ Έμ„œ... ν•¨μˆ˜λ§Œ μ§€μš°λŠ”κ±Έγ„Ή..)

return (
<ul className={styles.dashboardsWrapper}>
{dashboards.map((board) => (
<DashboardItem key={board.id} {...board} />
))}
</ul>
);
}

function DashboardItem({ id, color, title, createdByMe }: Dashboard) {
const isActive = usePathname() === `/dashboard/${id}`;

return (
<li>
<Link
href={`/dashboard/${id}`}
className={`link ${isActive ? styles.active : ''}`}
>
<div className={styles.titleContainer}>
<div style={{ background: color }} className={styles.dot}></div>
<span className={styles.title}>{title}</span>
{createdByMe && (
<span className={styles.crown}>
<Image src="/icons/crown.svg" alt="μ™•κ΄€" width={15} height={12} />
</span>
)}
</div>
</Link>
</li>
);
}

function Pagination({
currentPage,
totalPages,
onPageChange,
}: {
currentPage: number;
totalPages: number;
onPageChange: (direction: 'next' | 'prev') => void;
}) {
const isFirstPage = currentPage === 1;
const isLastPage = currentPage >= totalPages;

return (
<div className={styles.dashBoards}>
{dashboards &&
dashboards.map((board) => (
<Link
key={board.id}
href={`/dashboard/${board.id}`}
className={`link ${pathname === '/dashboard/' + board.id ? styles.active : ''}`}
>
{board.title}
</Link>
))}
<div className={styles.arrowWrapper}>
<Button
className={styles.arrowLeft}
onClick={() => onPageChange('prev')}
disabled={isFirstPage}
>
<Image
src={
isFirstPage
? '/icons/arrow_left_light.svg'
: '/icons/arrow_left.svg'
}
alt="μ™Όμͺ½μœΌλ‘œ 이동"
width={16}
height={16}
/>
</Button>
<Button
className={styles.arrowRight}
onClick={() => onPageChange('next')}
disabled={isLastPage}
>
<Image
src={
isLastPage
? '/icons/arrow_right_light.svg'
: '/icons/arrow_right.svg'
}
alt="였λ₯Έμͺ½μœΌλ‘œ 이동"
width={16}
height={16}
/>
</Button>
</div>
);
}
25 changes: 19 additions & 6 deletions src/components/sidebar/SideBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
display: flex;
flex-direction: column;
align-items: center;
gap: 30px;
gap: 15px;
}

.logo {
background-color: transparent;
text-align: left;
padding-top: 22px;
margin-bottom: 10px;
text-align: center;
}

.addDashBoardsContainer {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
padding: 0 22px;
}

.addDashBoardsTitle {
Expand All @@ -29,6 +28,20 @@
@media screen and (min-width: 768px) {
.sideBar {
min-width: 155px;
padding: 0 12px;
}

.logo {
text-align: left;
margin-bottom: 25px;
}

.addDashBoardsContainer {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
padding: 0;
}

.addDashBoardsTitle {
Expand Down
10 changes: 8 additions & 2 deletions src/components/sidebar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
import Image from 'next/image';
import Button from '../Button';
import useWindowSize from '@/app/(with-header-sidebar)/mydashboard/_hooks/useWindowSize';
import Dashboards from './DashBoards';
import Dashboards from './Dashboards';
import { useRouter } from 'next/navigation';
import styles from './SideBar.module.css';

export default function SideBar() {
const { isMobile } = useWindowSize();
const router = useRouter();

return (
<div className={styles.sideBar}>
<Button aria-label="ν™ˆνŽ˜μ΄μ§€ 이동" className={styles.logo}>
<Button
aria-label="ν™ˆνŽ˜μ΄μ§€ 이동"
className={styles.logo}
onClick={() => router.push('/')}
>
{isMobile ? (
<Image
src="/images/logo_small.svg"
Expand Down