-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from sunnybraille/request
feat: updated UX
- Loading branch information
Showing
6 changed files
with
157 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import axios from "axios"; | ||
import { useLanguage } from "../LanguageContext"; | ||
import { useHighContrast } from "./HighContrastMode"; | ||
|
||
interface FileNameDisplayProps { | ||
fileId: string | null; | ||
} | ||
|
||
const FileNameDisplay: React.FC<FileNameDisplayProps> = ({ fileId }) => { | ||
const [fileName, setFileName] = useState<string>(""); | ||
const { language } = useLanguage(); | ||
const textClassName = language === "ko" ? "font-kor" : "font-eng"; | ||
const { isHighContrast } = useHighContrast(); | ||
|
||
useEffect(() => { | ||
const fetchFileName = async () => { | ||
if (!fileId) { | ||
console.error("No file ID provided"); | ||
return; | ||
} | ||
|
||
try { | ||
const apiUrl = process.env.REACT_APP_API_URL; // API 주소 | ||
const response = await axios.get(`${apiUrl}/translations/${fileId}`); | ||
const originalFileName = response.data.originalFileName; | ||
|
||
const fileNameWithoutExtension = originalFileName | ||
.split(".") | ||
.slice(0, -1) | ||
.join("."); | ||
setFileName(fileNameWithoutExtension); | ||
} catch (error) { | ||
console.error("파일 정보를 불러오는데 실패했습니다.", error); | ||
setFileName("파일 정보 조회 실패"); | ||
} | ||
}; | ||
|
||
fetchFileName(); | ||
}, [fileId]); | ||
|
||
return ( | ||
<div | ||
className={`${textClassName} ${ | ||
isHighContrast ? "text-yellow-300" : "text-neutral-800" | ||
} text-center text-base font-normal my-[10px]`} | ||
> | ||
{fileName ? `${fileName}.brf` : "파일 이름을 불러오는 중..."} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FileNameDisplay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters