Skip to content

Commit 5cc56bd

Browse files
authored
Merge pull request #228 from boostcampwm-2024/feature-dev-hotfix
[feature-dev-hotfix] λΉ„νšŒμ› AI λ³€ν™˜ 블락
2 parents 7648c57 + fc2ff7b commit 5cc56bd

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

β€Žclient/src/components/MindMapMainSection/ControlSection/TextUpload.tsxβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default function TextUpload() {
1414
useUpload();
1515
const handleSocketEvent = useConnectionStore((state) => state.handleSocketEvent);
1616
const { open, openModal, closeModal } = useModal();
17+
const isAuthenticated = useConnectionStore((state) => state.token);
1718

1819
function textUploadValidation() {
1920
if (content.length < MIN_TEXT_UPLOAD_LIMIT) {
@@ -24,12 +25,12 @@ export default function TextUpload() {
2425
}
2526
function openConfirmModal() {
2627
if (availabilityInform) return;
28+
if (!textUploadValidation()) return;
2729
openModal();
2830
}
2931

3032
function handleAiProcessButton() {
3133
closeModal();
32-
if (!textUploadValidation()) return;
3334
updateErrorMsg("");
3435
handleSocketEvent({ actionType: "aiRequest", payload: { aiContent: content } });
3536
}
@@ -49,7 +50,7 @@ export default function TextUpload() {
4950
maxLength={MAX_TEXT_UPLOAD_LIMIT}
5051
/>
5152
<div className="flex justify-between text-grayscale-400">
52-
<p>AI λ³€ν™˜ 남은 횟수 : {aiCount}번</p>
53+
{isAuthenticated ? <p>AI λ³€ν™˜ 남은 횟수 : {aiCount}번</p> : <p>λΉ„νšŒμ›μ€ AI λ³€ν™˜ κΈ°λŠ₯을 μ‚¬μš©ν•  수 μ—†μ–΄μš”</p>}
5354
<p className="text-right text-grayscale-400">
5455
{content.length}/{MAX_TEXT_UPLOAD_LIMIT}
5556
</p>

β€Žclient/src/components/MindMapMainSection/ControlSection/VoiceFileUpload.tsxβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function VoiceFileUpload() {
2323
const { aiCount, updateLoadingStatus } = useNodeListContext();
2424
const handleSocketEvent = useConnectionStore((state) => state.handleSocketEvent);
2525
const propagateError = useConnectionStore((state) => state.propagateError);
26+
const isAuthenticated = useConnectionStore((state) => state.token);
2627
const [key, setKey] = useState(0);
2728

2829
function fileValidation(file) {
@@ -39,7 +40,6 @@ export default function VoiceFileUpload() {
3940

4041
async function sendAudioFile() {
4142
closeModal();
42-
if (!fileValidation(file)) return;
4343
updateErrorMsg("");
4444
handleSocketEvent({ actionType: "audioAiRequest" });
4545
try {
@@ -57,14 +57,19 @@ export default function VoiceFileUpload() {
5757

5858
function openConfirmModal() {
5959
if (availabilityInform) return;
60+
if (!fileValidation(file)) return;
6061
openModal();
6162
}
6263

6364
return (
6465
<>
6566
<div className="flex h-full flex-col text-grayscale-100">
6667
<UploadBox key={key} file={file} setFile={setFile} />
67-
<p className="mb-5 mt-1 text-grayscale-400">AI λ³€ν™˜ 남은 횟수 : {aiCount}번</p>
68+
{isAuthenticated ? (
69+
<p className="mb-5 mt-1 text-grayscale-400">AI λ³€ν™˜ 남은 횟수 : {aiCount}번</p>
70+
) : (
71+
<p className="mb-5 mt-1 text-grayscale-400">λΉ„νšŒμ›μ€ AI λ³€ν™˜ κΈ°λŠ₯을 μ‚¬μš©ν•  수 μ—†μ–΄μš”</p>
72+
)}
6873
<div className="mb-5 flex w-full flex-col gap-1">
6974
<Button
7075
className="rounded-xl bg-bm-blue p-3 transition hover:brightness-90"

β€Žclient/src/hooks/useUpload.tsβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function useUpload() {
88
const { aiCount } = useNodeListContext();
99
const [availabilityInform, setAvailabilityInform] = useState("");
1010
const [errorMsg, setErrorMsg] = useState("");
11+
const isAuthenticated = useConnectionStore((state) => state.token);
1112

1213
const ownerAvailability = role === "owner";
1314

@@ -24,6 +25,10 @@ export default function useUpload() {
2425
}
2526

2627
function checkAvailability() {
28+
if (!isAuthenticated) {
29+
setAvailabilityInform("λΉ„νšŒμ›μ€ AI λ³€ν™˜ κΈ°λŠ₯을 μ‚¬μš©ν•  수 μ—†μ–΄μš”");
30+
return;
31+
}
2732
if (!ownerAvailability) {
2833
setAvailabilityInform("λ§ˆμΈλ“œλ§΅ μ†Œμœ μžλ§Œ AI λ³€ν™˜μ„ ν•  수 μžˆμ–΄μš”");
2934
return;

0 commit comments

Comments
Β (0)