diff --git a/client/images/icon-x128.png b/client/assets/icon-x128.png
similarity index 100%
rename from client/images/icon-x128.png
rename to client/assets/icon-x128.png
diff --git a/client/images/icon-x192.png b/client/assets/icon-x192.png
similarity index 100%
rename from client/images/icon-x192.png
rename to client/assets/icon-x192.png
diff --git a/client/images/icon-x384.png b/client/assets/icon-x384.png
similarity index 100%
rename from client/images/icon-x384.png
rename to client/assets/icon-x384.png
diff --git a/client/images/icon-x512.png b/client/assets/icon-x512.png
similarity index 100%
rename from client/images/icon-x512.png
rename to client/assets/icon-x512.png
diff --git a/client/manifest.json b/client/manifest.json
index 9b6bbdc..1f2704f 100644
--- a/client/manifest.json
+++ b/client/manifest.json
@@ -3,28 +3,28 @@
"short_name": "Amatta",
"icons": [
{
- "src": "https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x128.png",
+ "src": "assets/icon-x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
- "src": "https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x192.png",
+ "src": "assets/icon-x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
- "src": "https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x384.png",
+ "src": "assets/icon-x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
- "src": "https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x512.png",
+ "src": "assets/icon-x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
- "start_url": "https://amatta.site/",
+ "start_url": "/",
"display": "fullscreen",
"background_color": "#92b8b1",
"theme_color": "#ffffff"
diff --git a/client/service-worker.js b/client/service-worker.js
index 7667a9c..5553c5b 100644
--- a/client/service-worker.js
+++ b/client/service-worker.js
@@ -1,61 +1,49 @@
-importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
-
-const CACHE = 'cache-offline-page';
-const offlineFallbackPage = 'offline.html';
-
-self.addEventListener('message', (event) => {
- if (event.data && event.data.type === 'SKIP_WAITING') {
- self.skipWaiting();
- }
-});
+const CACHE_NAME = 'my-pwa-cache';
+const urlsToCache = ['/', '/offline.html'];
self.addEventListener('install', (event) => {
- event.waitUntil(
- caches
- .open(CACHE)
- .then((cache) =>
- cache.addAll([
- 'https://amatta.site/',
- './offline.html',
- 'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x128.png',
- 'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x192.png',
- 'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x384.png',
- 'https://amatta-icons.s3.ap-northeast-2.amazonaws.com/app/icon-x512.png',
- ]),
- ),
- );
+ event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(urlsToCache)));
});
-if (workbox.navigationPreload.isSupported()) {
- workbox.navigationPreload.enable();
-}
-
-workbox.routing.registerRoute(
- new RegExp('/*'),
- new workbox.strategies.StaleWhileRevalidate({
- cacheName: CACHE,
- }),
-);
-
self.addEventListener('fetch', (event) => {
- if (event.request.mode === 'navigate') {
- event.respondWith(
- (async () => {
- try {
- const preloadResp = await event.preloadResponse;
-
- if (preloadResp) {
- return preloadResp;
+ event.respondWith(
+ caches
+ .match(event.request)
+ .then((response) => {
+ if (response) {
+ return response;
+ }
+ return fetch(event.request).then((response) => {
+ if (response.status === 404) {
+ return caches.match('/offline.html');
}
+ const responseToCache = response.clone();
+ caches.open(CACHE_NAME).then((cache) => {
+ cache.put(event.request, responseToCache);
+ });
+ return response;
+ });
+ })
+ .catch(() => {
+ return caches.match('/offline.html');
+ }),
+ );
+});
- const networkResp = await fetch(event.request);
- return networkResp;
- } catch (error) {
- const cache = await caches.open(CACHE);
- const cachedResp = await cache.match(offlineFallbackPage);
- return cachedResp;
- }
- })(),
- );
- }
+self.addEventListener('beforeinstallprompt', (event) => {
+ event.preventDefault();
+ const promptEvent = event;
+ const installButton = document.createElement('button');
+ installButton.textContent = 'Add to Home Screen';
+ document.body.appendChild(installButton);
+ installButton.addEventListener('click', () => {
+ promptEvent.prompt();
+ promptEvent.userChoice.then((choiceResult) => {
+ if (choiceResult.outcome === 'accepted') {
+ console.log('User accepted the install prompt');
+ } else {
+ console.log('User dismissed the install prompt');
+ }
+ });
+ });
});
diff --git a/client/src/apis/card.js b/client/src/apis/card.js
index df4b740..b7819c4 100644
--- a/client/src/apis/card.js
+++ b/client/src/apis/card.js
@@ -1,8 +1,8 @@
import client from './client';
-export const getCardList = async () => {
+export const getCardList = async (query = '') => {
try {
- const response = await client.get(`gifticon/test`);
+ const response = await client.get(`gifticon/test?keyword=${query}`);
return response.data;
} catch (e) {
diff --git a/client/src/apis/client.js b/client/src/apis/client.js
index 133622f..412e6ec 100644
--- a/client/src/apis/client.js
+++ b/client/src/apis/client.js
@@ -1,5 +1,7 @@
import axios from 'axios';
import { SERVER_URL } from '@/constants/constant';
+import { navigate } from '@/core/router';
+import { notification } from '@/components/common';
const baseURL = SERVER_URL.API;
@@ -9,4 +11,26 @@ const client = axios.create({
client.defaults.withCredentials = true;
+client.interceptors.response.use(
+ (response) => response,
+ (error) => {
+ if (error.response && error.response.status) {
+ switch (error.response.status) {
+ case 401:
+ navigate('/');
+ notification('로그인이 필요합니다.', 'login')();
+ return new Promise(() => {});
+ case 400:
+ notification(`${error.response.data}`, 'login')();
+ return new Promise(() => {});
+ default:
+ return Promise.reject(error);
+ }
+ } else if (error.code === 'ERR_NETWORK') {
+ notification('올바르지 않은 이미지 형식입니다.', 'login')();
+ }
+ return Promise.reject(error);
+ },
+);
+
export default client;
diff --git a/client/src/components/auth/login.js b/client/src/components/auth/login.js
index 4b888f6..b0e1099 100644
--- a/client/src/components/auth/login.js
+++ b/client/src/components/auth/login.js
@@ -43,7 +43,6 @@ const login = () => {
const submitData = async (e) => {
e.stopPropagation();
e.preventDefault();
- console.log('뭔데');
await loginU({ email: 'test@test.com', password: 'testPassword' });
// await loginU(userData);
diff --git a/client/src/components/common/header.js b/client/src/components/common/header.js
index 4b79d8c..1765aff 100644
--- a/client/src/components/common/header.js
+++ b/client/src/components/common/header.js
@@ -4,6 +4,7 @@ import { logoutU } from '@/apis/auth';
import { _ } from '@/utils/customFx';
import { IO, $ } from '@/utils';
import { sideMenu, modal } from '@/components/common';
+
// search-button //
const header = (props) => {
const { color, label, path } = props;
@@ -14,6 +15,7 @@ const header = (props) => {
const mintTemp = `
+