Skip to content

Commit

Permalink
chore: 디렉토리 변경
Browse files Browse the repository at this point in the history
issue #22
  • Loading branch information
77unny committed Jun 2, 2020
1 parent fb38682 commit 5cf3c6b
Show file tree
Hide file tree
Showing 30 changed files with 96 additions and 15 deletions.
3 changes: 0 additions & 3 deletions FE/src/constants/url.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion FE/package-lock.json → client/package-lock.json

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

2 changes: 1 addition & 1 deletion FE/package.json → client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "FE",
"name": "client",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions client/src/components/SearchList/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useState, useEffect } from 'react';
import styled from 'styled-components';
import SearchItem from './SearchItem';

const SearchListDiv = styled.div`
display: flex;
flex-wrap: wrap;
margin-left: -15px;
`;

const SearchList = ({ data }) => {
const SET_NUMBER = 20;
const [startPoint, setStartPoint] = useState(0);
const [endPoint, setEndPoint] = useState(SET_NUMBER);
const [searchList, setSearchList] = useState(data.slice(startPoint, endPoint));

const test = () => {
return setStartPoint(startPoint + SET_NUMBER);
};

useEffect(() => {
setEndPoint(endPoint + SET_NUMBER);
setSearchList(searchList.concat(data.slice(startPoint, endPoint)));
console.log('endPoint 변경', startPoint, endPoint);
}, [startPoint]);

return (
<SearchListDiv>
{searchList.map((accommodation, index) => {
return <SearchItem key={index} contents={accommodation} width="25%" />;
})}
<button onClick={test}>더보기</button>
</SearchListDiv>
);
};

export default SearchList;
File renamed without changes.
3 changes: 3 additions & 0 deletions client/src/constants/url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const URL = {
API: 'http://ec2-13-209-173-230.ap-northeast-2.compute.amazonaws.com/api/',
};
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import React, { useState } from 'react';
import styled from 'styled-components';
import useAsync from '../utils/useAsync';
import { URL } from '../constants/url';
import SearchItem from '../components/SearchList/SearchItem';
import SearchTitle from '../components/SearchList/SearchTitle';
import SearchList from '../components/SearchList';

const SearchListWrapDiv = styled.div``;
const SearchListInnerDiv = styled.div`
Expand Down Expand Up @@ -31,17 +32,19 @@ const SearchListContainer = () => {
if (!data) return null;

const { totalCount, priceDistribution, accommodations } = data.data;
console.log(data.data);

const searchListData = data.data.accommodations;
const searchListOption = {
items: 20,
preItems: 0,
};
console.log(searchListData.slice(searchListOption.preItems, searchListOption.items));

return (
<SearchListWrapDiv>
<SearchListInnerDiv>
<SearchTitle totalCount={totalCount} />
<SearchListDiv>
{accommodations.map(accommodation => {
return <SearchItem key={accommodation.accommodationId} contents={accommodation} width="20%" />;
})}
</SearchListDiv>
<SearchList data={accommodations} />
</SearchListInnerDiv>
</SearchListWrapDiv>
);
Expand Down
File renamed without changes.
12 changes: 9 additions & 3 deletions FE/src/modules/date.js → client/src/modules/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const initialState = {
startDate: null,
endDate: null,
checkInDate: null,
cehckOutDate: null,
checkOutDate: null,
};

export default function date(state = initialState, action) {
Expand All @@ -31,10 +31,16 @@ export default function date(state = initialState, action) {
let checkIn,
checkOut = null;
if (action.date.startDate) {
checkIn = `${action.date.startDate._d.getFullYear()}-${action.date.startDate._d.getMonth() + 1}-${action.date.startDate._d.getDate()}`;
const year = action.date.startDate._d.getFullYear();
const month = action.date.startDate._d.getMonth() + 1;
const day = action.date.startDate._d.getDate();
checkIn = `${year}-${('00' + month.toString()).slice(-2)}-${('00' + day.toString()).slice(-2)}`;
}
if (action.date.endDate) {
checkOut = `${action.date.endDate._d.getFullYear()}-${action.date.endDate._d.getMonth() + 1}-${action.date.endDate._d.getDate()}`;
const year = action.date.endDate._d.getFullYear();
const month = action.date.endDate._d.getMonth() + 1;
const day = action.date.endDate._d.getDate();
checkOut = `${year}-${('00' + month.toString()).slice(-2)}-${('00' + day.toString()).slice(-2)}`;
}
return {
...state,
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions FE/src/modules/index.js → client/src/modules/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { combineReducers } from 'redux';
import date from './date';
import guest from './guest';
import price from './price';
import form from './form';

const rootReducer = combineReducers({
date,
guest,
price,
form,
});

Expand Down
29 changes: 29 additions & 0 deletions client/src/modules/price.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const SAVE = 'price/SAVE';
const GET_PRICE_DISTRIBUTION = 'price/GET_PRICE_DISTRIBUTION';

export const save = data => ({ type: SAVE, data });
export const getPriceDistribution = data => ({ type: GET_PRICE_DISTRIBUTION, data });

const initialState = {
priceMin: null,
priceMax: null,
priceDistribution: null,
};

export default function price(state = initialState, action) {
switch (action.type) {
case SAVE:
return {
...state,
priceMin: action.data.priceMin,
priceMax: action.data.priceMax,
};
case GET_PRICE_DISTRIBUTION:
return {
...state,
priceDistribution: action.data,
};
default:
return state;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5cf3c6b

Please sign in to comment.