Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const InvoiceTable = ({
<tr className="w-full ">
<td colSpan={6} className="py-4 relative">
{
addNew && <div ref={wrapperRef} className="box-shadow rounded absolute m-0 font-medium text-sm text-miru-dark-purple-1000 bg-white top-0 w-full">
addNew && <div ref={wrapperRef} className="box-shadow z-10 rounded absolute m-0 font-medium text-sm text-miru-dark-purple-1000 bg-white top-0 w-full">
{getNewLineItemDropdown()}
</div>
}
Expand Down
50 changes: 27 additions & 23 deletions app/javascript/src/components/Invoices/Invoice/LineItem.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import React from "react";
import dayjs from "dayjs";

const LineItem = ({ item }) => (
<tr>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-left ">
{item.name}
{item.first_name} {item.last_name}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-left ">
{item.date}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-left ">
{item.description}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{item.rate}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{item.qty / 60}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{(item.qty / 60) * item.rate}
</td>
</tr>
);
const LineItem = ({ item }) => {
const date = dayjs(item.date).format("DD.MM.YYYY");
return (
<tr>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-left ">
{item.name}
{item.first_name} {item.last_name}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-left ">
{date}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-left ">
{item.description}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{item.rate}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{item.qty / 60}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{(item.qty / 60) * item.rate}
</td>
</tr>
);
};

export default LineItem;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useRef } from "react";
import React, { useState } from "react";
import DatePicker from "react-datepicker";

const EditLineItems = ({
item,
Expand All @@ -10,19 +11,18 @@ const EditLineItems = ({
const strName = item.name || `${item.first_name} ${item.last_name}`;
const quantity = (item.qty / 60) || (item.quantity / 60);
const [name, setName] = useState<string>(strName);
const [lineItemDate, setLineItemDate] = useState<string>(item.date);
const newDate = Date.parse(item.date);
const [lineItemDate, setLineItemDate] = useState(newDate);
const [description, setDescription] = useState<string>(item.description);
const [rate, setRate] = useState<any>(item.rate);
const [qty, setQty] = useState<any>(quantity);
const [lineTotal, setLineTotal] = useState<any>((item.qty / 60) * item.rate);
const ref = useRef();

const onEnter = e => {
if (e.key == "Enter") {
const sanitizedSelected = selectedOption.filter(option =>
option.id !== item.id || option.timesheet_entry_id !== item.timesheet_entry_id
);

const names = name.split(" ");
const newItem = {
...item,
Expand Down Expand Up @@ -53,15 +53,12 @@ const EditLineItems = ({
/>
</td>
<td className="w-full">
<input
type="text"
placeholder="Date"
ref={ref}
pattern="\d{1,2}-\d{1,2}-\d{4}"
onFocus={(e) => (e.target.type = "date")}
className=" p-1 px-2 bg-white rounded w-full font-medium text-sm text-miru-dark-purple-1000 focus:outline-none focus:border-miru-gray-1000 focus:ring-1 focus:ring-miru-gray-1000"
value={lineItemDate}
onChange={e => setLineItemDate(e.target.value)}
<DatePicker
wrapperClassName="datePicker invoice-datepicker"
calendarClassName="miru-calendar invoice-datepicker-option"
dateFormat="dd.MM.yyyy"
selected={lineItemDate}
onChange={(date) => setLineItemDate(date)}
onKeyDown={e => onEnter(e)}
/>
</td>
Expand Down
12 changes: 12 additions & 0 deletions app/javascript/stylesheets/react-calendar.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
.invoice-datepicker {
input {
@apply py-1 px-2 bg-white rounded w-full font-medium text-sm text-miru-dark-purple-1000 focus:outline-none focus:border-miru-gray-1000 focus:ring-1 focus:ring-miru-gray-1000;
}
}

.invoice-datepicker-option {
.react-datepicker__triangle {
display: none;
}
}

.miru-calendar {
padding: 28px;
position: absolute !important;
Expand Down