Skip to content

(계정분리 관련) 게시물 작성자 고정 / CUD 구역 생성 #70

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

Merged
merged 45 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a1b281c
fix: 2차 비밀번호 삭제
Gwak-Seungju Nov 11, 2024
379c474
feat: 히스토리 카테고리 추가
Gwak-Seungju Nov 11, 2024
12a226f
feat: 로그아웃 구현
Gwak-Seungju Nov 12, 2024
4939b2b
fix: 로그아웃 시 refreshToken 삭제
Gwak-Seungju Nov 12, 2024
e3d56ca
feat: 비밀번호 변경, 로그아웃 버튼 추가
Gwak-Seungju Nov 12, 2024
d85c1b8
feat: 비밀번호 변경 api 연결
Gwak-Seungju Nov 12, 2024
6f4f08c
feat: 비밀번호 변경 모달 생성
Gwak-Seungju Nov 12, 2024
3b01170
feat: 모달 내 취소하기 버튼 추가
Gwak-Seungju Nov 13, 2024
658b5f9
refactor: 파일명, 컴포넌트명 일치
Gwak-Seungju Nov 13, 2024
81e2de8
refactor: Form.Item에 dependencies 추가
Gwak-Seungju Nov 13, 2024
67d92b1
fix: dependencies 속성 추가
Gwak-Seungju Nov 14, 2024
74127bb
refactor: 로그아웃 함수 직접 정의
Gwak-Seungju Nov 14, 2024
dc6868d
refactor: 변수명 수정
Gwak-Seungju Nov 14, 2024
df357a0
refactor: 불필요 로직 삭제
Gwak-Seungju Nov 15, 2024
043a764
fix: store state 변경 훅 사용
Gwak-Seungju Nov 15, 2024
8e2eede
refactor: form 태그 대신 CustomForm 사용
Gwak-Seungju Nov 18, 2024
d5732cc
refactor: useValidate 유틸함수로 변경
Gwak-Seungju Nov 19, 2024
53ce547
refactor: 나머지 매개변수와 중복 선언 제거
Gwak-Seungju Nov 19, 2024
812de1b
Merge branch 'develop' into feat/separate-account
Gwak-Seungju Nov 19, 2024
bd5d880
feat: admin 정보 api 연결
Gwak-Seungju Nov 19, 2024
d3b088c
fix: icon 모달 사용 시 아이콘을 사용하지 않는 경우 추가
Gwak-Seungju Nov 19, 2024
bea2294
fix: hasIcon 속성 default값 추가
Gwak-Seungju Nov 19, 2024
30ce1fe
fix: antd Button 컴포넌트 사용
Gwak-Seungju Nov 19, 2024
b68aa23
refactor: auth 관련 로직 rtk acitons으로
Gwak-Seungju Nov 19, 2024
0c822bf
fix: ab테스트 작성자 변경불가하게
Gwak-Seungju Nov 20, 2024
54bed6f
feat: historys api 연결
Gwak-Seungju Nov 20, 2024
bb46a3b
chore: antd 버전 업데이트
Gwak-Seungju Nov 20, 2024
40041e8
fix: history api url 수정
Gwak-Seungju Nov 25, 2024
577499e
feat: 세부사항 내 히스토리 구역 컴포넌트
Gwak-Seungju Nov 25, 2024
e459579
feat: AB테스트 게시물 내 cud 구역 추가
Gwak-Seungju Nov 25, 2024
4b238e1
feat: 공지사항 게시물 내 cud 구역 추가
Gwak-Seungju Nov 25, 2024
bb47717
refetch안되는 현상 수정
Gwak-Seungju Nov 25, 2024
ef8c3be
refactor: 조건문 간소화
Gwak-Seungju Nov 25, 2024
7691566
Merge pull request #63 from BCSDLab/feat/separate-account
Gwak-Seungju Nov 26, 2024
3bdb16a
feat: admin 정보 api 연결
Gwak-Seungju Nov 26, 2024
dad6dcd
fix: ab테스트 작성자 변경불가하게
Gwak-Seungju Nov 26, 2024
e3665d2
feat: historys api 연결
Gwak-Seungju Nov 26, 2024
4b29106
chore: antd 버전 업데이트
Gwak-Seungju Nov 26, 2024
765f31a
fix: history api url 수정
Gwak-Seungju Nov 26, 2024
b913faf
feat: 세부사항 내 히스토리 구역 컴포넌트
Gwak-Seungju Nov 26, 2024
23cb194
feat: AB테스트 게시물 내 cud 구역 추가
Gwak-Seungju Nov 26, 2024
77e1ab1
feat: 공지사항 게시물 내 cud 구역 추가
Gwak-Seungju Nov 26, 2024
93a557c
refetch안되는 현상 수정
Gwak-Seungju Nov 26, 2024
84fe8e1
refactor: 조건문 간소화
Gwak-Seungju Nov 26, 2024
2aa11b5
Merge branch 'feat/#65/fix-admin-info' of https://github.com/BCSDLab/…
Gwak-Seungju Nov 26, 2024
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
930 changes: 540 additions & 390 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"antd": "^5.11.2",
"antd": "^5.22.2",
"axios": "^0.27.2",
"dayjs": "^1.11.7",
"dayjs": "^1.11.13",
"eslint-plugin-jest": "^27.6.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
18 changes: 18 additions & 0 deletions src/components/common/HistoryArea/HistoryArea.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Card } from 'antd';
import styled from 'styled-components';

// eslint-disable-next-line import/prefer-default-export
export const HistoryArea = styled(Card)`
position: absolute;
bottom: 0;
right: 0;
z-index: 5;
width: 300px;
height: 110px;
overflow: auto;
border: none;

.ant-card-body {
padding: 0;
}
`;
25 changes: 25 additions & 0 deletions src/components/common/HistoryArea/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { List } from 'antd';
import { CardProps } from 'antd/lib';
import { HistoryInfo } from 'model/history.model';
import * as S from './HistoryArea.style';

interface HistoryAreaProps {
historys: HistoryInfo[],
creator?: string,
created_at?: string,
}

export default function HistoryArea({
historys, creator, created_at, ...args
}: HistoryAreaProps & CardProps) {
return (
<S.HistoryArea {...args}>
<List
dataSource={historys}
renderItem={(item) => <List.Item style={{ padding: '0', border: 'none' }}>{`${item.created_at} ${item.request_method} (${item.name})`}</List.Item>}
locale={{ emptyText: ' ' }}
/>
<div>{`${created_at} 생성 (${creator})`}</div>
</S.HistoryArea>
);
}
10 changes: 10 additions & 0 deletions src/model/auth.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ export interface LoginRequest {
email: string
password: string
}

export interface AdminInfo {
id: number;
email: string;
name: string;
track_name: string;
team_name: string;
can_create_admin: boolean;
super_admin: boolean;
}
25 changes: 25 additions & 0 deletions src/model/history.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export interface HistoryInfo {
id: number;
domain_id: number;
name: string;
domain_name: string;
request_method: string;
request_message: string;
created_at: string;
}

export interface HistorysRequest {
page: number;
limit?: number;
requestMethod?: string;
domainName?: string;
domainId?: number;
}

export interface HistorysResponse {
total_count: number;
current_count: number;
total_page: number;
current_page: number;
historys: HistoryInfo[];
}
9 changes: 9 additions & 0 deletions src/pages/ABTest/components/ABTestDetail.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from 'styled-components';

export * from './DeleteWarning.style';

export * from 'components/common/HistoryArea/HistoryArea.style';

export const Container = styled.div`
position: relative;
`;
19 changes: 15 additions & 4 deletions src/pages/ABTest/components/ABTestDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import {
} from '@ant-design/icons';
import { useNavigate, useParams } from 'react-router-dom';
import CustomForm from 'components/common/CustomForm';
import HistoryArea from 'components/common/HistoryArea';
import { useGetABTestQuery } from 'store/api/abtest';
import { useGetHistorysQuery } from 'store/api/history';
import { ABTest } from 'model/abTest.model';
import useBooleanState from 'utils/hooks/useBoolean';
import useABTestMutation from './hook/useABTestMutation';
import * as S from './DeleteWarning.style';
import * as S from './ABTestDetail.style';
import UserManageModal from './UserManageModal';

interface Variable {
Expand All @@ -31,6 +33,7 @@ export default function ABTestDetail() {
const [variables, setVariables] = useState<Variable[]>([]);
const [sliderValues, setSliderValues] = useState<number[]>([]);
const [winner, setWinner] = useState<string>('');
const { data: historys } = useGetHistorysQuery({ page: 1, domainId: Number(id) });

// eslint-disable-next-line max-len
const { value: checkModal, setTrue: checkModalOpen, setFalse: checkModalClose } = useBooleanState();
Expand Down Expand Up @@ -135,14 +138,14 @@ export default function ABTestDetail() {
};

return (
<>
<S.Container>
<CustomForm form={form} onFinish={onFinish}>
<Divider orientation="left">세부사항</Divider>
{renderStatusTag()}
<br />
<br />
<CustomForm.Input label="id" name="id" disabled />
<CustomForm.Input label="작성자" name="creator" maxLength={50} />
<CustomForm.Input label="작성자" name="creator" maxLength={50} disabled />
<CustomForm.Input label="소속팀" name="team" maxLength={50} />
<CustomForm.Input label="AB테스트의 제목" name="display_title" maxLength={255} />
<CustomForm.Input label="변수" name="title" disabled maxLength={255} />
Expand Down Expand Up @@ -220,6 +223,14 @@ export default function ABTestDetail() {
>
실험 인원 수동 추가, 수정 하기
</Button>
{(historys && abTestData) && (
<HistoryArea
historys={historys.historys}
creator={abTestData.creator}
created_at={abTestData.created_at}
/>
)}

<Modal
open={checkModal}
onCancel={checkModalClose}
Expand Down Expand Up @@ -276,6 +287,6 @@ export default function ABTestDetail() {
</S.Item>
</S.AroundRow>
</Modal>
</>
</S.Container>
);
}
6 changes: 2 additions & 4 deletions src/pages/ABTest/components/AddABTestModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import * as S from './AddABTestModal.style';
import NewTest from './NewTest';
import useABTestMutation from './hook/useABTestMutation';

function AddABTestModal({ onCancel }: { onCancel: () => void }) {
function AddABTestModal({ onCancel, creator }: { onCancel: () => void, creator: string }) {
const [form] = CustomForm.useForm();
const [step, setStep] = useState(1);
const [title, setTitle] = useState('');
const [creator, setCreator] = useState('');
const [team, setTeam] = useState('');
const [displayTitle, setDisplayTitle] = useState('');
const [description, setDescription] = useState('');
Expand Down Expand Up @@ -80,7 +79,6 @@ function AddABTestModal({ onCancel }: { onCancel: () => void }) {
form.resetFields();
setStep(1);
setTitle('');
setCreator('');
setTeam('');
setDisplayTitle('');
setDescription('');
Expand Down Expand Up @@ -126,7 +124,7 @@ function AddABTestModal({ onCancel }: { onCancel: () => void }) {
{step === 1 && (
<S.StepContainer>
<S.Label>작성자</S.Label>
<S.Input onChange={(e) => setCreator(e.target.value)} maxLength={10} />
<S.Input value={creator} maxLength={10} disabled />
<S.Label>소속팀</S.Label>
<S.Input onChange={(e) => setTeam(e.target.value)} maxLength={10} />
<S.Label>AB테스트의 제목</S.Label>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/ABTest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import CustomForm from 'components/common/CustomForm';
import CustomTable from 'components/common/CustomTable';
import { useState } from 'react';
import { useGetABTestsQuery } from 'store/api/abtest';
import { useGetAdminInfoQuery } from 'store/api/auth';
import useBooleanState from 'utils/hooks/useBoolean';
import * as S from './ABTest.style';
import AddABTestModal from './components/AddABTestModal';
Expand All @@ -10,6 +11,7 @@ export default function ABTest() {
const [page, setPage] = useState(1);
const { data: abtestList } = useGetABTestsQuery({ page, limit: 10 });
const { value: isModalOpen, setTrue: openModal, setFalse: closeModal } = useBooleanState();
const { data: adminInfo } = useGetAdminInfoQuery();
return (
<S.Container>
<CustomForm.Modal
Expand All @@ -21,7 +23,7 @@ export default function ABTest() {
onCancel={closeModal}
onClick={openModal}
>
<AddABTestModal onCancel={closeModal} />
<AddABTestModal onCancel={closeModal} creator={adminInfo?.name || ''} />
</CustomForm.Modal>
{abtestList && (
<CustomTable
Expand Down
12 changes: 11 additions & 1 deletion src/pages/Services/Notice/NoticeDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
import { Editor } from '@toast-ui/react-editor';
import { useUploadfileMutation } from 'store/api/upload';
import { NoticeRequest, NoticeUpdateForm } from 'model/notice.model';
import { useGetHistorysQuery } from 'store/api/history';
import HistoryArea from 'components/common/HistoryArea';
import useNoticeMutation from './useNoticeMutation';
import * as S from './NoticeDetail.style';

Expand All @@ -27,6 +29,7 @@ export default function NoticeDetail() {
const [uploadfile] = useUploadfileMutation();
const { required } = CustomForm.useValidate();
const [form] = CustomForm.useForm();
const { data: historys } = useGetHistorysQuery({ page: 1, domainId: Number(id) });

const handleFinish = (values: NoticeRequest) => {
const editorContent = editorRef.current?.getInstance().getHTML();
Expand Down Expand Up @@ -113,7 +116,14 @@ export default function NoticeDetail() {
{isEditing ? '저장' : '수정'}
</CustomForm.Button>
</S.ButtonWrapper>

{historys && (
<HistoryArea
historys={historys.historys}
creator={notice.author}
created_at={notice.created_at}
style={{ left: '20px', bottom: '-70px' }}
/>
)}
<Modal
title="공지사항 삭제 확인"
open={isModalOpen}
Expand Down
13 changes: 11 additions & 2 deletions src/store/api/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
BaseQueryFn, createApi, FetchArgs, fetchBaseQuery, FetchBaseQueryError,
} from '@reduxjs/toolkit/query/react';
import { LoginRequest, LoginResponse } from 'model/auth.model';
import { LoginRequest, LoginResponse, AdminInfo } from 'model/auth.model';
import { RootState } from 'store';
import { API_PATH } from 'constant';
import { setCredentials } from 'store/slice/auth';
Expand Down Expand Up @@ -62,6 +62,8 @@ FetchBaseQueryError
};

export const authApi = createApi({
reducerPath: 'authApi',
tagTypes: ['admin'],
baseQuery: baseQueryReauth,
endpoints: (builder) => ({
login: builder.mutation<LoginResponse, LoginRequest>({
Expand All @@ -78,7 +80,14 @@ export const authApi = createApi({
protected: builder.mutation<{ message: string }, void>({
query: () => 'protected',
}),

getAdminInfo: builder.query<AdminInfo, void>({
query: () => ({
url: '',
}),
providesTags: [{ type: 'admin', id: 'ADMIN' }],
}),
}),
});

export const { useLoginMutation, useProtectedMutation } = authApi;
export const { useLoginMutation, useProtectedMutation, useGetAdminInfoQuery } = authApi;
24 changes: 24 additions & 0 deletions src/store/api/history/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createApi } from '@reduxjs/toolkit/query/react';
import { HistorysRequest, HistorysResponse } from 'model/history.model';
import baseQueryReauth from 'store/api/baseQueryReauth';

export const historyApi = createApi({
reducerPath: 'historyApi',
tagTypes: ['historys'],

baseQuery: baseQueryReauth,

endpoints: (builder) => ({
getHistorys: builder.query<HistorysResponse, HistorysRequest>({
query: ({ page, domainId = null, limit = 30 }) => ({
url: `admin/historys?page=${page}&limit=${limit}${domainId ? `&domainId=${domainId}` : ''}`,
}),
providesTags: [{ type: 'historys', id: 'HISTORYS' }],
}),
}),
refetchOnMountOrArgChange: true,
});

export const {
useGetHistorysQuery,
} = historyApi;
2 changes: 2 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { abTestApi } from './api/abtest';
import { benefitApi } from './api/benefit';
import { forceUpdateApi } from './api/forceUpdate';
import { updateListApi } from './api/updateList';
import { historyApi } from './api/history';

const apiList = [
authApi,
Expand All @@ -36,6 +37,7 @@ const apiList = [
benefitApi,
forceUpdateApi,
updateListApi,
historyApi,
];

const apiMiddleware = apiList.map((api) => api.middleware);
Expand Down
1 change: 1 addition & 0 deletions src/styles/Detail.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from 'styled-components';

export const Container = styled.div`
font-family: "Noto Sans KR", "Avenir", "Helvetica", "Arial", "sans-serif";
position: relative;
`;

export const BreadCrumb = styled.div`
Expand Down
Loading
Loading