Skip to content

Commit

Permalink
Merge branch 'release/0.19.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
“Apoorv committed Jul 31, 2023
2 parents d353d54 + 3004cdf commit 47cf5c6
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 123 deletions.
55 changes: 23 additions & 32 deletions app/javascript/src/components/Invoices/List/SendInvoice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import invoicesApi from "apis/invoices";
import { CustomAdvanceInput } from "common/CustomAdvanceInput";
import { CustomInputText } from "common/CustomInputText";
import { CustomTextareaAutosize } from "common/CustomTextareaAutosize";
import Recipient from "components/Invoices/common/InvoiceForm/SendInvoice/Recipient";
import { ApiStatus as InvoiceStatus } from "constants/index";
import { useUserContext } from "context/UserContext";

import {
isEmailValid,
Expand All @@ -31,22 +33,6 @@ interface InvoiceEmail {
recipients: string[];
}

const Recipient: React.FC<{ email: string; handleClick: any }> = ({
email,
handleClick,
}) => (
<div className="space-XIcon-2 m-0.5 flex w-fit items-center rounded-full border bg-miru-gray-400 px-2 py-1 text-sm font-medium">
<p>{email}</p>
{/* <button
className="text-miru-black-1000 hover:text-miru-red-400"
type="button"
onClick={handleClick}
>
<XIcon size={14} weight="bold" />
</button> */}
</div>
);

const SendInvoice: React.FC<any> = ({
isSending,
setIsSending,
Expand All @@ -55,6 +41,7 @@ const SendInvoice: React.FC<any> = ({
isSendReminder = false,
setISendReminder,
}) => {
const { user } = useUserContext();
const [status, setStatus] = useState<InvoiceStatus>(InvoiceStatus.IDLE);
const [invoiceEmail, setInvoiceEmail] = useState<InvoiceEmail>({
subject: emailSubject(invoice, isSendReminder),
Expand Down Expand Up @@ -173,24 +160,28 @@ const SendInvoice: React.FC<any> = ({
key={recipient}
/>
))}
{/* <input
name="to"
ref={input}
style={{ width }}
type="email"
value={newRecipient}
className={cn(
"focus:outline-none mx-1.5 w-fit cursor-text",
{
"text-miru-red-400": !isEmailValid(newRecipient),
}
)}
onChange={e => setNewRecipient(e.target.value.trim())}
onKeyDown={handleInput}
/> */}
{user.email == "supriya@saeloun.com" && (
<input
name="to"
ref={input}
style={{ width }}
type="email"
value={newRecipient}
className={cn(
"focus:outline-none mx-1.5 w-fit cursor-text",
{
"text-miru-red-400": !isEmailValid(newRecipient),
}
)}
onChange={e => setNewRecipient(e.target.value.trim())}
onKeyDown={handleInput}
/>
)}
</div>
}
// onClick={() => input.current.focus()}
onClick={() =>
user.email == "supriya@saeloun.com" && input.current.focus()
}
/>
</fieldset>
<fieldset className="field_with_errors flex flex-col">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";

import { XIcon } from "miruIcons";

import { useUserContext } from "context/UserContext";

const Recipient: React.FC<{ email: string; handleClick: any }> = ({
email,
handleClick,
}) => {
const { user } = useUserContext();

return (
<div className="space-XIcon-2 m-0.5 flex w-fit items-center rounded-full border bg-miru-gray-400 px-2 py-1">
<p>{email}</p>
{user.email == "supriya@saeloun.com" && (
<button
className="text-miru-black-1000 hover:text-miru-red-400"
type="button"
onClick={handleClick}
>
<XIcon size={14} weight="bold" />
</button>
)}
</div>
);
};

export default Recipient;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import { Toastr } from "StyledComponents";

import invoicesApi from "apis/invoices";
import { ApiStatus as InvoiceStatus } from "constants/index";
import { useUserContext } from "context/UserContext";

import Recipient from "./Recipient";
import {
isEmailValid,
emailSubject,
Expand All @@ -30,22 +32,6 @@ interface InvoiceEmail {
recipients: string[];
}

const Recipient: React.FC<{ email: string; handleClick: any }> = ({
email,
handleClick,
}) => (
<div className="space-XIcon-2 m-0.5 flex w-fit items-center rounded-full border bg-miru-gray-400 px-2 py-1">
<p>{email}</p>
{/* <button
className="text-miru-black-1000 hover:text-miru-red-400"
type="button"
onClick={handleClick}
>
<XIcon size={14} weight="bold" />
</button> */}
</div>
);

const SendInvoice: React.FC<any> = ({
invoice,
setIsSending,
Expand All @@ -54,6 +40,8 @@ const SendInvoice: React.FC<any> = ({
isSendReminder = false,
setIsSendReminder,
}) => {
const { user } = useUserContext();

const [status, setStatus] = useState<InvoiceStatus>(InvoiceStatus.IDLE);
const [invoiceEmail, setInvoiceEmail] = useState<InvoiceEmail>({
subject: emailSubject(invoice, isSendReminder),
Expand Down Expand Up @@ -177,7 +165,9 @@ const SendInvoice: React.FC<any> = ({
"flex flex-wrap rounded bg-miru-gray-100 p-1.5",
{ "h-9": !invoiceEmail.recipients }
)}
// onClick={() => input.current.focus()}
onClick={() =>
user.email == "supriya@saeloun.com" && input.current.focus()
}
>
{invoiceEmail.recipients.map(recipient => (
<Recipient
Expand All @@ -186,21 +176,23 @@ const SendInvoice: React.FC<any> = ({
key={recipient}
/>
))}
{/* <input
name="to"
ref={input}
style={{ width }}
type="email"
value={newRecipient}
className={cn(
"focus:outline-none mx-1.5 w-fit cursor-text rounded bg-miru-gray-100 py-2",
{
"text-miru-red-400": !isEmailValid(newRecipient),
}
)}
onChange={e => setNewRecipient(e.target.value.trim())}
onKeyDown={handleInput}
/> */}
{user.email == "supriya@saeloun.com" && (
<input
name="to"
ref={input}
style={{ width }}
type="email"
value={newRecipient}
className={cn(
"focus:outline-none mx-1.5 w-fit cursor-text rounded bg-miru-gray-100 py-2",
{
"text-miru-red-400": !isEmailValid(newRecipient),
}
)}
onChange={e => setNewRecipient(e.target.value.trim())}
onKeyDown={handleInput}
/>
)}
</div>
</fieldset>
<fieldset className="field_with_errors flex flex-col">
Expand Down
58 changes: 25 additions & 33 deletions app/javascript/src/components/Invoices/popups/SendInvoice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import invoicesApi from "apis/invoices";
import { CustomAdvanceInput } from "common/CustomAdvanceInput";
import { CustomInputText } from "common/CustomInputText";
import { CustomTextareaAutosize } from "common/CustomTextareaAutosize";
import Recipient from "components/Invoices/common/InvoiceForm/SendInvoice/Recipient";
import { ApiStatus as InvoiceStatus } from "constants/index";
import { useUserContext } from "context/UserContext";

import {
isEmailValid,
Expand All @@ -33,22 +35,6 @@ interface InvoiceEmail {
recipients: string[];
}

const Recipient: React.FC<{ email: string; handleClick: any }> = ({
email,
handleClick,
}) => (
<div className="space-XIcon-2 m-0.5 flex w-fit items-center rounded-full border bg-miru-gray-400 px-2 py-1">
<p>{email}</p>
{/* <button
className="text-miru-black-1000 hover:text-miru-red-400"
type="button"
onClick={handleClick}
>
<XIcon size={14} weight="bold" />
</button> */}
</div>
);

const SendInvoice: React.FC<any> = ({
invoice,
setIsSending,
Expand All @@ -57,6 +43,7 @@ const SendInvoice: React.FC<any> = ({
// eslint-disable-next-line @typescript-eslint/no-empty-function
setIsSendReminder = _value => {},
}) => {
const { user } = useUserContext();
const [status, setStatus] = useState<InvoiceStatus>(InvoiceStatus.IDLE);
const [invoiceEmail, setInvoiceEmail] = useState<InvoiceEmail>({
subject: emailSubject(invoice, isSendReminder),
Expand Down Expand Up @@ -190,24 +177,28 @@ const SendInvoice: React.FC<any> = ({
key={recipient}
/>
))}
{/* <input
name="to"
ref={input}
style={{ width }}
type="email"
value={newRecipient}
className={cn(
"focus:outline-none mx-1.5 w-fit cursor-text",
{
"text-miru-red-400": !isEmailValid(newRecipient),
}
)}
onChange={e => setNewRecipient(e.target.value.trim())}
onKeyDown={handleInput}
/> */}
{user.email == "supriya@saeloun.com" && (
<input
name="to"
ref={input}
style={{ width }}
type="email"
value={newRecipient}
className={cn(
"focus:outline-none mx-1.5 w-fit cursor-text",
{
"text-miru-red-400": !isEmailValid(newRecipient),
}
)}
onChange={e => setNewRecipient(e.target.value.trim())}
onKeyDown={handleInput}
/>
)}
</div>
}
// onClick={() => input.current.focus()}
onClick={() =>
user.email == "supriya@saeloun.com" && input.current.focus()
}
/>
</fieldset>
<fieldset className="field_with_errors flex flex-col">
Expand Down Expand Up @@ -249,7 +240,8 @@ const SendInvoice: React.FC<any> = ({
`mt-6 flex w-full justify-center rounded-md border border-transparent p-3 text-lg font-bold
uppercase text-white shadow-sm
${
invoiceEmail?.recipients.length > 0
invoiceEmail?.recipients.length > 0 &&
status !== InvoiceStatus.LOADING
? `focus:outline-none cursor-pointer bg-miru-han-purple-1000 hover:bg-miru-han-purple-600 focus:ring-2
focus:ring-miru-han-purple-600 focus:ring-offset-2`
: "cursor-not-allowed border-transparent bg-indigo-100 hover:border-transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,30 @@ const OrgDetails = () => {
id,
} = companyDetails;

const { name: CountryName } = address.country
? Country.getCountryByCode(address.country)
const { address_line_1, address_line_2, city, state, pin, country } =
address;

const { name: CountryName } = country
? Country.getCountryByCode(country)
: { name: "" };

const companyAddrParts = [
address_line_1,
address_line_2,
city,
state,
pin,
CountryName,
];

const companyAddr = companyAddrParts
.filter(part => part !== null && part !== undefined && part !== "")
.join(", ");

setOrgDetails({
logoUrl: logo,
companyName: name,
companyAddr: `${address.address_line_1} ${address.address_line_2}, ${address.city}, ${address.state} ${address.pin}, ${CountryName}`,
companyAddr,
companyPhone: business_phone,
countryName: address.country,
companyCurrency: currency,
Expand Down
Loading

0 comments on commit 47cf5c6

Please sign in to comment.