Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
55 changes: 55 additions & 0 deletions src/api/admin/banner.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { ApiBannerList } from '../../models/admin/banner';
import { httpClient } from '../http.api';

export const getBannerList = async () => {
try {
const response = await httpClient.get<ApiBannerList>('/banner');
console.log(response.data);
return response.data;
} catch (error) {
console.error(error);
throw error;
}
};

export const postBanner = async (formData: FormData) => {
try {
const response = await httpClient.post('/banner', formData);
return response.data;
} catch (error) {
console.error(error);
throw error;
}
};

export const patchBanner = async (formData: FormData, bannerId?: number) => {
try {
for (const [key, value] of formData.entries()) {
if (value instanceof File) {
console.log(`${key}:`, {
name: value.name,
size: value.size,
type: value.type,
lastModified: value.lastModified,
});
} else {
console.log(`${key}:`, value);
}
}
const response = await httpClient.patch(`/banner/${bannerId}`, formData);
return response.data;
} catch (error) {
console.error(error);
throw error;
}
};

export const deleteBanner = async (bannerId?: number) => {
try {
const response = await httpClient.delete(`/banner/${bannerId}`);
return response.data;
} catch (error) {
console.error(error);
throw error;
}
};
247 changes: 247 additions & 0 deletions src/components/admin/banner/BannerList.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
import styled, { css } from 'styled-components';
import Button from '../../common/Button/Button';

export const AddButtonContainer = styled.div``;

export const AddButton = styled(Button)``;

export const Container = styled.table<{ $header?: boolean }>`
border-collapse: collapse;
table-layout: fixed;
border-radius: 8px;
overflow: hidden;
width: 100%;
margin-top: 10rem;
`;

export const TableHeader = styled.thead`
color: #ffffff;
`;

export const TableHeaderCell = styled.th`
padding: 16px;
font-size: 14px;
text-align: center;
`;

export const ScrollBody = styled.tbody``;

export const TableRow = styled.tr``;

export const TableCell = styled.td`
padding: 14px;
font-size: 14px;
text-align: center;
color: #333;
vertical-align: middle;
`;

export const ImageCell = styled(TableCell)`
position: relative;
height: 120px;
padding: 0;
width: 280px;
`;

export const ImageUploadArea = styled.div`
position: relative;
width: 100%;
height: 120px;
cursor: pointer;
border-radius: 6px;
overflow: hidden;
`;

export const Thumbnail = styled.img`
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 6px;
`;

export const ImageOverlay = styled.div`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
`;

export const EditIcon = styled.div`
display: flex;
align-items: center;
justify-content: center;
color: white;
`;

export const ImageLabel = styled.div`
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-weight: 600;
font-size: 15px;
text-shadow: 0 0 5px rgba(0, 0, 0, 0.6);
`;

export const PlusButton = styled.div`
width: 100%;
height: 120px;
border: 2px dashed #ccc;
font-size: 32px;
color: #888;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease-in-out;

&:hover {
border-color: #6c5ce7;
color: #6c5ce7;
background-color: rgba(108, 92, 231, 0.1);
}
`;

export const ToggleSwitch = styled.div`
position: relative;
width: 50px;
height: 24px;

input {
opacity: 0;
width: 0;
height: 0;
}

label {
position: absolute;
background: #ccc;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

하드코딩된 색상 대신 테마 변수 사용

일관된 테마 관리를 위해 하드코딩된 색상값을 테마 변수로 교체해야 합니다.

   label {
     position: absolute;
-    background: #ccc;
+    background: ${({ theme }) => theme.color.gray300};
     border-radius: 999px;
     width: 100%;
     height: 100%;
     cursor: pointer;
     transition: background 0.2s ease-in-out;
   }

   input:checked + label {
-    background-color: #6c5ce7;
+    background-color: ${({ theme }) => theme.buttonScheme.primary.bg};
   }

Also applies to: 152-152

🤖 Prompt for AI Agents
In src/components/admin/banner/BannerList.styled.ts at lines 131 and 152,
replace the hardcoded background color #ccc with the appropriate theme variable
to ensure consistent theming. Identify the correct color variable from the theme
object and use it instead of the literal color code in the styled component.

border-radius: 999px;
width: 100%;
height: 100%;
cursor: pointer;
transition: background 0.2s ease-in-out;
}

label::after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 20px;
height: 20px;
background: #fff;
border-radius: 50%;
transition: transform 0.2s ease-in-out;
}

input:checked + label {
background-color: #6c5ce7;
}

input:checked + label::after {
transform: translateX(26px);
}
`;

export const RadioGroup = styled.div`
display: flex;
justify-content: center;
gap: 12px;
font-size: 14px;

input {
display: none;
}

label {
position: relative;
padding-left: 22px;
cursor: pointer;

&::before {
content: '';
position: absolute;
left: 0;
top: 2px;
width: 16px;
height: 16px;
border: 2px solid #666;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

RadioGroup에서도 테마 변수 사용 필요

RadioGroup 컴포넌트에서도 하드코딩된 색상을 테마 변수로 교체해주세요.

       width: 16px;
       height: 16px;
-      border: 2px solid #666;
+      border: 2px solid ${({ theme }) => theme.color.gray600};
       border-radius: 50%;
     }

     &::after {
       content: '';
       position: absolute;
       left: 4px;
       top: 6px;
       width: 8px;
       height: 8px;
-      background-color: #6c5ce7;
+      background-color: ${({ theme }) => theme.buttonScheme.primary.bg};
       border-radius: 50%;
       opacity: 0;
     }

Also applies to: 193-193

🤖 Prompt for AI Agents
In src/components/admin/banner/BannerList.styled.ts at lines 182 and 193,
replace the hardcoded color value #666 used in the border property of the
RadioGroup component with the appropriate color variable from the theme. Access
the theme object and use its color property instead of the fixed hex code to
ensure consistent theming.

border-radius: 50%;
}

&::after {
content: '';
position: absolute;
left: 4px;
top: 6px;
width: 8px;
height: 8px;
background-color: #6c5ce7;
border-radius: 50%;
opacity: 0;
}
}

input:checked + label::after {
opacity: 1;
}
`;

export const DateRange = styled.div`
display: flex;
align-items: center;
justify-content: center;
gap: 8px;

span {
font-size: 14px;
}
`;
export const DateInput = styled.input`
width: 120px;
height: 36px;
padding: 0 12px;
font-size: 14px;
border-radius: 18px;
border: 1px solid #ccc;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

DateInput 테두리 색상도 테마 변수 사용

날짜 입력 필드의 테두리 색상도 테마를 사용해주세요.

   font-size: 14px;
   border-radius: 18px;
-  border: 1px solid #ccc;
+  border: 1px solid ${({ theme }) => theme.color.gray300};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
border: 1px solid #ccc;
font-size: 14px;
border-radius: 18px;
border: 1px solid ${({ theme }) => theme.color.gray300};
🤖 Prompt for AI Agents
In src/components/admin/banner/BannerList.styled.ts at line 220, the border
color for the DateInput is hardcoded as #ccc. Replace this hardcoded color with
the appropriate theme variable for border color to ensure consistent theming
across the application.

`;

const buttonBase = css`
padding: 8px 16px;
font-size: 14px;
border-radius: ${({ theme }) => theme.borderRadius.primary};
color: ${({ theme }) => theme.color.white};
border: 1px solid ${({ theme }) => theme.color.white};
`;

export const EditButton = styled.button`
${buttonBase};
background-color: ${({ theme }) => theme.buttonScheme.primary.bg};
margin-right: 8px;
`;

export const DeleteButton = styled.button`
${buttonBase};
background-color: ${({ theme }) => theme.color.red};
`;

export const TableBody = styled.tbody``;

export const ButtonContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20px;
`;

export const CreateButton = styled(Button)``;

export const CancelButton = styled(Button)``;
Copy link
Collaborator

Choose a reason for hiding this comment

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

250과 중복입니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

감사합니다

Loading