Skip to content

Commit

Permalink
Merge branch 'release/1.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorv1316 committed Apr 10, 2024
2 parents ffe2cb4 + be0329c commit cc19dd5
Show file tree
Hide file tree
Showing 54 changed files with 843 additions and 524 deletions.
14 changes: 10 additions & 4 deletions app/controllers/internal_api/v1/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@ class InternalApi::V1::InvitationsController < InternalApi::V1::ApplicationContr

def create
authorize :invitation
Invitations::CreateInvitationService.new(invitation_params, current_company, current_user).process
render json: { notice: I18n.t("invitation.create.success.message") }, status: :created
invitation = Invitations::CreateInvitationService.new(invitation_params, current_company, current_user).process
render :create, locals: {
invitation:
},
status: :created
end

def update
authorize @invitation

@invitation.update!(invitation_params)
render json: { notice: I18n.t("invitation.update.success.message") }, status: :ok
render :update, locals: {
invitation: @invitation
}, status: :ok
end

def destroy
authorize @invitation

invitation_id = @invitation.id
@invitation.destroy!
render json: { notice: I18n.t("invitation.delete.success.message") }, status: :ok
render json: { id: invitation_id, notice: I18n.t("invitation.delete.success.message") }, status: :ok
end

def resend
Expand Down
9 changes: 2 additions & 7 deletions app/controllers/internal_api/v1/team_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ def index

def update
authorize employment, policy_class: TeamPolicy

Team::UpdateService.new(
user = Team::UpdateService.new(
user_params:, current_company:, new_role: params[:role], user: employment.user).process

render json: {
user: employment.user,
notice: I18n.t("team.update.success.message")
}, status: :ok
render :update, locals: { user:, employment: }, status: :ok
end

def update_team_members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const MobileClientForm = ({
resetErrorOnChange
id="name"
label="Name"
marginBottom="mb-0"
name="name"
setFieldValue={setFieldValue}
/>
Expand All @@ -142,21 +143,6 @@ const MobileClientForm = ({
fieldTouched={touched.name}
/>
</div>
<div className="mt-4">
<div className="field relative">
<InputField
resetErrorOnChange
id="email"
label="Email"
name="email"
setFieldValue={setFieldValue}
/>
<InputErrors
fieldErrors={errors.email}
fieldTouched={touched.email}
/>
</div>
</div>
<div className="mt-4">
<div className="field relative">
<div className="flex flex-col">
Expand Down Expand Up @@ -332,7 +318,6 @@ interface IClientForm {

interface FormValues {
name: string;
email: string;
phone: string;
address1: string;
address2: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export const clientSchema = Yup.object().shape({
name: Yup.string()
.required("Name cannot be blank")
.max(30, "Maximum 30 characters are allowed"),
phone: Yup.string()
.required("Business phone number cannot be blank")
.matches(phoneRegExp, "Please enter a valid business phone number"),
phone: Yup.string().matches(
phoneRegExp,
"Please enter a valid business phone number"
),
address1: Yup.string()
.required("Address line cannot be blank")
.max(50, "Maximum 50 characters are allowed"),
Expand Down
1 change: 0 additions & 1 deletion app/javascript/src/components/Clients/ClientForm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const disableBtn = (values, errors, submitting) => {

if (
values.name &&
values.phone &&
values.address1 &&
values.country &&
values.state &&
Expand Down
11 changes: 11 additions & 0 deletions app/javascript/src/components/Clients/Details/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ const Header = ({
<ReminderIcon id="reminderIcon" size={16} />
<span className="ml-3">Payment Reminder</span>
</li>
<li
onClick={() => {
setShowContactModal(true);
setShowMobileModal(false);
}}
>
<button className="menuButton__list-item px-0">
<TeamsIcon size={16} />
<span className="ml-3">Add / View Contacts</span>
</button>
</li>
<li
className="menuButton__list-item px-0"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,21 +301,25 @@ const AddLineItemContainer = ({
/>
</div>
{showNewLineItemTable && (
<div className="absolute z-50 h-96 w-full rounded-md bg-white pb-4 shadow-lg">
<NewLineItemTable
dateFormat={dateFormat}
filteredLineItems={filteredLineItems}
loadMoreItems={loadNewLineItems}
loading={loading}
selectedLineItems={selectedLineItems}
setAddNew={setShowMenu}
setFilteredLineItems={setFilteredLineItems}
setLineItem={setLineItem}
setLoading={setLoading}
setMultiLineItemModal={setMultiLineItemModal}
setSelectedLineItems={setSelectedLineItems}
/>
</div>
<>
{filteredLineItems.length > 0 && (
<div className="absolute z-50 h-96 w-full rounded-md bg-white pb-4 shadow-lg">
<NewLineItemTable
dateFormat={dateFormat}
filteredLineItems={filteredLineItems}
loadMoreItems={loadNewLineItems}
loading={loading}
selectedLineItems={selectedLineItems}
setAddNew={setShowMenu}
setFilteredLineItems={setFilteredLineItems}
setLineItem={setLineItem}
setLoading={setLoading}
setMultiLineItemModal={setMultiLineItemModal}
setSelectedLineItems={setSelectedLineItems}
/>
</div>
)}
</>
)}
</div>
<div className="pb-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useEffect } from "react";

import dayjs from "dayjs";
import { lineTotalCalc, minToHHMM } from "helpers";
import { EmptyState } from "miruIcons";

import NewLineItemTableHeader from "./Header";

Expand Down Expand Up @@ -48,7 +47,7 @@ const NewLineItemTable = ({
Loading..
</p>
)}
{filteredLineItems.length > 0 ? (
{filteredLineItems.length > 0 && (
<div className="relative mt-4 flex flex-col overflow-scroll p-2 md:h-50">
{filteredLineItems.map((item, index) => {
const hoursLogged = minToHHMM(item.quantity);
Expand Down Expand Up @@ -88,18 +87,6 @@ const NewLineItemTable = ({
);
})}
</div>
) : (
!loading && (
<div className="mx-auto w-full">
<img
className="mx-auto mt-10 w-320 object-contain"
src={EmptyState}
/>
<p className="my-10 text-center font-manrope text-sm font-semibold not-italic leading-5 text-miru-dark-purple-200">
There are no unbilled time entries for this client
</p>
</div>
)
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,8 @@ import {
generateHolidayColor,
} from "components/Profile/Organization/Leaves/utils";

const LeaveBlock = ({ leaveType, setSelectedLeaveType }) => {
const {
icon,
color,
name,
netDuration,
netDays,
type,
category,
timePeriod,
} = leaveType;
const LeaveBlock = ({ leaveType, selectedLeaveType, setSelectedLeaveType }) => {
const { icon, color, name, netDuration, type, category, label } = leaveType;

const leaveIcon =
type == "leave" ? generateLeaveIcon(icon) : generateHolidayIcon(icon);
Expand All @@ -29,13 +20,20 @@ const LeaveBlock = ({ leaveType, setSelectedLeaveType }) => {
type == "leave" ? generateLeaveColor(color) : generateHolidayColor(color);

const formattedDuration =
netDuration < 0
? `-${minToHHMM(-netDuration)} h (${netDays} days)`
: `${minToHHMM(netDuration)} h (${netDays} days)`;
category == "national" || category == "optional"
? label
: netDuration < 0
? `-${minToHHMM(-netDuration)} h (${label})`
: `${minToHHMM(netDuration)} h (${label})`;

const selectedDiv =
selectedLeaveType?.name == name
? "flex w-full cursor-pointer justify-start rounded-lg p-2 text-white lg:flex-col lg:p-6 shadow-2xl border-2 border-miru-dark-purple-1000 border-opacity-20"
: "flex w-full cursor-pointer justify-start rounded-lg p-2 text-white lg:flex-col lg:p-6 hover:opacity-80";

return (
<div
className="flex w-full cursor-pointer justify-start rounded-lg p-2 text-white lg:flex-col lg:p-6"
className={selectedDiv}
style={{ background: leaveColor.value }}
onClick={() => setSelectedLeaveType(leaveType)}
>
Expand All @@ -48,8 +46,7 @@ const LeaveBlock = ({ leaveType, setSelectedLeaveType }) => {
<div className="mt-4 flex flex-col">
<span className="text-xs font-semibold lg:text-sm">{name}</span>
<span className="mt-2 text-base font-semibold lg:text-2xl">
{category !== "national" && formattedDuration}
{category == "optional" && `this ${timePeriod}`}
{formattedDuration}
</span>
</div>
</div>
Expand Down
40 changes: 24 additions & 16 deletions app/javascript/src/components/LeaveManagement/Container/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

import { minToHHMM } from "helpers";
import { Button } from "StyledComponents";
import { XIcon } from "miruIcons";

import { Divider } from "common/Divider";

Expand All @@ -17,36 +17,44 @@ const Container = ({
setSelectedLeaveType,
}) => (
<div className="mx-4 my-6 h-full lg:mx-0">
<div className="flex justify-between">
<span className="text-base font-normal text-miru-dark-purple-1000 lg:text-2xl">
{getLeaveBalanaceDateText()}
</span>
<Button style="ternary" onClick={() => setSelectedLeaveType(null)}>
{selectedLeaveType && "View all leaves"}
</Button>
</div>
<p className="text-base font-normal text-miru-dark-purple-1000 lg:text-2xl">
{getLeaveBalanaceDateText()}
</p>
<div className="mt-6 grid w-full gap-4 lg:grid-cols-3">
{leaveBalance.map((leaveType, index) => (
<LeaveBlock
key={index}
leaveType={leaveType}
selectedLeaveType={selectedLeaveType}
setSelectedLeaveType={setSelectedLeaveType}
/>
))}
</div>
<div className="mt-10">
<div className="flex items-center justify-between py-3 lg:py-5">
<span className="text-lg font-bold text-miru-dark-purple-1000 lg:text-xl">
{`Leave Details ${
selectedLeaveType ? `(${selectedLeaveType.name})` : ""
}`}
</span>
<span className="text-sm font-medium text-miru-dark-purple-1000 lg:text-base">
<div className="flex items-center">
<span className="mr-4 text-lg font-bold text-miru-dark-purple-1000 lg:text-xl">
Leave Details
</span>
{selectedLeaveType && (
<div className="flex items-center justify-center rounded-xl bg-miru-gray-400 px-3 py-1 lg:mx-2 lg:my-0">
<span className="tracking-wide text-base font-normal capitalize text-miru-dark-purple-1000">
{selectedLeaveType.name}
</span>
<XIcon
className="ml-2 cursor-pointer"
size={14}
onClick={() => setSelectedLeaveType(null)}
/>
</div>
)}
</div>
<p className="text-sm font-medium text-miru-dark-purple-1000 lg:text-base">
Total :{" "}
<span className="font-bold">
{minToHHMM(totalTimeoffEntriesDuration)}
</span>
</span>
</p>
</div>
<Divider />
<Table timeoffEntries={timeoffEntries} />
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/components/LeaveManagement/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Header = ({
}) => (
<div className="m-4 flex items-center justify-between lg:mx-0">
<span className="hidden text-3xl font-bold text-miru-dark-purple-1000 lg:inline">
Leave Management
Leaves & Holidays
</span>
<CustomYearPicker
nextYearButtonDisabled
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/components/LeaveManagement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const LeaveManagement = () => {
date = new Date();
}

return `Leave Balance Untill ${format(date, "do MMM yyyy")}`;
return `Balance Until ${format(date, "do MMM yyyy")}`;
};

return (
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/components/Navbar/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const navOptions = [
},
{
logo: <CalendarIcon className="mr-0 md:mr-4" size={26} />,
label: "Leave Management",
label: "Leaves & Holidays",
path: Paths.Leave_Management,
allowedRoles: ["admin", "owner", "employee"],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ const CompanyDetailsForm = ({
values.city?.value?.trim() &&
values.timezone?.value?.trim() &&
values.address_line_1?.trim() &&
values.business_phone?.trim() &&
values.zipcode?.trim()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export const companyDetailsFormValidationSchema = Yup.object().shape({
company_name: Yup.string()
.required("Company name cannot be blank")
.max(30, "Maximum 30 characters are allowed"),
business_phone: Yup.string()
.required("Business phone number cannot be blank")
.matches(phoneRegExp, "Please enter a valid business phone number"),
business_phone: Yup.string().matches(
phoneRegExp,
"Please enter a valid business phone number"
),
address_line_1: Yup.string()
.required("Address line cannot be blank")
.max(50, "Maximum 50 characters are allowed"),
Expand Down
11 changes: 6 additions & 5 deletions app/javascript/src/components/Profile/Layout/MobileNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ const getSettingsNavUrls = memberId => [
text: "ALLOCATED DEVICES",
icon: <MobileIcon size={16} />,
},
{
url: "/settings/compensation",
text: "COMPENSATION",
icon: <PaymentsIcon size={16} />,
},
//Todo: Uncomment while API integration
// {
// url: "/settings/compensation",
// text: "COMPENSATION",
// icon: <PaymentsIcon size={16} />,
// },
],
},

Expand Down
Loading

0 comments on commit cc19dd5

Please sign in to comment.