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

데이터 관련 이것저것 #105

Merged
merged 6 commits into from
Aug 18, 2024
Merged
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
38 changes: 37 additions & 1 deletion src/features/content/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ import {
GetNoticeDetailResData,
GetEventDetailResData,
GetTransactionDetailResData,
GetRuleDetailResData,
GetProceedingDetailResData,
} from './types';
import { EVENT_DETAIL_API, NOTICE_DETAIL_API, TRANSACTION_DETAIL_API } from '.';
import {
EVENT_DETAIL_API,
NOTICE_DETAIL_API,
PROCEEDING_DETAIL_API,
RULE_DETAIL_API,
TRANSACTION_DETAIL_API,
} from '.';

//학교 공지 detail
export const useGetCampusNoticeDetail = (
Expand Down Expand Up @@ -68,3 +76,31 @@ export const useGetTransactionDetail = (
...options,
});
};

export const useGetProceedingDetail = (
proceedingId: number,
options?: UseQueryOptions<GetProceedingDetailResData, AxiosError>,
) => {
return useQuery({
queryKey: ['proceedingDetail', proceedingId],
queryFn: async () => {
const data = await PROCEEDING_DETAIL_API.proceedingDetail(proceedingId);
return data;
},
...options,
});
};

export const useGetRuleDetail = (
ruleId: number,
options?: UseQueryOptions<GetRuleDetailResData, AxiosError>,
) => {
return useQuery({
queryKey: ['ruleDetail', ruleId],
queryFn: async () => {
const data = await RULE_DETAIL_API.ruleDetail(ruleId);
return data;
},
...options,
});
};
9 changes: 2 additions & 7 deletions src/features/content/model/usePdfDetail.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useGetRuleDetail, useGetProceedingDetail } from '../api/queries';

const usePdfDetail = () => {
//회칙/학칙 detail
const returnRuleDetailItem = (organization: string, id: number) => {
Expand Down Expand Up @@ -49,10 +51,3 @@ const usePdfDetail = () => {
};

export default usePdfDetail;
function useGetRuleDetail(id: number): { data: any; isSuccess: any } {
throw new Error('Function not implemented.');
}

function useGetProceedingDetail(id: number): { data: any; isSuccess: any } {
throw new Error('Function not implemented.');
}
20 changes: 18 additions & 2 deletions src/features/content/ui/CommonDetailComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import DateText from '@/widgets/DateText';
import Title from '@/widgets/Title';
import { formatDate } from '@/shared/lib/utils';
Expand All @@ -6,12 +8,18 @@ import ReactMarkdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';
import { TbDownload } from 'react-icons/tb';
import { CommonDetailItem } from '../api/types';
import { usePathname } from 'next/navigation';

const CommonDetailComponent = ({
content: data,
}: {
content: CommonDetailItem | undefined;
}) => {
const pathname = usePathname();
const isEventDetailPage = pathname.includes('event');

const arr = [1, 2, 3, 4, 5, 6, 2];

if (data) {
return (
<div className="flex flex-col space-y-3">
Expand All @@ -29,13 +37,21 @@ const CommonDetailComponent = ({
</div>
</div>
<hr />
<div className="p-5 text-md">
<div className="p-5 text-md flex flex-col gap-4">
<ReactMarkdown rehypePlugins={[rehypeRaw]}>
{data.content}
</ReactMarkdown>
<div className="flex flex-col gap-2">
{isEventDetailPage &&
data.fileInfo.length > 0 &&
data.fileInfo.map((data, index) => (
<img src={data.url} key={index} className="w-70" />
))}
</div>
</div>
<hr />
{data.fileInfo.length > 0 &&
{!isEventDetailPage &&
data.fileInfo.length > 0 &&
data.fileInfo.map((data, index) => (
<a
className="flex flex-row items-center gap-1 pt-2 text-sm"
Expand Down
3 changes: 1 addition & 2 deletions src/features/content/ui/PdfViewerDetailComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ const PdfViewerDetailComponent = ({
<DateText date={formatDate(item.createAt)} />
</div>
<hr />
<PdfViewer pdf="/static/test.pdf" />
<PdfViewer pdf={item.fileInfo[0].url} />
<hr />

<div className="flex justify-end">
<BackToListButton />
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/shared/api/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ instance.interceptors.response.use(
return;
}
}

if (
error.config.url.includes('transactions') ||
error.config.url.includes('notice') ||
error.config.url.includes('meetings') ||
error.config.url.includes('faq') ||
error.config.url.includes('event') ||
error.config.url.includes('rule') ||
error.config.url.includes('campusnotice')
) {
window.location.replace('/404');
}
return Promise.reject(error);
},
);