-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extend frontend with home and pastry page
* docs: update README.md to get started quickly for real * fix: be consistent with pastry naming * pastery -> pastry * feat: add pastry page and adding new pastries * add pastry page and home page * add save pastry functionality
- Loading branch information
1 parent
7458f22
commit f33fa0a
Showing
19 changed files
with
238 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const express = require('express'); | ||
const pastriesController = require('../controllers/pastries-controller'); | ||
const router = express.Router(); | ||
|
||
router.get('/', pastriesController.getPastries); | ||
router.get('/:id', pastriesController.getPastry); | ||
router.post('/', pastriesController.addPastry); | ||
router.put('/:id', pastriesController.updatePastry); | ||
router.delete('/:id', pastriesController.deletePastry); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"Vue.volar", | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode" | ||
"esbenp.prettier-vscode", | ||
"bradlc.vscode-tailwindcss" | ||
] | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
frontend/src/core/use-cases/pastries/add-pastry.use-case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type RemoteUseCaseProxy from '../remote-use-case-proxy' | ||
import type { ApiResponse } from '../remote-use-case-proxy' | ||
|
||
export default class AddPastryUseCase { | ||
constructor(private remoteUseCaseProxy: RemoteUseCaseProxy) {} | ||
|
||
public async execute(pastryName: string): Promise<ApiResponse<any, any>> { | ||
const resp = await this.remoteUseCaseProxy.execute< | ||
{ name: string }, | ||
Record<string, never>, | ||
string | ||
>('pastries', 'post', { | ||
name: pastryName | ||
}) | ||
|
||
return resp | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
frontend/src/core/use-cases/pastries/get-pastries.use-case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Pastry } from '@/core/models/pastry' | ||
import type RemoteUseCaseProxy from '../remote-use-case-proxy' | ||
import type { ApiResponse } from '../remote-use-case-proxy' | ||
|
||
export default class GetPastriesUseCase { | ||
constructor(private remoteUseCaseProxy: RemoteUseCaseProxy) {} | ||
|
||
public async execute(): Promise<ApiResponse<Pastry[], any>> { | ||
const dto = await this.remoteUseCaseProxy.execute<Record<string, never>, Pastry[], string>( | ||
'pastries', | ||
'get', | ||
{} | ||
) | ||
|
||
return dto | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<template> | ||
|
||
<div class="flex flex-col"> | ||
<h3 class="text-xl font-bold mb-6">AppBakery - BakeTime</h3> | ||
|
||
<p class="text-m mb-8">What's bakin'?</p> | ||
|
||
<div class="flex flex-row items-center gap-9"> | ||
<img src="@/assets/bakingApps.png"> | ||
|
||
<div class="flex flex-col gap-5"> | ||
<div><RouterLink class="text-blue-500 hover:text-red-500 transition-colors" to="/appbakers">AppBakers</RouterLink></div> | ||
<div><RouterLink class="text-blue-500 hover:text-red-500 transition-colors" to="/pastries">Pastries</RouterLink></div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
|
||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<template> | ||
<LoadingWrapper :state="state" :reload="doReload"> | ||
<PastriesListView :pastries="data" @added="doReload"></PastriesListView> | ||
</LoadingWrapper> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { AppContainerKey } from '@/core/container/app-container' | ||
import { injectStrict } from '@/core/container/inject' | ||
import LoadingWrapper from '@/shared/components/LoadingWrapper.vue' | ||
import PastriesListView from './PastriesListView.vue' | ||
import { useLoading } from '../../shared/functions/use-loading' | ||
import type { Pastry } from '../../core/models/pastry' | ||
const getPastriesListUseCase = injectStrict(AppContainerKey.getPastriesUseCase) | ||
const { state, data, load } = useLoading<Pastry[]>() | ||
load(() => { | ||
return getPastriesListUseCase.execute() | ||
}) | ||
const doReload = () => { | ||
load(() => { | ||
return getPastriesListUseCase.execute() | ||
}) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<div class="flex flex-col gap-2 grow"> | ||
<div v-for="pastry of pastries" :key="pastry.id" class="flex flex-row gap-2"> | ||
<div>{{ pastry.name }}</div> | ||
</div> | ||
<div class="flex flex-row gap-5 mt-5"> | ||
<input v-model="newName" placeholder="New Pastry Name" /> | ||
<PrimaryButton :disabled="newName.length <= 0" @click="savePastry">Save</PrimaryButton> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import { ref } from 'vue' | ||
import { AppContainerKey } from '@/core/container/app-container' | ||
import { injectStrict } from '@/core/container/inject' | ||
import { SavingState, useSaving } from '../../shared/functions/use-saving' | ||
import type { Pastry } from '@/core/models/pastry'; | ||
import PrimaryButton from '@/shared/components/PrimaryButton.vue'; | ||
const addPastryUseCase = injectStrict(AppContainerKey.addPastryUseCase) | ||
const { savingState, savedData, save } = useSaving<void>() | ||
const newName = ref('') | ||
const savePastry = async () => { | ||
await save(() => { | ||
return addPastryUseCase.execute(newName.value) | ||
}) | ||
switch (savingState.value) { | ||
case SavingState.Success: | ||
emit('added') | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
interface Props { | ||
pastries: Pastry[] | ||
} | ||
const emit = defineEmits(['added']) | ||
defineProps<Props>() | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<button class="bg-sbb-red border border-transparent text-white px-4 py-3 rounded-full hover:bg-sbb-red-125 disabled:bg-sbb-milk disabled:text-sbb-granite disabled:border disabled:border-dashed disabled:border-sbb-smoke"> | ||
<slot /> | ||
</button> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters