Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 19 additions & 0 deletions app/components/public/add-to-calender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Component from '@glimmer/component';
import moment from 'moment';

export default class AddToCalender extends Component {
params = this.args.event;

get timezone() {
return `GMT${moment.tz("Asia/Kolkata").format('Z')}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project is not just for India

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my mistake

}

get calender() {
const startparams = this.params.startsAt;
const endparams = this.params.endsAt;
const starttime = moment(startparams).tz(this.params.timezone).utc().format('YYYYMMDD[T]HHmmSS[Z]');
const endtime = moment(endparams).tz(this.params.timezone).utc().format('YYYYMMDD[T]HHmmSS[Z]');
return `https://calendar.google.com/calendar/u/0/r/eventedit?dates=${starttime}/${endtime}&text=${this.params.name}&location=${this.args.eventlocation}&sf=true`;
}

}
9 changes: 9 additions & 0 deletions app/helpers/calender-date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Helper from '@ember/component/helper';
import moment from 'moment';

export function calenderDate(params) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of this helper. Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohk

const timezone = params[1] ? params[1] : moment.tz.guess();
return `${moment(params[0]).tz(timezone).format('dddd, MMMM DD, YYYY h:mm A')}`;
}

export default Helper.helper(calenderDate);
6 changes: 6 additions & 0 deletions app/templates/components/public/add-to-calender.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="ui list basic segment">
<div class="content">
<li>{{calender-date this.params.startsAt}} To {{calender-date this.params.endsAt}} {{this.timezone}}</li>
<i class="calendar alternate outline icon"></i><a href={{this.calender}}>Add To Calender</a>
</div>
</div>
3 changes: 2 additions & 1 deletion app/templates/public.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
{{/each}}
</div>
{{/if}}
<Public::SocialLinks @externalUrl={{this.model.externalEventUrl}} @socialLinks={{this.model.socialLinks}} />
<Public::AddToCalender @event={{this.model}} @eventlocation={{this.headerLocation}}/>
<Public::SocialLinks @externalUrl={{this.model.externalEventUrl}} @socialLinks={{this.model.socialLinks}}/>
{{/if}}
</div>
</div>
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/components/public/add-to-calender-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | public/add-to-calender', function(hooks) {
setupRenderingTest(hooks);

test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`{{public/add-to-calender}}`);

assert.equal(this.element.textContent.trim(), '');

// Template block usage:
await render(hbs`
{{#public/add-to-calender}}
template block text
{{/public/add-to-calender}}
`);

assert.equal(this.element.textContent.trim(), 'template block text');
});
});
17 changes: 17 additions & 0 deletions tests/integration/helpers/calender-date-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Helper | calender-date', function(hooks) {
setupRenderingTest(hooks);

// Replace this with your real tests.
test('it renders', async function(assert) {
this.set('inputValue', '1234');

await render(hbs`{{calender-date inputValue}}`);

assert.equal(this.element.textContent.trim(), '1234');
});
});