Skip to content

Commit

Permalink
WeddingPage 추가, FileApi.upload 개선, FileApi.getMusic 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhello0507 committed Jan 18, 2025
1 parent beba123 commit cd40bad
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import TemplateComponent from "@src/component/template/TemplateComponent";
import {dummyWedding} from "@remote/value/Wedding";
import TemplatesPage from "@page/templates/TemplatesPage";
import GlobalStyle from "@src/GlobalStyle";
import WeddingPage from "@page/wedding/WeddingPage";

const {Kakao} = window as any;

Expand Down Expand Up @@ -59,8 +60,10 @@ function App() {
{/*not found*/}
<Route path={'*'} element={<Navigate to={'/'}/>}/>

{/*temp*/}
<Route path={'template1'} element={(
{/*wedding*/}
{/*<Route path={'wedding'} element={}/>*/}
<Route path={'wedding/:url'} element={<WeddingPage/>}/>
<Route path={'sample'} element={(
<div style={{display: 'flex', justifyContent: 'center'}}>
<TemplateComponent wedding={dummyWedding}/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/component/template/component/PreviewTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {HTMLProps, useRef, useState} from 'react';
import React from 'react';
import Text from "@designsystem/component/text";
import {Column, Row} from "@designsystem/component/flexLayout";
import Icon, {IconType} from "@designsystem/foundation/icon";
Expand Down
30 changes: 30 additions & 0 deletions src/page/wedding/WeddingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, {useEffect, useState} from 'react';
import Wedding from "@remote/value/Wedding";
import weddingApi from "@remote/api/WeddingApi";
import {useParams} from "react-router-dom";
import {Row} from "@designsystem/component/flexLayout";
import TemplateComponent from "@src/component/template/TemplateComponent";

function WeddingPage() {
const {url} = useParams();
const [wedding, setWedding] = useState<Wedding>();

useEffect(() => {
if (!url) return;

(async () => {
const {data} = await weddingApi.getWedding(url);
setWedding(data);
})();
}, []);

return (
<Row $justifyContent={'center'}>
{wedding && (
<TemplateComponent wedding={wedding}/>
)}
</Row>
);
}

export default WeddingPage;
14 changes: 7 additions & 7 deletions src/remote/api/FileApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ class FileApi {
static PATH = 'file';

async upload(file: File): Promise<ResponseData<Upload>> {
const formData = new FormData();
formData.append('file', file);

const {data} = await customApi.post(`${FileApi.PATH}/upload`, formData, {
headers: {
"Content-Type": "multipart/form-data"
}
const {data} = await customApi.postForm(`${FileApi.PATH}/upload`, {
file
});
return data;
}

async getMusics(): Promise<ResponseData<string[]>> {
const {data} = await customApi.get(`${FileApi.PATH}/music`);
return data;
}
}

const fileApi = new FileApi();
Expand Down

0 comments on commit cd40bad

Please sign in to comment.