Skip to content

Commit

Permalink
Merge pull request #3198 from ever-co/3186-bug-planned--on-the-calend…
Browse files Browse the repository at this point in the history
…ar-planned-date-can-not-be-selected-to-plan-a-task

refactor:  user should be able to plan tasks for Dates with Planned
  • Loading branch information
evereq authored Oct 28, 2024
2 parents 347e93a + 32d2f87 commit 45fb45e
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 23 deletions.
22 changes: 12 additions & 10 deletions apps/web/lib/features/daily-plan/create-daily-plan-form-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useForm } from 'react-hook-form';
import { DailyPlanStatusEnum, IDailyPlanMode, IOrganizationTeamList, OT_Member } from '@app/interfaces';
import { useAuthenticateUser, useDailyPlan, useOrganizationTeams } from '@app/hooks';
import { Avatar, Card, Modal, Text } from 'lib/components';
import { imgTitle, tomorrowDate } from '@app/helpers';
import { imgTitle, tomorrowDate, yesterdayDate } from '@app/helpers';
import { ReloadIcon } from '@radix-ui/react-icons';
import moment from 'moment';
import { Calendar } from '@components/ui/calendar';
Expand All @@ -16,6 +16,7 @@ import { Check } from 'lucide-react';
import { cn } from 'lib/utils';
import { MdOutlineKeyboardArrowDown } from 'react-icons/md';
import { LAST_OPTION__CREATE_DAILY_PLAN_MODAL } from '@app/constants';
import { useTranslations } from 'next-intl';

export function CreateDailyPlanFormModal({
open,
Expand All @@ -39,7 +40,7 @@ export function CreateDailyPlanFormModal({
const latestOption: 'Select' | 'Select & Close' | null = window.localStorage.getItem(
LAST_OPTION__CREATE_DAILY_PLAN_MODAL
) as 'Select' | 'Select & Close';

const t = useTranslations();
const existingPlanDates = useMemo(
() => profileDailyPlans?.items?.map((plan) => new Date(plan.date)),
[profileDailyPlans.items]
Expand Down Expand Up @@ -92,6 +93,7 @@ export function CreateDailyPlanFormModal({
organizationId: user?.employee.organizationId
}).then(() => {
reset();
setIsOpen(false);
});
},
[
Expand Down Expand Up @@ -121,7 +123,7 @@ export function CreateDailyPlanFormModal({
{/* Form header */}
<div className="mb-3">
<Text.Heading as="h3" className="text-start">
Select Date
{t('common.SELECT_DATE')}
</Text.Heading>
</div>

Expand Down Expand Up @@ -151,7 +153,7 @@ export function CreateDailyPlanFormModal({
className="px-7 py-4 w-36 font-light rounded-md"
onClick={() => closeModal()}
>
Cancel
{t('common.CANCEL')}
</Button>
<div
className={clsxm(
Expand Down Expand Up @@ -197,7 +199,7 @@ export function CreateDailyPlanFormModal({
type="submit"
className="w-full text-xs"
>
Select
{t('common.SELECT')}
</Button>
<Button
disabled={createDailyPlanLoading}
Expand All @@ -207,7 +209,7 @@ export function CreateDailyPlanFormModal({
type="submit"
className="w-full text-xs"
>
Select & Close
{t('common.SELECT_AND_CLOSE')}
</Button>
</div>
</div>
Expand Down Expand Up @@ -238,7 +240,7 @@ const CustomCalendar = memo(function CustomCalendar({
selected={date}
onSelect={(day) => setDate(day ? day : new Date(tomorrowDate))}
initialFocus
disabled={[...existingPlanDates, { from: new Date(1970, 1, 1), to: tomorrowDate }]}
disabled={[{ from: new Date(1970, 1, 1), to: yesterdayDate }]}
modifiers={{
booked: existingPlanDates
}}
Expand Down Expand Up @@ -290,12 +292,12 @@ function MembersList({
{(member?.employee?.user?.image?.thumbUrl ||
member?.employee?.user?.image?.fullUrl ||
member?.employee?.user?.imageUrl) &&
isValidUrl(
member?.employee?.user?.image?.thumbUrl ||
isValidUrl(
member?.employee?.user?.image?.thumbUrl ||
member?.employee?.user?.image?.fullUrl ||
member?.employee?.user?.imageUrl ||
''
) ? (
) ? (
<Avatar
size={36}
className="relative cursor-pointer dark:border-[0.25rem] dark:border-[#26272C]"
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@
"ASSIGNEE": "المسند إليه",
"CHANGE_RELATIONS": "تغيير العلاقات",
"SET_AS_NEXT": "تعيين كالتالي",
"MOVE_TO": "نقل إلى"
"MOVE_TO": "نقل إلى",
"SELECT_DATE": "اختر التاريخ",
"SELECT_AND_CLOSE": "اختر وأغلق"
},
"sidebar": {
"DASHBOARD": "لوحة التحكم",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Назначен",
"CHANGE_RELATIONS": "Променете отношенията",
"SET_AS_NEXT": "Задайте като следващо",
"MOVE_TO": "Преместете в"
"MOVE_TO": "Преместете в",
"SELECT_DATE": "Изберете дата",
"SELECT_AND_CLOSE": "Изберете и затворете"
},
"hotkeys": {
"HELP": "Помощ",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Zessionar",
"CHANGE_RELATIONS": "Beziehungen ändern",
"SET_AS_NEXT": "Als nächstes festlegen",
"MOVE_TO": "Verschieben nach"
"MOVE_TO": "Verschieben nach",
"SELECT_DATE": "Datum auswählen",
"SELECT_AND_CLOSE": "Auswählen und schließen"
},
"hotkeys": {
"HELP": "Hilfe",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Assignee",
"CHANGE_RELATIONS": "Change relations",
"SET_AS_NEXT": "Set as next",
"MOVE_TO": "Move to"
"MOVE_TO": "Move to",
"SELECT_DATE": "Select date",
"SELECT_AND_CLOSE": "Select & Close"
},
"hotkeys": {
"HELP": "Help",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Cesionario",
"CHANGE_RELATIONS": "Cambiar relaciones",
"SET_AS_NEXT": "Establecer como siguiente",
"MOVE_TO": "Mover a"
"MOVE_TO": "Mover a",
"SELECT_DATE": "Seleccionar fecha",
"SELECT_AND_CLOSE": "Seleccionar y cerrar"
},
"hotkeys": {
"HELP": "Ayuda",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Cessionnaire",
"CHANGE_RELATIONS": "Changer les relations",
"SET_AS_NEXT": "Définir comme suivant",
"MOVE_TO": "Déplacer vers"
"MOVE_TO": "Déplacer vers",
"SELECT_DATE": "Sélectionner la date",
"SELECT_AND_CLOSE": "Sélectionner et fermer"
},
"hotkeys": {
"HELP": "Aide",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "נמען",
"CHANGE_RELATIONS": "שנה יחסים",
"SET_AS_NEXT": "הגדר כהבא",
"MOVE_TO": "העבר אל"
"MOVE_TO": "העבר אל",
"SELECT_DATE": "בחר תאריך",
"SELECT_AND_CLOSE": "בחר וסגור"
},
"hotkeys": {
"HELP": "עזרה",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Assegnatario",
"CHANGE_RELATIONS": "Cambia relazioni",
"SET_AS_NEXT": "Imposta come successivo",
"MOVE_TO": "Sposta a"
"MOVE_TO": "Sposta a",
"SELECT_DATE": "Seleziona data",
"SELECT_AND_CLOSE": "Seleziona e chiudi"
},
"hotkeys": {
"HELP": "Aiuto",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Cessionaris",
"CHANGE_RELATIONS": "Verander relaties",
"SET_AS_NEXT": "Instellen als volgende",
"MOVE_TO": "Verplaatsen naar"
"MOVE_TO": "Verplaatsen naar",
"SELECT_DATE": "Selecteer datum",
"SELECT_AND_CLOSE": "Selecteren en sluiten"
},
"hotkeys": {
"HELP": "Help",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Cesjonariusz",
"CHANGE_RELATIONS": "Zmień relacje",
"SET_AS_NEXT": "Ustaw jako następny",
"MOVE_TO": "Przenieś do"
"MOVE_TO": "Przenieś do",
"SELECT_DATE": "Wybierz datę",
"SELECT_AND_CLOSE": "Wybierz i zamknij"
},
"hotkeys": {
"HELP": "Pomoc",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Cessionário",
"CHANGE_RELATIONS": "Alterar relações",
"SET_AS_NEXT": "Definir como o próximo",
"MOVE_TO": "Mover para"
"MOVE_TO": "Mover para",
"SELECT_DATE": "Selecionar data",
"SELECT_AND_CLOSE": "Selecionar e fechar"
},
"hotkeys": {
"HELP": "Ajuda",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "Исполнитель",
"CHANGE_RELATIONS": "Изменить отношения",
"SET_AS_NEXT": "Установить следующим",
"MOVE_TO": "Переместить в"
"MOVE_TO": "Переместить в",
"SELECT_DATE": "Выберите дату",
"SELECT_AND_CLOSE": "Выбрать и закрыть"
},
"hotkeys": {
"HELP": "Помощь",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@
"ASSIGNEE": "受让人",
"CHANGE_RELATIONS": "更改关系",
"SET_AS_NEXT": "设置为下一个",
"MOVE_TO": "移动到"
"MOVE_TO": "移动到",
"SELECT_DATE": "选择日期",
"SELECT_AND_CLOSE": "选择并关闭"
},
"hotkeys": {
"HELP": "帮助",
Expand Down

0 comments on commit 45fb45e

Please sign in to comment.