Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions pages/planning/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GoSync } from 'react-icons/go';
export default function DashboardPlanning() {
//

//
// Get days from API
const { data: daysFromDB } = useSWR('/api/planning/*');

Expand Down Expand Up @@ -43,9 +44,18 @@ export default function DashboardPlanning() {

async function getRecipes() {
try {
const vegan = await apicbaseAPI('/products/recipes?page_size=200&custom_fields={"Tipo de Receita": ["Vegan", "Vegetariana"]}', 'GET');
const fish = await apicbaseAPI('/products/recipes?page_size=200&custom_fields={"Tipo de Receita": ["Peixe"]}', 'GET');
const meat = await apicbaseAPI('/products/recipes?page_size=200&custom_fields={"Tipo de Receita": ["Carne"]}', 'GET');
const vegan = await apicbaseAPI(
'/products/recipes?page_size=200&custom_fields={"Tipo de Receita": ["Vegan", "Vegetariana"]}',
'GET'
);
const fish = await apicbaseAPI(
'/products/recipes?page_size=200&custom_fields={"Tipo de Receita": ["Peixe"]}',
'GET'
);
const meat = await apicbaseAPI(
'/products/recipes?page_size=200&custom_fields={"Tipo de Receita": ["Carne"]}',
'GET'
);

function formatRecipes(data) {
return data.map((item) => ({
Expand Down Expand Up @@ -103,7 +113,9 @@ export default function DashboardPlanning() {
// INIT AUTH
async function initApicbaseAuth() {
window.location.assign(
'https://app.apicbase.com/oauth/authorize/?response_type=code&client_id=' + process.env.NEXT_PUBLIC_APICBASE_CLIENT_ID + '&scope=library'
'https://app.apicbase.com/oauth/authorize/?response_type=code&client_id=' +
process.env.NEXT_PUBLIC_APICBASE_CLIENT_ID +
'&scope=library'
);
}

Expand All @@ -128,7 +140,12 @@ export default function DashboardPlanning() {

<Sidebar title={'Planeamento'}>
<div className={styles.toolbar}>
<DateRangePicker amountOfMonths={2} placeholder='Pick dates range' value={dateRangeValue} onChange={setDateRangeValue} />
<DateRangePicker
amountOfMonths={2}
placeholder='Pick dates range'
value={dateRangeValue}
onChange={setDateRangeValue}
/>
<Button onClick={() => setDateRangeValue(getRangeCurrentMonth)}>Current Month</Button>
<Button onClick={() => setDateRangeValue(getRangeNextMonth)}>Next Month</Button>
<Button disabled={isRefreshhing || isLoading} onClick={() => refreshRecipes()}>
Expand Down