Skip to content

Commit

Permalink
Merge branch 'feature' into FE/Feat/#124
Browse files Browse the repository at this point in the history
  • Loading branch information
sejongpark authored Dec 1, 2023
2 parents a8ca408 + f601b9e commit 36ced80
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 71 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
push:
branches: ["feature"]

name: Deploy achieve project to Amazon EC2
env:
PROJECT_NAME: achieve
BUCKET_NAME: ec2-s3-deploy-bucket
APPLICATION_NAME: achieve-deploy-app
DEPLOYMENT_GROUP_NAME: achieve-deploy-group

jobs:
deploy:
name: DEPLOY
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Make application.yml
run: echo "${{ secrets.APPLICATION_PROD }}" > ./backend/src/main/resources/application-prod.yml

- name: Make aws RDS env file
run: echo "${{ secrets.AWS_RDS }}" > ./.env

- name: Grant execute permission for gradlew
run: chmod +x ./backend/gradlew
shell: bash

- name: Build with Gradle
run: |
cd backend
./gradlew clean bootJar --exclude-task test
shell: bash

- name: Make zip file
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip

- name: Code Deploy
run: aws deploy create-deployment --application-name $APPLICATION_NAME --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip --ignore-application-stop-failures
20 changes: 20 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.0
os: linux

files:
- source: /
destination: /opt/achieve/project
file_exists_behavior: OVERWRITE
permissions:
- object: /opt/achieve/project
owner: ubuntu
group: ubuntu
mode: 755
hooks:
BeforeInstall:
- location: scripts/before_install.sh

AfterInstall:
- location: scripts/deploy.sh
# timeout: 60
runas: root
4 changes: 4 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ plugins {
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

jar {
enabled=false
}

group = 'backend'
version = '0.0.1-SNAPSHOT'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public ResponseEntity<List<ReservationResponse>> getReservationsByUserId() {
return ResponseEntity.ok(reservations);
}

//전체 예약 내역 조회
@GetMapping("/all")
public ResponseEntity<List<ReservationResponse>> getAllReservations() {
List<ReservationResponse> allReservations = reservationService.getAllReservations();
return ResponseEntity.ok(allReservations);
}

//예약 취소
@DeleteMapping("/{reservationId}")
public ResponseEntity<String> cancelReservation(@PathVariable Long reservationId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
public class ReservationResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public List<ReservationResponse> getReservationsByUserId(Long userId) {
.collect(Collectors.toList());
}

public List<ReservationResponse> getAllReservations() {
List<Reservation> allReservations = reservationRepository.findAll();
return allReservations.stream()
.map(this::convertToResponse)
.collect(Collectors.toList());
}

public boolean cancelReservation(Long reservationId) {
Long userId = (long) session.getAttribute("userId");
User user = userService.findById(userId);
Expand Down
2 changes: 1 addition & 1 deletion devops/nginx/prod/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM nginx:latest

RUN rm -rf /etc/nginx/conf.d/default.conf

COPY ./nginx_develop.conf /etc/nginx/nginx.conf
COPY ./nginx_production.conf /etc/nginx/nginx.conf

EXPOSE 80
File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
- "80:80"
- "443:443"
volumes:
- ./devops/nginx/prod/nginx_develop.conf:/etc/nginx/nginx.conf
- ./devops/nginx/prod/nginx_production.conf:/etc/nginx/nginx.conf
- ./devops/nginx/certbot/conf:/etc/letsencrypt
- ./devops/nginx/certbot/www:/var/www/certbot
- build_folder:/var/www/frontend
Expand Down
28 changes: 14 additions & 14 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions frontend/src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,18 @@ const StyledNav = styled.nav`
`;
const Header = () => {
const [isLoggedIn, setIsLoggedIn] = useState(false);

useEffect(() => {
axios
.get('http://localhost:8080/api/users/login-confirm')
.then((response) => {
if (response.data.loggedIn) {
setIsLoggedIn(true);
} else {
setIsLoggedIn(false);
}
setIsLoggedIn(response.data.loggedIn);
})
.catch((error) => {
console.error('로그인 상태 확인 중 에러:', error);
setIsLoggedIn(false);
});
}, [isLoggedIn]);
}, []);

return (
<StyledHeaderBorder>
Expand All @@ -68,9 +65,11 @@ const Header = () => {
<Link to="/Community">Community</Link>
</li>
{isLoggedIn ? (
<li>
<Link to="/Mypage">Mypage</Link>
</li>
<>
<li>
<Link to="/Mypage">Mypage</Link>
</li>
</>
) : (
<>
<li>
Expand All @@ -87,4 +86,7 @@ const Header = () => {
</StyledHeaderBorder>
);
};

export default Header;

export {};
22 changes: 21 additions & 1 deletion frontend/src/pages/BannerSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import axios from '../util/axiosConfig';

const BannerSlider: React.FC = () => {
const settings = {
Expand Down Expand Up @@ -134,6 +135,25 @@ const BannerSlider: React.FC = () => {
color: inherit;
`;

const handleReservationClick = async () => {
try {
const response = await axios.get('http://localhost:8080/api/users/login-confirm');
const isLoggedIn = response.data.loggedIn; // API에서 받은 로그인 상태

if (!isLoggedIn) {
// 로그인되어 있지 않으면 로그인 페이지로 이동
window.location.href = '/login';
} else {
// 로그인되어 있을 때 예약 페이지로 이동
window.location.href = '/select';
}
} catch (error) {
console.error('로그인 상태 확인 중 에러:', error);
// 에러 발생 시 로그인 페이지로 이동
window.location.href = '/login';
}
};

return (
<Banner>
<StyledSlider {...settings}>
Expand All @@ -150,7 +170,7 @@ const BannerSlider: React.FC = () => {
<Text>SF5</Text>
</Background>
</StyledSlider>
<ReservationLink to="/select">
<ReservationLink to="/select" onClick={handleReservationClick}>
<RoundedRectangle>
<h3>스마트하게</h3>
<h2>동아리방 예약</h2>
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/pages/JoinPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const PasswordInput = styled(Input).attrs({ type: 'password', autoComplete: 'new
margin-bottom: 0px;
border-radius: 0;
`;

const JoinPage: React.FC = () => {
const [affiliation, setAffiliation] = useState('');
const [email, setEmail] = useState('');
Expand Down Expand Up @@ -129,15 +128,13 @@ const JoinPage: React.FC = () => {
}
}
};

const handleSendCodeClick: React.MouseEventHandler<HTMLButtonElement> = async () => {
try {
await sendCode();
} catch (error) {
console.error('handleSendCodeClick 오류:', (error as AxiosError).message);
}
};

const handleConfirmAuthClick = async () => {
try {
const response = await axios.post('http://achieve-project.store/api/email/verification/confirm', {
Expand All @@ -152,7 +149,6 @@ const JoinPage: React.FC = () => {
console.error('인증 확인 중 에러:', (error as AxiosError).message);
}
};

const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();

Expand All @@ -168,7 +164,6 @@ const JoinPage: React.FC = () => {
setIsModalOpen(true);

setModalContent('회원가입이 완료되었습니다.');

console.log('서버 응답:', response.data);
} catch (error) {
console.error('서버로의 데이터 전송 중 에러:', error);
Expand All @@ -178,7 +173,6 @@ const JoinPage: React.FC = () => {
console.error('비밀번호가 일치하지 않습니다.');
}
};

return (
<>
<Modal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)}>
Expand Down Expand Up @@ -253,5 +247,4 @@ const JoinPage: React.FC = () => {
</>
);
};

export default JoinPage;
Loading

0 comments on commit 36ced80

Please sign in to comment.