Skip to content

Commit ed97dc2

Browse files
committed
feat: 개인후원자 목록 컴포넌트 추가
1 parent cb7bdcf commit ed97dc2

File tree

7 files changed

+42
-0
lines changed

7 files changed

+42
-0
lines changed

apps/pyconkr-admin/src/consts/mdx_components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ const PythonKRShopMDXComponents: MDXComponents = {
154154
Shop__Feature__ProductImageCardList: Shop.Components.Features.ProductImageCardList,
155155
Shop__Feature__OrderList: Shop.Components.Features.OrderList,
156156
Shop__Feature__UserInfo: Shop.Components.Features.UserInfo,
157+
Shop__Feature__PatronList: Shop.Components.Features.PatronList,
157158
};
158159

159160
export const PyConKRMDXComponents = {

apps/pyconkr/src/consts/mdx_components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ const PythonKRShopMDXComponents: MDXComponents = {
154154
Shop__Feature__ProductImageCardList: Shop.Components.Features.ProductImageCardList,
155155
Shop__Feature__OrderList: Shop.Components.Features.OrderList,
156156
Shop__Feature__UserInfo: Shop.Components.Features.UserInfo,
157+
Shop__Feature__PatronList: Shop.Components.Features.PatronList,
157158
};
158159

159160
export const PyConKRMDXComponents = {

packages/shop/src/apis/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ namespace ShopAPIs {
133133
`v1/orders/${data.order_id}/products/${data.order_product_relation_id}/options/`,
134134
data.options
135135
);
136+
137+
/**
138+
* 후원자 목록을 가져옵니다.
139+
*/
140+
export const listPatrons = (client: ShopAPIClient, year: number) => () => client.get<ShopSchemas.Patron[]>("v1/ext/patron/", { params: { year } });
136141
}
137142

138143
export default ShopAPIs;

packages/shop/src/components/features/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CartStatus as CartStatus_ } from "./cart";
22
import { OrderList as OrderList_ } from "./order";
3+
import { PatronList as PatronList_ } from "./patron_list";
34
import { ProductImageCardList as ProductImageCardList_, ProductList as ProductList_ } from "./product";
45
import { UserInfo as UserInfo_ } from "./user_status";
56

@@ -9,6 +10,7 @@ namespace FeatureComponents {
910
export const ProductList = ProductList_;
1011
export const ProductImageCardList = ProductImageCardList_;
1112
export const UserInfo = UserInfo_;
13+
export const PatronList = PatronList_;
1214
}
1315

1416
export default FeatureComponents;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { CircularProgress, Stack, Typography } from "@mui/material";
2+
import { ErrorBoundary, Suspense } from "@suspensive/react";
3+
import * as React from "react";
4+
5+
import ShopHooks from "../../hooks";
6+
7+
const InnerPatronList: React.FC<{ year: number }> = ErrorBoundary.with(
8+
{ fallback: <>개인후원자 목록을 불러오는 중 문제가 발생했습니다.</> },
9+
Suspense.with({ fallback: <CircularProgress /> }, ({ year }) => {
10+
const shopAPIClient = ShopHooks.useShopClient();
11+
const { data } = ShopHooks.usePatrons(shopAPIClient, year);
12+
return data.map((patron) => (
13+
<Stack key={patron.name} spacing={1} sx={{ my: 2 }}>
14+
<Typography variant="h6" fontWeight="700" children={patron.name} />
15+
{patron.contribution_message && <Typography variant="subtitle1" children={patron.contribution_message} />}
16+
</Stack>
17+
));
18+
})
19+
);
20+
21+
export const PatronList: React.FC<{ year: number }> = ({ year }) => <Stack children={<InnerPatronList year={year} />} />;

packages/shop/src/hooks/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const QUERY_KEYS = {
1212
PRODUCT_LIST: ["query", "shop", "products"],
1313
CART_INFO: ["query", "shop", "cart"],
1414
ORDER_LIST: ["query", "shop", "orders"],
15+
PATRONS: ["query", "shop", "patrons"],
1516
};
1617

1718
const MUTATION_KEYS = {
@@ -135,6 +136,12 @@ namespace ShopHooks {
135136
mutationFn: ShopAPIs.patchOrderOptions(client),
136137
meta: { invalidates: [QUERY_KEYS.ORDER_LIST] },
137138
});
139+
140+
export const usePatrons = (client: ShopAPIClient, year: number) =>
141+
useSuspenseQuery({
142+
queryKey: [...QUERY_KEYS.PATRONS, year],
143+
queryFn: ShopAPIs.listPatrons(client, year),
144+
});
138145
}
139146

140147
export default ShopHooks;

packages/shop/src/schemas/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ namespace ShopSchemas {
227227
}[];
228228
};
229229

230+
export type Patron = {
231+
name: string;
232+
contribution_message: string;
233+
};
234+
230235
export const isObjectErrorResponseSchema = (obj?: unknown): obj is ShopSchemas.ErrorResponseSchema => {
231236
return (
232237
R.isPlainObject(obj) &&

0 commit comments

Comments
 (0)