Added buttons to view/edit spools on locations page
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
import { IResourceComponentsProps, useInvalidate, useList, useTranslate } from "@refinedev/core";
|
import { IResourceComponentsProps, useInvalidate, useList, useNavigation, useTranslate } from "@refinedev/core";
|
||||||
import { theme } from "antd";
|
import { Button, theme } from "antd";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import utc from "dayjs/plugin/utc";
|
import utc from "dayjs/plugin/utc";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { DndProvider, useDrag, useDrop } from "react-dnd";
|
import { DndProvider, useDrag, useDrop } from "react-dnd";
|
||||||
import { HTML5Backend } from "react-dnd-html5-backend";
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
||||||
|
|
||||||
|
import { EditOutlined, EyeOutlined } from "@ant-design/icons";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
import SpoolIcon from "../../components/spoolIcon";
|
import SpoolIcon from "../../components/spoolIcon";
|
||||||
import { ISpool } from "../spools/model";
|
import { ISpool } from "../spools/model";
|
||||||
import { setSpoolLocation } from "./functions";
|
import { setSpoolLocation } from "./functions";
|
||||||
@@ -17,6 +19,7 @@ const { useToken } = theme;
|
|||||||
|
|
||||||
function SpoolCard({ spool }: { spool: ISpool }) {
|
function SpoolCard({ spool }: { spool: ISpool }) {
|
||||||
const { token } = useToken();
|
const { token } = useToken();
|
||||||
|
const t = useTranslate();
|
||||||
const [{ opacity }, dragRef] = useDrag(
|
const [{ opacity }, dragRef] = useDrag(
|
||||||
() => ({
|
() => ({
|
||||||
type: "spool",
|
type: "spool",
|
||||||
@@ -27,6 +30,7 @@ function SpoolCard({ spool }: { spool: ISpool }) {
|
|||||||
}),
|
}),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
const { editUrl, showUrl } = useNavigation();
|
||||||
|
|
||||||
const colorObj = spool.filament.multi_color_hexes
|
const colorObj = spool.filament.multi_color_hexes
|
||||||
? {
|
? {
|
||||||
@@ -52,9 +56,24 @@ function SpoolCard({ spool }: { spool: ISpool }) {
|
|||||||
<SpoolIcon color={colorObj} />
|
<SpoolIcon color={colorObj} />
|
||||||
<div className="info">
|
<div className="info">
|
||||||
<div className="title">
|
<div className="title">
|
||||||
#{spool.id} {filament_name}
|
<span>
|
||||||
|
#{spool.id} {filament_name}
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<Link to={editUrl("spool", spool.id)}>
|
||||||
|
<Button icon={<EditOutlined />} title={t("buttons.edit")} size="small" type="text" />
|
||||||
|
</Link>
|
||||||
|
<Link to={showUrl("spool", spool.id)}>
|
||||||
|
<Button icon={<EyeOutlined />} title={t("buttons.show")} size="small" type="text" />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="subtitle">
|
<div
|
||||||
|
className="subtitle"
|
||||||
|
style={{
|
||||||
|
color: token.colorTextSecondary,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{spool.remaining_weight} / {spool.filament.weight} g
|
{spool.remaining_weight} / {spool.filament.weight} g
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
.loc-container {
|
.loc-container {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
width: 20em;
|
width: 24em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loc-container .loc-spools {
|
.loc-container .loc-spools {
|
||||||
@@ -28,11 +28,15 @@
|
|||||||
.loc-container .spool .info {
|
.loc-container .spool .info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.5em;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loc-container .spool .info .title {
|
.loc-container .spool .info .title {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loc-container .spool .info .subtitle {
|
.loc-container .spool .info .subtitle {
|
||||||
|
|||||||
Reference in New Issue
Block a user