Skip to content

Commit

Permalink
fix: Remove from queue behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Groß <[email protected]>
  • Loading branch information
jo-gross committed Dec 27, 2024
1 parent bcc146f commit ad21383
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions components/cocktails/CocktailRecipeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export function CocktailRecipeForm(props: CocktailRecipeFormProps) {
form={
<GlassForm
onSaved={async (id) => {
modalContext.closeModal();
modalContext.closeAllModals();
await setFieldValue('glassId', id);
fetchGlasses(workspaceId, setGlasses, setGlassesLoading);
}}
Expand Down Expand Up @@ -1102,7 +1102,7 @@ export function CocktailRecipeForm(props: CocktailRecipeFormProps) {
<IngredientForm
formRef={createRef<FormikProps<any>>()}
onSaved={async (id) => {
modalContext.closeModal();
modalContext.closeAllModals();
await setFieldValue(`steps.${indexStep}.ingredients.${indexIngredient}.ingredientId`, id);
fetchIngredients(workspaceId, setIngredients, setIngredientsLoading);
}}
Expand Down Expand Up @@ -1329,7 +1329,7 @@ export function CocktailRecipeForm(props: CocktailRecipeFormProps) {
<GarnishForm
formRef={createRef<FormikProps<any>>()}
onSaved={async (id) => {
modalContext.closeModal();
modalContext.closeAllModals();
await setFieldValue(`garnishes.${indexGarnish}.garnishId`, id);
fetchGarnishes(workspaceId, setGarnishes, setGarnishesLoading);
}}
Expand Down
2 changes: 1 addition & 1 deletion pages/api/workspaces/[workspaceId]/queue/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default withHttpMethods({
id: cocktailId,
},
},
notes: notes ? (notes.trim() == '' ? undefined : notes.trim()) : undefined,
notes: notes ? (notes.trim() == '' || notes.trim() == '-' ? undefined : notes.trim()) : undefined,
};

const results = [];
Expand Down
4 changes: 3 additions & 1 deletion pages/api/workspaces/[workspaceId]/queue/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export default withHttpMethods({
[HTTPMethod.POST]: withWorkspacePermission([Role.USER], async (req: NextApiRequest, res: NextApiResponse, user, workspace) => {
const { cocktailId, notes } = req.body;

const notesTrimmed = notes ? (notes.trim() == '' || notes.trim() == '-' ? null : notes.trim()) : null;

const firstQueueItem = await prisma.cocktailQueue.findFirst({
where: {
workspaceId: workspace.id,
cocktailId: cocktailId,
notes: notes,
notes: notesTrimmed,
},
orderBy: {
createdAt: 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default withHttpMethods({
- if there are cocktails with notes in the queue, return an error "ask user wich one to remove" (oldest
*/
if (notes) {
const searchNote = notes == '-' ? null : notes;
const searchNote: string | null = notes == '-' ? null : notes;
const queueItem = await prisma.cocktailQueue.findFirst({
where: {
workspaceId: workspace.id,
Expand Down

0 comments on commit ad21383

Please sign in to comment.