Update mobile purchase flow and locale formatting
This commit is contained in:
@ -5,6 +5,7 @@ import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { useLocale } from "@/components/providers/locale-provider";
|
||||
import { SearchableSelectField } from "@/components/shared/searchable-select-field";
|
||||
import { formatCurrencyAmount, formatDecimal, formatKilogram } from "@/lib/formatters";
|
||||
import type { ApiErrorResponse, DetailResponse } from "@/types/api";
|
||||
import type {
|
||||
GradeRecord,
|
||||
@ -65,7 +66,7 @@ const createEmptyForm = (): TransformationForm => ({
|
||||
outputs: [createEmptyOutput()]
|
||||
});
|
||||
|
||||
export function LotMixingClient() {
|
||||
export function LotMixingClient({ currencyCode }: { currencyCode: string }) {
|
||||
const { locale } = useLocale();
|
||||
const [lots, setLots] = useState<LotListItem[]>([]);
|
||||
const [transformations, setTransformations] = useState<LotTransformationListItem[]>([]);
|
||||
@ -478,8 +479,8 @@ export function LotMixingClient() {
|
||||
<p className="text-sm font-semibold text-ink">{locale === "id" ? "Penanganan sisa regrade" : "Regrade remainder handling"}</p>
|
||||
<p className="mt-1 text-sm text-slate-600">
|
||||
{locale === "id"
|
||||
? <>Masih ada sisa <span className="font-semibold text-ink">{unusedSourceRemainderQty.toFixed(3)} kg</span> dari lot sumber yang tidak dipakai untuk regrade. Pilih apakah sisa tetap berada di grade asal atau dicatat sebagai susut.</>
|
||||
: <>There is still <span className="font-semibold text-ink">{unusedSourceRemainderQty.toFixed(3)} kg</span> remaining from the source lot that was not used for regrade. Choose whether the remainder stays in the original grade or is recorded as shrinkage.</>}
|
||||
? <>Masih ada sisa <span className="font-semibold text-ink">{formatKilogram(unusedSourceRemainderQty, locale)}</span> dari lot sumber yang tidak dipakai untuk regrade. Pilih apakah sisa tetap berada di grade asal atau dicatat sebagai susut.</>
|
||||
: <>There is still <span className="font-semibold text-ink">{formatKilogram(unusedSourceRemainderQty, locale)}</span> remaining from the source lot that was not used for regrade. Choose whether the remainder stays in the original grade or is recorded as shrinkage.</>}
|
||||
</p>
|
||||
<div className="mt-4 space-y-3">
|
||||
<label className="flex items-start gap-3 rounded border border-line/70 bg-white px-4 py-3">
|
||||
@ -499,8 +500,8 @@ export function LotMixingClient() {
|
||||
<div className="font-medium text-ink">{locale === "id" ? "Tetap di grade sebelumnya" : "Keep in previous grade"}</div>
|
||||
<div className="mt-1">
|
||||
{locale === "id"
|
||||
? `Sisa ${unusedSourceRemainderQty.toFixed(3)} kg akan tetap berada di lot asal${selectedRegradeSourceLot ? ` (${selectedRegradeSourceLot.grade})` : ""}.`
|
||||
: `The remaining ${unusedSourceRemainderQty.toFixed(3)} kg will stay in the source lot${selectedRegradeSourceLot ? ` (${selectedRegradeSourceLot.grade})` : ""}.`}
|
||||
? `Sisa ${formatKilogram(unusedSourceRemainderQty, locale)} akan tetap berada di lot asal${selectedRegradeSourceLot ? ` (${selectedRegradeSourceLot.grade})` : ""}.`
|
||||
: `The remaining ${formatKilogram(unusedSourceRemainderQty, locale)} will stay in the source lot${selectedRegradeSourceLot ? ` (${selectedRegradeSourceLot.grade})` : ""}.`}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
@ -521,8 +522,8 @@ export function LotMixingClient() {
|
||||
<div className="font-medium text-ink">{locale === "id" ? "Catat sebagai susut" : "Record as shrinkage"}</div>
|
||||
<div className="mt-1">
|
||||
{locale === "id"
|
||||
? `Sisa ${unusedSourceRemainderQty.toFixed(3)} kg akan ditambahkan ke shrinkage lot sumber.`
|
||||
: `The remaining ${unusedSourceRemainderQty.toFixed(3)} kg will be added to source-lot shrinkage.`}
|
||||
? `Sisa ${formatKilogram(unusedSourceRemainderQty, locale)} akan ditambahkan ke shrinkage lot sumber.`
|
||||
: `The remaining ${formatKilogram(unusedSourceRemainderQty, locale)} will be added to source-lot shrinkage.`}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
@ -615,8 +616,8 @@ export function LotMixingClient() {
|
||||
<p className="text-sm font-semibold text-ink">{locale === "id" ? "Penanganan selisih hasil ubah grade" : "Regrade output difference handling"}</p>
|
||||
<p className="mt-1 text-sm text-slate-600">
|
||||
{locale === "id"
|
||||
? <>Total output masih kurang <span className="font-semibold text-ink">{outputLossQty.toFixed(3)} kg</span> dari qty yang dipakai untuk regrade. Anda tidak bisa menyimpan sebelum selisih ini ditangani.</>
|
||||
: <>Total output is still short by <span className="font-semibold text-ink">{outputLossQty.toFixed(3)} kg</span> compared with the qty used for regrade. You cannot save before this difference is handled.</>}
|
||||
? <>Total output masih kurang <span className="font-semibold text-ink">{formatKilogram(outputLossQty, locale)}</span> dari qty yang dipakai untuk regrade. Anda tidak bisa menyimpan sebelum selisih ini ditangani.</>
|
||||
: <>Total output is still short by <span className="font-semibold text-ink">{formatKilogram(outputLossQty, locale)}</span> compared with the qty used for regrade. You cannot save before this difference is handled.</>}
|
||||
</p>
|
||||
<ul className="mt-3 list-disc space-y-1 pl-5 text-sm text-slate-600">
|
||||
<li>{locale === "id" ? "tambahkan lot hasil baru agar total output pas, atau" : "add a new output lot so total output matches, or"}</li>
|
||||
@ -640,8 +641,8 @@ export function LotMixingClient() {
|
||||
<div className="font-medium text-ink">{locale === "id" ? "Catat sebagai susut/lost" : "Record as shrinkage/loss"}</div>
|
||||
<div className="mt-1">
|
||||
{locale === "id"
|
||||
? `Selisih ${outputLossQty.toFixed(3)} kg akan dicatat sebagai shrinkage pada lot sumber.`
|
||||
: `The ${outputLossQty.toFixed(3)} kg difference will be recorded as shrinkage on the source lot.`}
|
||||
? `Selisih ${formatKilogram(outputLossQty, locale)} akan dicatat sebagai shrinkage pada lot sumber.`
|
||||
: `The ${formatKilogram(outputLossQty, locale)} difference will be recorded as shrinkage on the source lot.`}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
@ -650,9 +651,9 @@ export function LotMixingClient() {
|
||||
) : null}
|
||||
|
||||
<div className="mt-6 grid gap-4 md:grid-cols-3">
|
||||
<SummaryMetric label={locale === "id" ? "Total Qty Input" : "Total Input Qty"} value={inputTotal.toFixed(3)} />
|
||||
<SummaryMetric label={locale === "id" ? "Total Qty Output" : "Total Output Qty"} value={outputTotal.toFixed(3)} />
|
||||
<SummaryMetric label={locale === "id" ? "Selisih / Shrinkage" : "Difference / Shrinkage"} value={outputLossQty.toFixed(3)} />
|
||||
<SummaryMetric label={locale === "id" ? "Total Qty Input" : "Total Input Qty"} value={formatDecimal(inputTotal, locale)} />
|
||||
<SummaryMetric label={locale === "id" ? "Total Qty Output" : "Total Output Qty"} value={formatDecimal(outputTotal, locale)} />
|
||||
<SummaryMetric label={locale === "id" ? "Selisih / Shrinkage" : "Difference / Shrinkage"} value={formatDecimal(outputLossQty, locale)} />
|
||||
</div>
|
||||
|
||||
{error ? (
|
||||
@ -704,8 +705,8 @@ export function LotMixingClient() {
|
||||
<tr key={item.id}>
|
||||
<td className="font-semibold text-ink">{item.transformation_no}</td>
|
||||
<td className="text-slate-600">{item.transformation_type}</td>
|
||||
<td className="text-slate-600">{item.total_input_qty.toFixed(3)}</td>
|
||||
<td className="text-slate-600">{item.total_output_qty.toFixed(3)}</td>
|
||||
<td className="text-slate-600">{formatDecimal(item.total_input_qty, locale)}</td>
|
||||
<td className="text-slate-600">{formatDecimal(item.total_output_qty, locale)}</td>
|
||||
<td>
|
||||
<span className="ops-chip-active">{item.status}</span>
|
||||
</td>
|
||||
@ -744,7 +745,7 @@ export function LotMixingClient() {
|
||||
</div>
|
||||
{selectedTransformation.remainder_qty ? (
|
||||
<div className="mt-2 text-sm text-slate-600">
|
||||
{locale === "id" ? "Sisa" : "Remainder"}: {selectedTransformation.remainder_qty.toFixed(3)} kg ·{" "}
|
||||
{locale === "id" ? "Sisa" : "Remainder"}: {formatKilogram(selectedTransformation.remainder_qty, locale)} ·{" "}
|
||||
{selectedTransformation.remainder_mode === "KEEP_SOURCE_GRADE"
|
||||
? locale === "id" ? "tetap di grade asal" : "kept in original grade"
|
||||
: selectedTransformation.remainder_mode === "SHRINKAGE"
|
||||
@ -754,7 +755,7 @@ export function LotMixingClient() {
|
||||
) : null}
|
||||
{selectedTransformation.processing_loss_qty ? (
|
||||
<div className="mt-2 text-sm text-slate-600">
|
||||
{locale === "id" ? "Selisih output" : "Output difference"}: {selectedTransformation.processing_loss_qty.toFixed(3)} kg ·{" "}
|
||||
{locale === "id" ? "Selisih output" : "Output difference"}: {formatKilogram(selectedTransformation.processing_loss_qty, locale)} ·{" "}
|
||||
{selectedTransformation.processing_loss_mode === "SHRINKAGE"
|
||||
? locale === "id" ? "dicatat sebagai susut/lost" : "recorded as shrinkage/loss"
|
||||
: "-"}
|
||||
@ -817,7 +818,7 @@ export function LotMixingClient() {
|
||||
</div>
|
||||
<div className="mt-2 text-sm text-slate-600">
|
||||
{output.result_lot.grade} ·{" "}
|
||||
{locale === "id" ? "Biaya Rp" : "Cost Rp"} {output.unit_cost.toLocaleString(locale === "id" ? "id-ID" : "en-US")}
|
||||
{locale === "id" ? "Biaya" : "Cost"} {formatCurrencyAmount(output.unit_cost, locale, currencyCode, 0)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user