generated from prokawsar/dashboard-starter
-
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.
- Loading branch information
Showing
5 changed files
with
84 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
import Icon from '@iconify/svelte' | ||
import Input from './Input.svelte' | ||
import { receive, send } from '$lib/utils/tools' | ||
import { fields, placeholders } from '$lib/utils/constants' | ||
import { createEventDispatcher } from 'svelte' | ||
import type { Paper } from '$lib/utils/services' | ||
export let paper: Paper | ||
export let index: number | ||
export let totalPaper: number | ||
export let perPaperResult: Map<string, number> | ||
const dispatch = createEventDispatcher() | ||
</script> | ||
|
||
<div | ||
id={paper.id} | ||
class="flex flex-row items-center justify-between rounded" | ||
in:receive={{ key: paper.id }} | ||
out:send={{ key: paper.id }} | ||
> | ||
<div class="flex flex-row gap-[3px] items-center overflow-x-auto"> | ||
<button | ||
disabled={totalPaper == 1 && index == 0} | ||
class="border border-gray-400 rounded-md text-red-600 p-1 w-fit disabled:border-gray-200 disabled:cursor-not-allowed disabled:text-opacity-45" | ||
on:click={() => dispatch('remove')} | ||
> | ||
<Icon icon="ph:trash-light" width="16px" /> | ||
</button> | ||
{#each fields as field} | ||
<Input bind:value={paper[field]} placeholder={placeholders[field]} on:keydown /> | ||
{/each} | ||
</div> | ||
<div class="flex flex-grow justify-center px-1"> | ||
<p | ||
class="{perPaperResult.get(paper.id) ? 'font-semibold' : 'font-light text-gray-400'} pr-[2px]" | ||
> | ||
= {perPaperResult.get(paper.id)?.toFixed(2) || 'total'} | ||
</p> | ||
</div> | ||
</div> |
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 @@ | ||
export const PAPER_FIXED = 1550000 | ||
export const MAX_PAPER = 10 | ||
export const MAX_HISTORY = 20 | ||
|
||
export const paperFields = { | ||
id: '', | ||
length: '', | ||
width: '', | ||
thickness: '', | ||
rate: '' | ||
} | ||
export const placeholders: { [key: string]: string } = { | ||
length: 'L', | ||
width: 'W', | ||
thickness: 'GSM', | ||
rate: 'R' | ||
} | ||
export const fields = Object.keys(paperFields).filter((key) => key !== 'id') |
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