new table for settings and store blocked date there;
non admins can't enter avs before the blocked date new table for survey
This commit is contained in:
@ -17,11 +17,22 @@ export default function AvailabilityList({ publisher, showNew }) {
|
||||
const [showAv, setShowAv] = useState(showNew || false);
|
||||
const [selectedItem, setSelectedItem] = useState(null);
|
||||
const [items, setItems] = useState(publisher.availabilities); // Convert items prop to state
|
||||
const [blockedAvailabilityDate, setBlockedAvailabilityDate] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('items set to:', items?.map(item => item.id));
|
||||
}, [items])
|
||||
|
||||
useEffect(() => {
|
||||
axiosInstance.get(`/api/?action=settings&key=AvailabilityBlockDate`)
|
||||
.then(({ data }) => {
|
||||
setBlockedAvailabilityDate(new Date(data.value));
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error getting blocked date:", error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const toggleAv = () => setShowAv(!showAv);
|
||||
const editAvailability = (item) => {
|
||||
setSelectedItem(item);
|
||||
@ -72,9 +83,16 @@ export default function AvailabilityList({ publisher, showNew }) {
|
||||
{/* <button className="bg-blue-200 hover:bg-blue-300 text-blue-600 py-1 px-2 rounded inline-flex items-center" onClick={() => editAvailability(item)}>
|
||||
<PencilSquareIcon className="h-6 w-6" />
|
||||
</button> */}
|
||||
<button className="bg-red-200 hover:bg-red-300 text-red-600 py-1 px-2 rounded ml-2 inline-flex items-center" onClick={() => deleteAvailability(item.id)}>
|
||||
<TrashIcon className="h-6 w-6" />
|
||||
</button>
|
||||
{(blockedAvailabilityDate && new Date(item.startTime) < blockedAvailabilityDate) ? (
|
||||
<button className="disabled bg-gray-200 hover:bg-gray-300 text-gray-600 py-1 px-2 rounded inline-flex items-center">
|
||||
<TrashIcon className="h-6 w-6" />
|
||||
</button>
|
||||
) : (
|
||||
<button className="bg-red-200 hover:bg-red-300 text-red-600 py-1 px-2 rounded ml-2 inline-flex items-center" onClick={() => deleteAvailability(item.id)}>
|
||||
<TrashIcon className="h-6 w-6" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
Reference in New Issue
Block a user