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

receipts view #15

Merged
merged 37 commits into from
Jan 30, 2025
Merged

receipts view #15

merged 37 commits into from
Jan 30, 2025

Conversation

iisa
Copy link
Contributor

@iisa iisa commented Dec 13, 2024

Copy link

github-actions bot commented Dec 13, 2024

PR Preview Action v1.6.0
Preview removed because the pull request was closed.
2025-01-30 21:36 UTC

demo/index.html Show resolved Hide resolved

@customElement('iaux-monthly-giving-circle')
export class MonthlyGivingCircle extends LitElement {
@property({ type: String }) patronName: string = '';

@property({ type: Array }) receipts = [];

Choose a reason for hiding this comment

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

This can become

@property({ type: Array }) receipts: aReceipt[] = [];

so TS knows the type of data its working with and help the developer out during development.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for catch, will update. i will keep class and decorate this list

<th class="amount">Amount</th>
<th class="action">Action</th>
</tr>
${this.receipts.length
Copy link

@jbuckner jbuckner Jan 28, 2025

Choose a reason for hiding this comment

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

Minor, but to make this render() method a bit easier to read, I might split out the receipts list view, ie:

${this.receipts.length > 0 : this.receiptsListView : html`<p>No recent donations found</p>`}

private receiptsListView(): TemplateResult {
  return html`...`
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i did want to show the table row markup inside the context of the table draw function. there aren't any other views to switch from at this level so i think it makes sense to keep in-line. 👍

<button
?disabled=${this.isDisabled}
@click=${() => {
if (this.isDisabled) {

Choose a reason for hiding this comment

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

Do you need this disabled check? The ?disabled above should be making it unclickable, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the disabled check ensures the button does not re-fire.

export class IauxButton extends LitElement {
@property({ type: Boolean, reflect: true }) isDisabled = false;

@property({ type: Function }) clickHandler: Function | undefined;

Choose a reason for hiding this comment

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

Is type: Function valid? I get an error when I tried using that. I think it would be type: Object

Copy link

@jbuckner jbuckner Jan 28, 2025

Choose a reason for hiding this comment

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

To make this callback similar to an HTML button and help the developer know what the clickHandler looks like, I might make this type as (e: Event) => void, ie:

@property({ type: Object }) clickHandler?: (e: Event) => void;
...
<button @click=${(e: Event) => { this.clickHandler(e) }>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you know, that's from copilot 😅 i wanted to believe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks again for the feedback. i've got a good fix around this. we aren't bubbling up the click event, but i'll take a look at switching to passing event.


if (this.clickHandler) {
this?.clickHandler(this);
}

Choose a reason for hiding this comment

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

The this isn't optional so you shouldn't need the question mark.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clickhandler can be undefined

src/receipts.ts Outdated Show resolved Hide resolved

type receiptEmailStatus = {
id: string;
emailStatus: 'success' | 'fail' | 'pending' | '';

Choose a reason for hiding this comment

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

What does a status of '' mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

empty string. i wanted to use same type and default to falsey.

Copy link
Contributor Author

@iisa iisa left a comment

Choose a reason for hiding this comment

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

thanks so much for the care @jbuckner and @nsharma123 🙌

demo/index.html Show resolved Hide resolved
src/models/receipt.ts Show resolved Hide resolved
src/models/receipt.ts Show resolved Hide resolved
src/monthly-giving-circle.ts Show resolved Hide resolved
src/monthly-giving-circle.ts Show resolved Hide resolved

if (this.clickHandler) {
this?.clickHandler(this);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

clickhandler can be undefined

<button
?disabled=${this.isDisabled}
@click=${() => {
if (this.isDisabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the disabled check ensures the button does not re-fire.

src/receipts.ts Outdated Show resolved Hide resolved

type receiptEmailStatus = {
id: string;
emailStatus: 'success' | 'fail' | 'pending' | '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

empty string. i wanted to use same type and default to falsey.

<th class="amount">Amount</th>
<th class="action">Action</th>
</tr>
${this.receipts.length
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i did want to show the table row markup inside the context of the table draw function. there aren't any other views to switch from at this level so i think it makes sense to keep in-line. 👍

@iisa iisa merged commit dc2493e into main Jan 30, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants