Skip to content

Commit

Permalink
이미지 추가, cart 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinDog committed Aug 24, 2024
1 parent 433ccc0 commit 9d3856b
Show file tree
Hide file tree
Showing 18 changed files with 379 additions and 53 deletions.
Binary file added public/icons/left_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/logo_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/logo_gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/app/scene/scene.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@
</div>
</div>
</div>

<router-outlet />
12 changes: 7 additions & 5 deletions src/app/scene/scene.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { FormsModule } from '@angular/forms';
import Swiper from 'swiper';
import { Navigation, Pagination, Mousewheel } from 'swiper/modules';
import { API } from '../AxiosRestApi';
import { Router } from '@angular/router';
import { Router, RouterOutlet } from '@angular/router';
@Component({
selector: 'main-coupang',
standalone: true,
imports: [FormsModule, CommonModule],
imports: [FormsModule, CommonModule, RouterOutlet],
templateUrl: './scene.component.html',
styleUrl: './scene.component.css',
})
Expand Down Expand Up @@ -92,11 +92,13 @@ export class scene implements OnInit {
const result = this.startX - lastX;
if (result > 100) {
//left
alert('left');
this.router.navigate(['cart']);
} else if (result <= -100) {
//right
console.log('right');
this.router.navigate(['/cart']);
if (this.swiper) {
const id = this.slides[this.swiper.activeIndex].id;
this.api.addCart(1, id);
}
}
this.startX = 0;
const sceneElement = document.querySelector(
Expand Down
16 changes: 16 additions & 0 deletions src/app/AxiosRestApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ export class API {
console.log(e);
});
};
public getCart = (usrId: number) => {
let usrLink = this.link.concat('/cart/').concat(usrId.toString());
return axios.get(usrLink, {
headers: {
'Content-Type': `application/json`,
'ngrok-skip-browser-warning': '69420',
},
});
};
public addCart = (usrId: number, prodId: number) => {
let usrLink = this.link.concat('/cart');
return axios.post(usrLink, {
user_id: usrId,
product_id: prodId,
});
};
}
4 changes: 1 addition & 3 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<main class="main">
<main-coupang></main-coupang>
<router-outlet />
</main>

<router-outlet />
11 changes: 8 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { Router, RouterOutlet } from '@angular/router';
import { scene } from './scene/scene.component';
import { CartComponent } from './cart/cart.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, scene],
imports: [RouterOutlet, scene, CartComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.css',
})
export class AppComponent {}
export class AppComponent {
constructor(private router: Router) {
this.router.navigate(['scene']);
}
}
5 changes: 3 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { scene } from './scene/scene.component';
import { CartComponent } from './cart/cart.component';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
declarations: [AppComponent, CartComponent, scene],
imports: [BrowserModule, CartComponent, scene],
providers: [],
bootstrap: [AppComponent],
})
Expand Down
7 changes: 4 additions & 3 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { BasketComponent } from './basket/basket.component';

import { CartComponent } from './cart/cart.component';
import { scene } from './\bscene/scene.component';
export const routes: Routes = [
{ path: '', component: AppComponent },
{ path: 'cart', component: BasketComponent },
{ path: 'scene', component: scene },
{ path: 'cart', component: CartComponent },
];
Empty file.
1 change: 0 additions & 1 deletion src/app/basket/basket.component.html

This file was deleted.

23 changes: 0 additions & 23 deletions src/app/basket/basket.component.spec.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/app/basket/basket.component.ts

This file was deleted.

Loading

0 comments on commit 9d3856b

Please sign in to comment.