-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add open Facebook Event button (#143)
Co-authored-by: Marc Schmidt <[email protected]>
- Loading branch information
Showing
31 changed files
with
2,210 additions
and
86 deletions.
There are no files selected for viewing
53 changes: 0 additions & 53 deletions
53
src/client/src/app/+state/events/actions/commit-event.action.ts
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
src/client/src/app/+state/events/actions/update-event.action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { inject } from '@angular/core'; | ||
import { on } from '@ngrx/store'; | ||
import { produce } from 'immer'; | ||
import { switchMap } from 'rxjs'; | ||
|
||
import { EventAdministrationService } from '../../../api/services'; | ||
import { createHttpAction, handleHttpAction, onHttpAction, toHttpAction } from '../../action-state'; | ||
import { createFunctionalEffect } from '../../functional-effect'; | ||
import { Effects, Reducers } from '../../utils'; | ||
import { EVENTS_ACTION_SCOPE } from '../consts'; | ||
import { selectEventsActionState } from '../events.selectors'; | ||
import { EventsFeatureState, eventEntityAdapter } from '../events.state'; | ||
|
||
export const updateEventAction = createHttpAction<{ | ||
eventId: string; | ||
commit?: boolean; | ||
externalUri?: string; | ||
}>()(EVENTS_ACTION_SCOPE, 'Update Event'); | ||
|
||
export const updateEventReducers: Reducers<EventsFeatureState> = [ | ||
on(updateEventAction.success, (state, { props }) => | ||
eventEntityAdapter.mapOne( | ||
{ | ||
id: props.eventId, | ||
map: produce(draft => { | ||
draft.staged = props.commit ? props.commit : undefined; | ||
draft.externalUri = props.externalUri != undefined ? props.externalUri : undefined; | ||
}), | ||
}, | ||
state | ||
) | ||
), | ||
handleHttpAction('update', updateEventAction), | ||
]; | ||
|
||
export const updateEventEffects: Effects = { | ||
updateEvent$: createFunctionalEffect.dispatching((api = inject(EventAdministrationService)) => | ||
onHttpAction(updateEventAction, selectEventsActionState('update')).pipe( | ||
switchMap(({ props }) => toHttpAction(updateEvent(api, props), updateEventAction, props)) | ||
) | ||
), | ||
}; | ||
|
||
async function updateEvent( | ||
api: EventAdministrationService, | ||
props: ReturnType<typeof updateEventAction>['props'] | ||
) { | ||
const response = await api.updateEvent({ | ||
eventId: props.eventId, | ||
body: { | ||
commit: props.commit ? props.commit : undefined, | ||
externalUri: props.externalUri ?? undefined, | ||
}, | ||
}); | ||
return response.ok | ||
? updateEventAction.success(props, undefined) | ||
: updateEventAction.error(props, response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...events/event-details/modify-external-uri-dialog/modify-external-uri-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<p-dialog | ||
[visible]="visible()" | ||
(visibleChange)="visible.set($event)" | ||
[modal]="true" | ||
[header]="translations.events_facebookLink()" | ||
> | ||
<p-inputGroup> | ||
<input | ||
#inputElement | ||
class="w-full max-w-[350px]" | ||
type="text" | ||
pInputText | ||
autocomplete="off" | ||
[ngModel]="externalUri()" | ||
(ngModelChange)="externalUri.set($event)" | ||
/> | ||
<button pButton icon="i-[mdi--backspace]" (click)="clearExternalUri()"></button> | ||
</p-inputGroup> | ||
|
||
<ng-template pTemplate="footer"> | ||
<p-button [text]="true" [label]="translations.shared_cancel()" (onClick)="visible.set(false)" /> | ||
<p-button [label]="translations.shared_save()" (onClick)="updateExternalUri()" /> | ||
</ng-template> | ||
</p-dialog> |
Oops, something went wrong.