This commit is contained in:
Riccardo
2021-08-16 11:06:02 +02:00
parent 78db95aa5f
commit 2f119e43bd
12 changed files with 68 additions and 101 deletions

View File

@@ -5,6 +5,7 @@ import AppointmentList from './appointment/AppointmentList';
import CreateAppointment from './appointment/CreateAppointment';
import UpdateAppointemnt from './appointment/UpdateAppointment';
import Calendar from './Calendar';
import Search from './Search';
import { Switch, Route } from 'react-router-dom';
const App = () => {
@@ -18,6 +19,7 @@ const App = () => {
<Route exact path="/update/:_id" component={UpdateAppointemnt} />
<Route exact path="/login" component={Login} />
<Route exact path="/calendar" component={Calendar} />
<Route exact path="/search" component={Search} />
</Switch>
</div>
</div>

View File

@@ -1,63 +1,39 @@
import React, { useState } from 'react';
import { useMutation } from '@apollo/client';
import { useLazyQuery } from '@apollo/client';
import gql from 'graphql-tag';
import Appointment from './Appointment';
import { Link } from 'react-router-dom';
import Appointment from './appointment/Appointment';
const FEED_SEARCH_QUERY = gql`
query FeedSearchQuery($filter: String!) {
feed(filter: $filter) {
id
links {
id
appointments {
_id
title
description
type
createdBy {
id
username
}
# follows {
# id
# user {
# id
# }
# }
}
}
}
`;
const Search = () => {
const [searchFilter, setSearchFilter] = useState('');
const [executeSearch, { data }] = useLazyQuery(
FEED_SEARCH_QUERY
);
return (
<>
<div>
Search
<input
type="text"
onChange={(e) => setSearchFilter(e.target.value)}
/>
<button
onClick={() =>
executeSearch({
variables: { filter: searchFilter }
})
}
>
OK
</button>
</div>
{/* {data &&
data.feed.appointments.map((appointment, index) => (
<Link key={appointment.id} link={appointment} index={index} />
))} */}
</>
);
const [searchFilter, setSearchFilter] = useState('');
const [executeSearch, { data }] = useLazyQuery(
FEED_SEARCH_QUERY
);
return (
<>
<div>
Search
<input type="text" onChange={(e) => setSearchFilter(e.target.value)}/>
<button onClick={() => executeSearch({ variables: { filter: searchFilter } })}>OK</button>
</div>
{data &&
data.feed.appointments.map((appointment, index) => (
<Appointment key={appointment.id} appointment={appointment} index={index} />
))}
</>
);
};
export default Search;

View File

@@ -21,10 +21,10 @@ const Appointment = (props) => {
onCompleted: () => history.push('/')
})
// const updateAppointment = () => {
// let path = `/update/${appointment._id}`;
// history.push(path);
// }
const updateAppointment = () => {
let path = `/update/${appointment._id}`;
history.push(path);
}
return (
<div>

View File

@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { useHistory } from 'react-router';
import { useMutation, gql, useQuery } from '@apollo/client';
import { APPOINTMENTS_PER_PAGE } from '../../constants';
import { APPOINTMENTS_QUERY } from './AppointmentList';
// import { APPOINTMENTS_PER_PAGE } from '../../constants';
// import { APPOINTMENTS_QUERY } from './AppointmentList';
import Datetime from 'react-datetime';
import "react-datetime/css/react-datetime.css";

View File

@@ -1,6 +1,6 @@
import React from 'react';
// import { useHistory } from 'react-router';
import { Link, withRouter } from 'react-router-dom';
import { Link } from 'react-router-dom';
// import { AUTH_TOKEN } from '../../constants';
const Header = () => {
@@ -17,6 +17,9 @@ const Header = () => {
<div className="flex flex-fixed">
<Link to="/create" className="ml1 no-underline black">New</Link>
</div>
{/* <div className="flex flex-fixed">
<Link to="/search" className="ml1 no-underline black">Search</Link>
</div> */}
{/* <div className="flex flex-fixed">
{authToken ? (
<div className="ml1 pointer black"