-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from pvdthings/dev
Release: Catalog > Item Details
- Loading branch information
Showing
30 changed files
with
379 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { fetchItem } = require("../../../services/inventory"); | ||
const mapItemStatus = require("./mapItemStatus"); | ||
|
||
async function getItemDetails(id) { | ||
const details = await fetchItem(null, { recordId: id }); | ||
|
||
return { | ||
id: details.id, | ||
name: details.name, | ||
number: details.number, | ||
spanishName: details.name_es, | ||
available: details.available, | ||
availableDate: details.dueBack, | ||
condition: details.condition, | ||
eyeProtection: details.eyeProtection, | ||
totalLoans: details.totalLoans, | ||
image: details.images.length ? details.images[0] : undefined, | ||
manuals: details.manuals?.map((m) => m.url) || [], | ||
status: mapItemStatus(details) | ||
}; | ||
} | ||
|
||
module.exports = { | ||
getItemDetails | ||
} |
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,9 @@ | ||
function mapItemStatus(item) { | ||
if (item.available) { | ||
return 'available'; | ||
} | ||
|
||
return 'checkedOut'; | ||
} | ||
|
||
module.exports = mapItemStatus; |
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
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
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
10 changes: 10 additions & 0 deletions
10
apps/web/src/lib/components/Shell/Drawer/NavigationButton/BackButton.svelte
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 @@ | ||
<script lang="ts"> | ||
import { pop } from "../drawer"; | ||
let className: string = ''; | ||
export { className as class }; | ||
</script> | ||
|
||
<button class="btn btn-circle bg-white outline-none shadow {className}" on:click={pop}> | ||
<span class="ph-bold ph-arrow-left text-xl" /> | ||
</button> |
10 changes: 10 additions & 0 deletions
10
apps/web/src/lib/components/Shell/Drawer/NavigationButton/CloseButton.svelte
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 @@ | ||
<script lang="ts"> | ||
import { close } from "../drawer"; | ||
let className: string = ''; | ||
export { className as class }; | ||
</script> | ||
|
||
<button class="btn btn-circle bg-white outline-none shadow {className}" on:click={close}> | ||
<span class="ph-bold ph-x text-xl" /> | ||
</button> |
14 changes: 14 additions & 0 deletions
14
apps/web/src/lib/components/Shell/Drawer/NavigationButton/NavigationButton.svelte
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,14 @@ | ||
<script lang="ts"> | ||
import BackButton from "./BackButton.svelte"; | ||
import CloseButton from "./CloseButton.svelte"; | ||
import { poppable } from "../drawer"; | ||
let className: string = ''; | ||
export { className as class }; | ||
</script> | ||
|
||
{#if $poppable} | ||
<BackButton class={className} /> | ||
{:else} | ||
<CloseButton class={className} /> | ||
{/if} |
1 change: 1 addition & 0 deletions
1
apps/web/src/lib/components/Shell/Drawer/NavigationButton/index.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 @@ | ||
export { default as NavigationButton } from "./NavigationButton.svelte"; |
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,53 @@ | ||
import { derived, writable } from 'svelte/store'; | ||
|
||
const emptyState = Object.freeze({ views: [] }); | ||
|
||
let previousViewsLength = 0; | ||
|
||
export type DrawerState = { | ||
views: DrawerContent[]; | ||
}; | ||
|
||
export type DrawerContent = { | ||
component: any; | ||
props: any; | ||
}; | ||
|
||
const state = writable<DrawerState>(emptyState); | ||
|
||
export const view = derived(state, (s) => { | ||
return s.views.length ? s.views[0] : undefined; | ||
}); | ||
|
||
export const push = (component: any, props: any) => { | ||
state.update((s) => ({ | ||
views: [{ component, props }, ...s.views] | ||
})); | ||
}; | ||
|
||
export const pop = () => { | ||
state.update((s) => ({ | ||
views: s.views.slice(1) | ||
})); | ||
}; | ||
|
||
export const poppable = derived(state, (s) => s.views.length && s.views.length > 1); | ||
|
||
export const close = () => { | ||
state.update((s) => emptyState); | ||
}; | ||
|
||
// pushing second view does not work | ||
export const toggle = (callback: () => void) => { | ||
return state.subscribe(s => { | ||
if (previousViewsLength === 0 && s.views.length) { | ||
callback(); | ||
} | ||
|
||
if (previousViewsLength && !s.views.length) { | ||
callback(); | ||
} | ||
|
||
previousViewsLength = s.views.length; | ||
}); | ||
}; |
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,2 @@ | ||
export * from "./drawer"; | ||
export * from "./NavigationButton"; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.