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

visual: added design at client list page #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/locales/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@ export const main = {
student_id: "Student ID",
},
},
clients: {
list: {
title: "Clients List",
add: "Create New",
},
},
};
6 changes: 6 additions & 0 deletions src/locales/ko-KR/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@ export const main = {
student_id: "학번",
},
},
clients: {
list: {
title: "클라이언트 목록",
add: "새로 생성하기",
},
},
};
53 changes: 41 additions & 12 deletions src/pages/ClientList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { useClients } from "src/api/client";
import Button from "src/components/Button";

import {
ClientCardContainer,
Container,
Divider,
Row,
Section,
Title,
} from "./styles";

const ClientCard = ({
uuid,
Expand All @@ -10,25 +21,43 @@ const ClientCard = ({
name: string;
id: string;
}) => (
<div>
<Link to={`/clients/${uuid}`}>{name}</Link>
<div>id: {id}</div>
</div>
<ClientCardContainer>
<b>
<Link to={`/clients/${uuid}`}>{name}</Link>
</b>
<div>
ID: <code>{id}</code>
</div>
</ClientCardContainer>
);

const ClientListPage = () => {
const navigate = useNavigate();
const { t } = useTranslation();

const { data: clients } = useClients();
return (
<div>
<ul>
<Container>
<Section>
<Row>
<Title>{t("clients.list.title")}</Title>
</Row>

{clients?.map((client) => (
<li key={client.uuid}>
<Row key={client.uuid}>
<ClientCard {...client} />
</li>
</Row>
))}
</ul>
<Link to="/clients/new">create new client</Link>
</div>
</Section>

<Divider />

<Section>
<Button onClick={() => navigate("/clients/new")}>
{t("clients.list.add")}
</Button>
</Section>
</Container>
);
};

Expand Down
48 changes: 48 additions & 0 deletions src/pages/ClientList/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import styled from "styled-components";

export const Container = styled.div`
width: 100%;
display: flex;
flex-direction: column;
`;

export const Divider = styled.div`
background-color: #f5f5f5;
height: 1px;
margin: 1.875rem 0;

@media screen and (max-width: 425px) {
height: 1rem;
margin: 1.875rem -2.25rem;
}
`;

export const Section = styled.section`
padding: 0 1.875rem;
display: flex;
flex-direction: column;
gap: 1.5rem;
`;

export const Row = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`;

export const Title = styled.h1`
font-size: 1.5rem;
font-weight: bold;
color: var(--color-primary-text);
margin: 0;
`;

export const ClientCardContainer = styled.div`
display: flex;
flex-direction: column;
gap: 0.2rem;
padding: 1.5rem;
border-radius: 0.5rem;
background-color: rgba(0, 0, 0, 0.05);
width: 100%;
`;