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

[FE] assignment : Daystar #4

Open
wants to merge 15 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const responseBodyMap = {
[HttpStatusCode.Ok]: z.object({
items: z.array(
z.object({
orderId: z.number().int().min(1),
studentName: z.string(),
issuedNumber: z.number().int().min(1),
orderId: z.coerce.number().int().min(1),
studentName: z.coerce.string(),
issuedNumber: z.coerce.number().int().min(1),
statusEnum: z.nativeEnum(ActivityCertificateOrderStatusEnum),
createdAt: z.date(),
createdAt: z.coerce.date(),
}),
),
total: z.number().int().min(0),
offset: z.number().int().min(1),
total: z.coerce.number().int().min(0),
offset: z.coerce.number().int().min(1),
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ const responseBodyMap = {
[HttpStatusCode.Ok]: z.object({
items: z.array(
z.object({
orderId: z.number().int().min(1),
orderId: z.coerce.number().int().min(1),
// 상태에 관한 prop이 없어서 임의로 추가했습니다. 리뷰하실 때 시트와 함께 검토해 주세요!
statusEnum: z.nativeEnum(CommonSpaceUsageOrderStatusEnum),
spaceName: z.string(),
chargeStudentName: z.string().max(255),
spaceName: z.coerce.string(),
chargeStudentName: z.coerce.string().max(255),
startTerm: z.coerce.date(), // Assuming startTerm is a datetime
endTerm: z.coerce.date(), // Assuming endTerm is a datetime
createdAt: z.coerce.date(), // Assuming createdAt is a datetime
}),
),
total: z.number().int().min(0),
offset: z.number().int().min(1),
total: z.coerce.number().int().min(0),
offset: z.coerce.number().int().min(1),
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ const responseBodyMap = {
[HttpStatusCode.Ok]: z.object({
items: z.array(
z.object({
id: z.number().int().min(1),
studentName: z.string(),
id: z.coerce.number().int().min(1),
studentName: z.coerce.string(),
status: z.nativeEnum(PromotionalPrintingOrderStatusEnum),
orders: z.array(
z.object({
promotionalPrintingSizeEnum: z.nativeEnum(
PromotionalPrintingSizeEnum,
),
numberOfPrints: z.number().min(1),
numberOfPrints: z.coerce.number().min(1),
}),
),
desiredPickUpDate: z.date(),
pickUpTime: z.optional(z.date()),
createdAt: z.date(),
desiredPickUpDate: z.coerce.date(),
pickUpTime: z.optional(z.coerce.date()),
createdAt: z.coerce.date(),
}),
),
total: z.number().int().min(0),
offset: z.number().int().min(1),
total: z.coerce.number().int().min(0),
offset: z.coerce.number().int().min(1),
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ const responseBodyMap = {
[HttpStatusCode.Ok]: z.object({
items: z.array(
z.object({
id: z.number().int().min(0),
studentName: z.string(),
id: z.coerce.number().int().min(0),
studentName: z.coerce.string(),
objects: z.array(
z.object({
id: z.number().int().min(0),
name: z.string(),
number: z.number().int().min(1),
id: z.coerce.number().int().min(0),
name: z.coerce.string(),
number: z.coerce.number().int().min(1),
}),
),
statusEnum: z.nativeEnum(RentalOrderStatusEnum),
desiredStart: z.date(),
desiredEnd: z.date(),
startDate: z.date().optional(),
endDate: z.date().optional(),
createdAt: z.date(),
desiredStart: z.coerce.date(),
desiredEnd: z.coerce.date(),
startDate: z.coerce.date().optional(),
endDate: z.coerce.date().optional(),
createdAt: z.coerce.date(),
}),
),
total: z.number().int().min(0),
offset: z.number().int().min(1),
total: z.coerce.number().int().min(0),
offset: z.coerce.number().int().min(1),
}),
};

Expand Down
10 changes: 10 additions & 0 deletions 2024-summer-FE-seminar/packages/web/src/app/Daystar/my/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use client";

// use client에 대해서는 공부가 더 필요할 것 같습니다
import React from "react";

import DaystarMyPageMainFrame from "@sparcs-clubs/web/features/Daystar/my/frames/DaystarMyPageMainFrame";

const DaystarMy = () => <DaystarMyPageMainFrame />;
Copy link
Collaborator

Choose a reason for hiding this comment

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

페이지에 프레임이 하나일 때는 웬만하면 프레임 쓰지 말기!


export default DaystarMy;
96 changes: 96 additions & 0 deletions 2024-summer-FE-seminar/packages/web/src/app/Daystar/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"use client";

import React, { useState } from "react";

import styled from "styled-components";

import Card from "@sparcs-clubs/web/common/components/Card";
import DaystarItemNumberInput from "@sparcs-clubs/web/common/components/Daystar/DaystarItemNumberInput";
import DaystarTextInput from "@sparcs-clubs/web/common/components/Daystar/DaystarTextInput";
import ItemNumberInput from "@sparcs-clubs/web/common/components/Forms/ItemNumberInput";
import TextInput from "@sparcs-clubs/web/common/components/Forms/TextInput";
import Select from "@sparcs-clubs/web/common/components/Select";
import Typography from "@sparcs-clubs/web/common/components/Typography";

const DaystarWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 8px;
`;
Comment on lines +15 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

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

FlexWrapper를 사용합시당


const Daystar = () => {
const [firstText, setFirstText] = useState("");
const [secondText, setSecondText] = useState("");
const [firstItemNumber, setFirstItemNumber] = useState("0");
const [solItemNumber, setSolItemNumber] = useState("0");

const [secondHasError, setSecondHasError] = useState(false);

const handleSecondTextChange = (value: string) => {
setSecondText(value);
setSecondHasError(value.length < 5); // 5글자보다 짧으면 에러 뜨는 것으로 테스트
};
Comment on lines +29 to +32
Copy link
Collaborator

Choose a reason for hiding this comment

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

(optional) 여기서 이 input을 한 번도 클릭하지 않았을 때는 에러가 안 뜨게 하려면 어떻게 해야할까요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

secondHasError state의 초깃값을 false로 하면 되는 것 같습니다!


const handleFirstItemNumberChange = (value: string) => {
setFirstItemNumber(value);
};

const handleSolItemNumberChange = (value: string) => {
setSolItemNumber(value);
};

return (
<DaystarWrapper>
<TextInput placeholder="" />
<ItemNumberInput placeholder="" />
<Select items={[]} />
<Card outline gap={16}>
<Typography type="h3">부모 컴포넌트가 받는 값들</Typography>
<Typography>
입력 값들
<br />
{`1번째 InputText : ${firstText}`}
<br />
{`2번째 InputText : ${secondText}`}
<br />
{`1번째 ItemNumberInput : ${firstItemNumber}`}
<br />
{`기존 ItemNumberInput : ${solItemNumber}`}
</Typography>
</Card>
<DaystarTextInput placeholder="Placeholder" handleChange={setFirstText} />
<DaystarTextInput
placeholder="5글자 미만이면 Error"
errorMessage={secondHasError ? "5글자 이상 입력해주세요" : ""}
handleChange={handleSecondTextChange}
/>
<DaystarTextInput placeholder="Disabled" disabled />
<DaystarItemNumberInput
label="Label"
value={firstItemNumber}
itemLimit={50}
unit="개"
placeholder="0개"
handleChange={handleFirstItemNumberChange}
/>
<DaystarItemNumberInput
label="Disabled"
itemLimit={50}
disabled
unit="개"
placeholder="0개"
handleChange={handleFirstItemNumberChange}
/>
<ItemNumberInput
label="기존 Component"
value={solItemNumber}
itemLimit={9}
unit="개"
placeholder="(기존) 0개"
handleChange={handleSolItemNumberChange}
/>
</DaystarWrapper>
);
};

export default Daystar;
Loading