Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

โœจsmall ui fixes + auth api path change #38

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 46 additions & 6 deletions src/components/SellingItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ const SellingItem = ({ ItemInfo }: SellingItemProps) => {
setIsDropdownOpen(false);
};

const handleEditClick = (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
void navigate(`/itemedit/${ItemInfo.id}`);
};

const handleReserveClick = (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
// ๋กœ์ง ์ถ”๊ฐ€
Expand All @@ -52,6 +47,46 @@ const SellingItem = ({ ItemInfo }: SellingItemProps) => {
setIsDropdownOpen(false);
};

const handleEditClick = (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
void navigate(`/itemedit/${ItemInfo.id}`);
};

const handleDeleteClick = async () => {
try {
const token = localStorage.getItem('token');
if (token === null) {
throw new Error('ํ† ํฐ์ด ์—†์Šต๋‹ˆ๋‹ค.');
}
const response = await fetch(
`http://localhost:5173/api/item/delete/${ItemInfo.id}`,
{
method: 'DELETE',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
},
);

if (!response.ok) {
throw new Error('์‚ญ์ œ ์š”์ฒญ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.');
}

void navigate('/main');
} catch (error) {
console.error('์‚ญ์ œ ์ค‘ ์—๋Ÿฌ ๋ฐœ์ƒ:', error);
}
};

const handleDeleteClickWrapper = (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
setIsDropdownOpen(false);
if (window.confirm('์ •๋ง ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?')) {
void handleDeleteClick();
}
};

return (
<NavLink to={`/item/${ItemInfo.id}`} className={styles.navLink}>
<div className={styles.main}>
Expand Down Expand Up @@ -122,7 +157,12 @@ const SellingItem = ({ ItemInfo }: SellingItemProps) => {
<button className={styles.bluebutton} onClick={handleEditClick}>
๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ •
</button>
<button className={styles.redbutton}>์‚ญ์ œ</button>
<button
className={styles.redbutton}
onClick={handleDeleteClickWrapper}
>
์‚ญ์ œ
</button>
</div>
<button onClick={handleCancelClick} className={styles.cancelbutton}>
์ทจ์†Œ
Expand Down
1 change: 1 addition & 0 deletions src/css/ChatRoomPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.upperbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 15px;
position: sticky;
top: 0;
Expand Down
8 changes: 4 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StrictMode } from 'react';
//import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import { App } from './App';
Expand All @@ -8,7 +8,7 @@ const root = document.getElementById('root');
if (root === null) throw new Error('Root element not found');

createRoot(root).render(
<StrictMode>
<App />
</StrictMode>,
//<StrictMode>
<App />,
//</StrictMode>,
);
2 changes: 2 additions & 0 deletions src/pages/ChatRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
<img
src={leftarrow}
className={styles.icon}
onClick={() => void navigate(-1)}

onClick={handleBackClick}

Check failure on line 111 in src/pages/ChatRoomPage.tsx

View workflow job for this annotation

GitHub Actions / ci

JSX elements cannot have multiple attributes with the same name.

Check failure on line 111 in src/pages/ChatRoomPage.tsx

View workflow job for this annotation

GitHub Actions / ci

JSX elements cannot have multiple attributes with the same name.
></img>
<div className={styles.opponentinfo}>
<p className={styles.opponentnickname}>์ด๋ฃธ์ด</p>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/CommunityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { toolBarInfo } from '../typings/toolBar';

const communityPageToolBarInfo: toolBarInfo = {
path: '/community',
mainText: '๋Œ€ํ•™๋™',
mainText: localStorage.getItem('location') ?? '',
toolBarItems: [
{
pathTo: '/temp',
Expand Down
1 change: 1 addition & 0 deletions src/pages/ItemPostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const ItemPostPage = () => {
const data = (await response.json()) as ArticleResponse;
if (images.length > 0) {
console.info('์—…๋กœ๋“œ ์„ฑ๊ณต, ์‚ฌ์ง„ ์—…๋กœ๋“œ ์ค‘');
console.info(data.image_url);

const presignedUrls = data.image_url;
if (images.length !== presignedUrls.length)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const LoginPage = () => {

const handleLoginClick = async () => {
try {
const response = await fetch('http://localhost:5173/auth/sign/in', {
const response = await fetch('http://localhost:5173/api/auth/sign/in', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { toolBarInfo } from '../typings/toolBar';

const mainPageToolBarInfo: toolBarInfo = {
path: '/main',
mainText: '๋Œ€ํ•™๋™',
mainText: localStorage.getItem('location') ?? '',
toolBarItems: [
{
pathTo: '/temp',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RegisterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const LoginPage = () => {

const handleRegisterClick = async () => {
try {
const response = await fetch('http://localhost:5173/auth/sign/up', {
const response = await fetch('http://localhost:5173/api/auth/sign/up', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand Down
4 changes: 1 addition & 3 deletions src/pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import clockIcon from '../assets/clock_gray.svg';
import leftArrow from '../assets/leftarrow.svg';
import styles from '../css/SearchPage.module.css';

const tempLocation = '๋Œ€ํ•™๋™';

type stateProps = {
focusSearchBar: boolean;
query: string;
Expand Down Expand Up @@ -78,7 +76,7 @@ const SearchPage = () => {
type="search"
ref={searchInputRef}
className={styles.searchBar}
placeholder={`${tempLocation} ๊ทผ์ฒ˜์—์„œ ๊ฒ€์ƒ‰`}
placeholder={`${localStorage.getItem('location') ?? ''} ๊ทผ์ฒ˜์—์„œ ๊ฒ€์ƒ‰`}
value={query}
onChange={(e) => {
setQuery(e.target.value);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SettingsPage = () => {

const handleConfirmLogout = () => {
setIsLogoutPopupVisible(false);
localStorage.removeItem('token');
localStorage.clear();
void navigate('/');
console.info('๋กœ๊ทธ์•„์›ƒ ์„ฑ๊ณต!');
};
Expand Down
4 changes: 0 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export default defineConfig({
target: 'http://52.78.132.59:8080',
changeOrigin: true,
},
'/auth': {
target: 'http://52.78.132.59:8080',
changeOrigin: true,
},
},
},
});
Loading