import React, { useState, useEffect } from 'react';
import styled from 'styled-components';
import { Button } from 'antd';
import { Hr } from 'styles/custom-styled-components';
import { useParams } from 'react-router-dom';
import { fetchAPI } from 'utils/fetchAPI';
import { STAFF, UNASSIGN_STAFF, PUBLIC_API } from 'containers/App/urls';
import RestaurantStaffModal from './Restaurant-staffs/RestaurantStaffModal';
import { StaffModel } from '../Store/types';
import { FormattedMessage } from 'react-intl';
import messages from 'translations/messages';
import { DeletePopOver } from './Delete-popover';
import { MOBILE_BREAK_POINT } from 'styles/constants';
import { PlusCharacter } from 'styles/icon-components';
import Avatar from 'react-avatar';
import { initials } from 'utils/string';
import RestaurantStaffAreaModal from './Restaurant-staffs/RestaurantStaffAreaModal';
const RestaurantStaffsWrapper = styled.div`
.restaurant-staff {
&__header {
font-size: 21px;
font-weight: 700;
display: flex;
justify-content: space-between;
padding: 20px 10px;
&__title {
color: #333;
}
&__button {
text-align: right;
}
}
&__no-staff {
text-align: center;
}
}
@media only screen and (max-width: ${MOBILE_BREAK_POINT}px) {
border-top: solid 1px rgb(217,217,217);
}
`;
export function RestaurantStaffs(props) {
const { } = props;
// @ts-ignore
const { id: restaurantId } = useParams();
const [loading, setLoading] = useState(true);
const [staffList, setStaffList] = useState([]);
const [openStaffModal, setOpenStaffModal] = useState(false);
const getStaffs = async () => {
const response = await fetchAPI({
method: 'GET',
url: `${STAFF}?restaurantId=${restaurantId}`
})
if (response) {
setStaffList(response.list);
setLoading(false);
}
}
useEffect(() => {
getStaffs();
}, [])
if (loading) {
return