Skip to content

Commit 0e1cdc7

Browse files
authored
Merge pull request #19 from RJihyeon/fe/vite-react
Fe/vite react
2 parents 2a31cb9 + 31a5d77 commit 0e1cdc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6680
-984
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"deno.enable": false
3+
}

frontend/.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "next/typescript"]
3+
}

frontend/.gitignore

+40-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
1-
# dotenv environment variable files
2-
.env
3-
.env.development.local
4-
.env.test.local
5-
.env.production.local
6-
.env.local
7-
8-
# Fresh build directory
9-
_fresh/
10-
# npm dependencies
11-
node_modules/
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
32+
# env files (can opt-in for committing if needed)
33+
.env*
34+
35+
# vercel
36+
.vercel
37+
38+
# typescript
39+
*.tsbuildinfo
40+
next-env.d.ts

frontend/.vscode/extensions.json

-6
This file was deleted.

frontend/.vscode/settings.json

-20
This file was deleted.

frontend/.vscode/tailwind.json

-55
This file was deleted.

frontend/README.md

+30-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
# Fresh project
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
22

3-
Your new Fresh project is ready to go. You can follow the Fresh "Getting
4-
Started" guide here: https://fresh.deno.dev/docs/getting-started
3+
## Getting Started
54

6-
### Usage
5+
First, run the development server:
76

8-
Make sure to install Deno: https://deno.land/manual/getting_started/installation
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
916

10-
Then start the project:
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
1118

12-
```
13-
deno task start
14-
```
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
1535

16-
This will watch the project directory and restart as necessary.
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

frontend/api/upload.tsx

-74
This file was deleted.

frontend/app/api/upload.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import dotenv from 'dotenv';
2+
3+
dotenv.config();
4+
5+
export async function uploadFile(file: File): Promise<string> {
6+
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL;
7+
const AUTH_TOKEN = process.env.NEXT_PUBLIC_AUTH_TOKEN;
8+
9+
console.log('BASE_URL:', BASE_URL);
10+
console.log('AUTH_TOKEN:', AUTH_TOKEN);
11+
12+
if (!BASE_URL || !AUTH_TOKEN) {
13+
throw new Error('BASE_URL or AUTH_TOKEN is not defined in the environment variables.');
14+
}
15+
16+
const formData = new FormData();
17+
formData.append('audio_file', file);
18+
19+
const toUserId = 1; // Temporary user ID
20+
const url = `${BASE_URL}/voice?to_user_id=${toUserId}`;
21+
22+
try {
23+
const response = await fetch(url, {
24+
method: 'POST',
25+
headers: {
26+
Authorization: `Bearer ${AUTH_TOKEN}`,
27+
},
28+
body: formData,
29+
});
30+
31+
if (!response.ok) {
32+
const errorText = await response.text();
33+
throw new Error(`Failed to upload file: HTTP ${response.status}, ${errorText}`);
34+
}
35+
36+
const result = await response.json();
37+
console.log('Upload result:', result);
38+
return result.message || 'File uploaded successfully!';
39+
} catch (error) {
40+
if (error instanceof Error) {
41+
throw new Error(`Upload failed: ${error.message}`);
42+
}
43+
throw new Error('An unknown error occurred during upload.');
44+
}
45+
}

frontend/app/components/Button.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// components/Button.tsx
2+
"use client";
3+
4+
import React from 'react';
5+
6+
interface ButtonProps {
7+
onClick?: () => void;
8+
children: React.ReactNode;
9+
}
10+
11+
const Button: React.FC<ButtonProps> = ({ onClick, children }) => {
12+
return (
13+
<button onClick={onClick}
14+
className="px-4 py-2 border-red-300 bg-red-600 border-2 rounded-full hover:bg-gray-200 transition-colors text-white font-extrabold">
15+
{children}
16+
</button>
17+
);
18+
};
19+
20+
export default Button;

frontend/app/components/Counter.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// components/Counter.tsx
2+
3+
import React, { useState } from 'react';
4+
import { Button } from './Button';
5+
6+
interface CounterProps {
7+
initialCount: number;
8+
}
9+
10+
const Counter: React.FC<CounterProps> = ({ initialCount }) => {
11+
const [count, setCount] = useState(initialCount);
12+
13+
return (
14+
<div className="flex gap-8 py-6">
15+
<Button onClick={() => setCount(count - 1)}>-1</Button>
16+
<p className="text-3xl tabular-nums">{count}</p>
17+
<Button onClick={() => setCount(count + 1)}>+1</Button>
18+
</div>
19+
);
20+
};
21+
22+
export default Counter;

0 commit comments

Comments
 (0)