Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Lieu Admin créer un créneau de campagne #89

Merged
merged 1 commit into from
Feb 26, 2024
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
1 change: 1 addition & 0 deletions web/components/Account/Place/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const StyleWrapper = styled.div`
z-index: 11;
border-radius: 8px;
margin: 3px 2px 3px 2px;
mix-blend-mode: multiply;
}
`

Expand Down
12 changes: 10 additions & 2 deletions web/components/Account/Place/ScheduleSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ScheduleEventWhen } from '~@types/schedule-event.d'
import isSameDay from 'date-fns/isSameDay'
import ScheduleContext from '~components/Account/Place/ScheduleContext'
import PeriodEvent from '~components/Place/PeriodEvent'
import useCampaignContext from '~components/Campaign/useCampaignContext'

const styleSelected = {
border: '1px dashed',
Expand Down Expand Up @@ -58,6 +59,7 @@ const Event = ({
isCampaignMode = false,
}) => {
const { setToDelete, eventsIdToDelete, place } = useContext(ScheduleContext)
const { currentCampaign } = useCampaignContext()
const isPeriod = useMemo(() => {
if (!range) return null
return !isSameDay(range.start, range.end)
Expand All @@ -68,8 +70,14 @@ const Event = ({
id,
])

const isDisabled =
const isFromOtherTab =
(isCampaignMode && !isCampaignEvent) || (!isCampaignMode && isCampaignEvent)
const isClosedDispoMode =
isCampaignMode &&
isCampaignEvent &&
currentCampaign.mode !== 'disponibilities'

const isDisabled = isFromOtherTab || isClosedDispoMode

return (
<Box
Expand Down Expand Up @@ -113,7 +121,7 @@ const Event = ({
}}
borderColor={isSelected ? 'blue.500' : 'transparent'}
{...getStyle(status)}
opacity={isDisabled ? 0.6 : 1}
opacity={isFromOtherTab ? 0.6 : 1}
>
{isPeriod && (
<PeriodEvent
Expand Down
6 changes: 4 additions & 2 deletions web/components/Campaign/Places/Admin/CampaignSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CampaignScheduleInfo from '~components/Campaign/Places/Admin/CampaignSche
import * as yup from 'yup'
import { useTranslation } from 'next-i18next'
import ScheduleContext from '~components/Account/Place/ScheduleContext'
import { ScheduleEventWhen, ScheduleEventType } from '~@types/schedule-event.d'
import { ScheduleEventType } from '~@types/schedule-event.d'

interface Props {
place: Espace
Expand Down Expand Up @@ -69,7 +69,9 @@ const CampaignPlaceSchedule = ({ place }: Props) => {
<FormProvider {...form}>
<ScheduleProvider place={place}>
<Stack direction={{ base: 'column-reverse', lg: 'row' }} spacing={4}>
<Schedule isCampaignMode />
<Box display={{ base: 'none', lg: 'block' }}>
<Schedule isCampaignMode />
</Box>

<Box flex={1}>
{showForm ? (
Expand Down
5 changes: 5 additions & 0 deletions web/components/Campaign/Places/Admin/CampaignScheduleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { client } from '~api/client-api'
import { setHours } from 'date-fns'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import { format } from '~utils/date'
import Schedule from '~components/Account/Place/Schedule'

export const STAFF_VALUES = ['no', 'light', 'sound', 'video', 'scene']

Expand Down Expand Up @@ -132,6 +133,10 @@ const CampaignScheduleForm = ({ place, hideForm }: Props) => {
</Text>
<CampaignDatePicker control={control} />

<Box display={{ base: 'block', lg: 'none' }} width="100%">
<Schedule isCampaignMode />
</Box>

<Box display={staff?.includes('no') && 'none'} width="100%">
<InputMultiSelect
name="staff"
Expand Down
8 changes: 6 additions & 2 deletions web/components/Campaign/Places/Admin/CampaignScheduleInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ const CampaignScheduleInfo = ({ place, showForm }: Props) => {
<Text>
{currentCampaign?.mode === 'disponibilities'
? t(
`campaign.helpers.disponibilities.schedule.open_disponibilities`,
`campaign.helpers.disponibilities.schedule.${
currentCampaign?.disponibilities_max === 1
? 'open_disponibility'
: 'open_disponibilities'
}`,
{ title: currentCampaign?.title },
)
: t(
Expand Down Expand Up @@ -91,7 +95,7 @@ const CampaignScheduleInfo = ({ place, showForm }: Props) => {
variant="outline"
colorScheme="blue"
as={Link}
href={`${ROUTE_ACCOUNT_APPLICATIONS}?espace=${place.id}&disponibility=${campaignDispos[0]?.id}`}
href={`${ROUTE_ACCOUNT_APPLICATIONS}?campaign=${currentCampaign?.id}&espace=${place.id}&disponibility=${campaignDispos[0]?.id}`}
>
{t('campaign.helpers.applications.schedule.see_applications')}
</Button>
Expand Down
3 changes: 2 additions & 1 deletion web/public/locales/fr/place.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@
"schedule": {
"title": "Ajoutez ou modifiez vos créneaux avant le {{disponibility_end}}. ",
"description": "\n Vous pouvez ajouter jusqu’à {{disponibilities_max}} créneaux dédiés au dispositif {{title}} pour un même espace. Les créneaux doivent impérativement faire {{duration}} jours, et se dérouler entre le {{campaign_start}} et le {{campaign_end}}",
"open_disponibilities": "créneaux qui seront ouverts à candidatures {{title}}"
"open_disponibilities": "créneaux qui seront ouverts à candidatures {{title}}",
"open_disponibility": "créneau qui sera ouvert à candidatures {{title}}"
}
}
}
Expand Down
Loading