NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

// Inside Home.tsx
import React, { useState } from "react";
import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonNote } from "@ionic/react";
import MessageListItem from "../components/MessageListItem";
import { Call, getCalls, deleteCalls } from "../data/calls";

const Home: React.FC = () => {
const [calls, setCalls] = useState<Call[]>([]);

useIonViewWillEnter(() => {
setCalls(getCalls());
});

const handleDelete = (id: string) => {
deleteCalls(id);
setCalls(getCalls()); // Refresh the list after deletion
};

return (
<IonPage id="home-page">
<IonHeader>
<IonToolbar>
<IonTitle>Recent Calls</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent>
<div className="message">
{calls.length > 0 ? (
<IonList>
{calls.map((call) => (
<MessageListItem key={call.id} call={call} onDelete={handleDelete} />
))}
</IonList>
) : (
<IonNote>Call Log Is Empty</IonNote>
)}
</div>
</IonContent>
</IonPage>
);
};

export default Home;
--------------------------------------

// Inside calls.ts
export interface Call {
name: string;
mobile: string;
time: string;
place: string;
region: string;
missed: boolean;
id: string;
}

// Sample call log data array
let messages: Call[] = [
{
id: "1",
name: "Name 1",
mobile: "+91 987654321",
place: "place one",
region: "region one",
time: "1:30PM",
missed: false,
},
{
id: "2",
name: "Name 2",
mobile: "+91 987654321",
place: "place one",
region: "region one",
time: "11:30PM",
missed: true,
},
// Add more call log entries as needed
{
id: "3",
name: "",
mobile: "+91 987654321",
place: "place one",
region: "region one",
time: "10:30AM",
missed: false,
},
{
id: "4",
name: "",
mobile: "+91 448654321",
place: "place one",
region: "region one",
time: "12:30PM",
missed: true,
},
// Continue with other predefined call logs...
];

// Function to get all call log entries
export const getCalls = (): Call[] => {
return messages;
};

// Function to delete a specific call log entry by id
export const deleteCalls = (id: string): void => {
messages = messages.filter(message => message.id !== id);
};


-----------------
// Inside MessageListItem.tsx
import React from "react";
import {
IonItem,
IonItemOption,
IonItemOptions,
IonItemSliding,
IonLabel,
IonIcon,
} from "@ionic/react";
import { call as callIcon } from "ionicons/icons";
import { Call } from "../data/calls";

interface CallListItemProps {
call: Call;
onDelete: (id: string) => void;
}

const MessageListItem: React.FC<CallListItemProps> = ({ call, onDelete }) => {
return (
<IonItemSliding>
<IonItem>
<IonLabel className="ion-text-wrap">
{call.missed && <IonIcon icon={callIcon} color="danger" />}
<h2>{call.name || call.mobile}</h2>
<p>{`${call.place}, ${call.region}, ${call.time}`}</p>
</IonLabel>
</IonItem>
<IonItemOptions side="end">
<IonItemOption color="danger" onClick={() => onDelete(call.id)}>
Delete
</IonItemOption>
</IonItemOptions>
</IonItemSliding>
);
};

export default MessageListItem;

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.