Skip to content

Commit

Permalink
[#46] fix: correct variable
Browse files Browse the repository at this point in the history
  • Loading branch information
suzinxix committed Jan 31, 2023
1 parent 57a112d commit 1ab9bb1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion bowwowcare/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import LoginPage from './views/LoginPage/LoginPage';
import SignupPage from './views/SignupPage/SignupPage';
import AdditionPage from "./views/AdditionPage/AdditionPage";
import PrivateRoute from "./PrivateRoute";
import PetInfo from "./views/HomePage/PetList/PetInfo/PetInfo";
import PetInfoPage from "./views/PetInfoPage/PetInfoPage";

import { logout } from "./slices/auth";
Expand Down
10 changes: 5 additions & 5 deletions bowwowcare/src/utils/Calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export const getAge = (date) => {
return age;
};

export const getBwDate = (date) => {
export const getDurationDate = (date) => {
const now = new Date();
const stDate = new Date(date.getFullYear(), date.getMonth() + 1, date.getDate());
const startDate = new Date(date.getFullYear(), date.getMonth() + 1, date.getDate());
const endDate = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate());

const btMs = endDate.getTime() - stDate.getTime() ;
const btDay = btMs / (1000*60*60*24);
const ms = endDate.getTime() - startDate.getTime() ;
const durationDate = ms / (1000*60*60*24);

return btDay;
return durationDate;
}
2 changes: 1 addition & 1 deletion bowwowcare/src/views/HomePage/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function HomePage() {
onClick={() => navigate("/camera")}>사진 찍기</button>

</div>
{pet && <PetList pet={pet}/>}
{pet && <PetList pets={pet}/>}

<button className="w-full h-32 mt-6 text-center rounded-md border border-gray-300 hover:border-main-color text-gray-300 bg-transparent pl-4"
onClick={()=>navigate("/addition")}>
Expand Down
8 changes: 4 additions & 4 deletions bowwowcare/src/views/HomePage/PetList/PetList.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react'
import { Link } from 'react-router-dom';

import PetInfo from './PetInfo/PetInfo'
import PetInfo from './Sections/PetInfo'

function PetList(props) {
return (
<div>
{ props.pet.map((a, i)=>{
{ props.pets.map((pet, i)=>{
return(
<Link to={`/petinfo/${a.id}`} state={{ pet: a }}>
<PetInfo pet={a} key={i}/>
<Link to={`/petinfo/${pet.id}`} state={{ pet: pet }}>
<PetInfo pet={pet} key={i}/>
</Link>
)
})}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react'

import { getAge } from '../../../../utils/Calculator';
import { getBwDate } from '../../../../utils/Calculator';
import { getDurationDate } from '../../../../utils/Calculator';

function PetInfo(props) {

const birthDate = new Date( Date.parse(props.pet.birthDate) );
const adoptDate = new Date( Date.parse(props.pet.adoptDate) );

const age = getAge(birthDate);
const day = getBwDate(adoptDate);
const day = getDurationDate(adoptDate);

return (
<div className='flex shadow-lg mt-6 p-8 rounded-lg'>
Expand Down

0 comments on commit 1ab9bb1

Please sign in to comment.