-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
714 additions
and
11 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,99 @@ | ||
// care_instructions.rs | ||
// Ojos Project | ||
// | ||
// Extra care instructions provided by the caregivers for the nurses. | ||
use crate::structs::CareInstruction; | ||
use chrono::Local; | ||
use rusqlite::{named_params, Connection}; | ||
use tauri::{AppHandle, Manager}; | ||
use uuid::Uuid; | ||
|
||
pub fn add_care_instruction( | ||
app: &AppHandle, | ||
title: String, | ||
content: String, | ||
frequency: Option<String>, | ||
added_by: String, | ||
) -> CareInstruction { | ||
let app_data_dir = app.path().app_data_dir().unwrap(); | ||
let conn = Connection::open(app_data_dir.join("iris.db")).unwrap(); | ||
let ts = Local::now().timestamp(); | ||
let id = Uuid::new_v4().to_string(); | ||
|
||
let ci = CareInstruction { | ||
id, | ||
title, | ||
content, | ||
frequency, | ||
added_by, | ||
last_updated: ts, | ||
}; | ||
|
||
conn.execute("INSERT INTO care_instruction(id, title, content, frequency, added_by, last_updated) VALUES (?1, ?2, ?3, ?4, ?5, ?6)", (&ci.id, &ci.title, &ci.content, &ci.frequency, &ci.added_by, &ci.last_updated)).unwrap(); | ||
ci | ||
} | ||
|
||
pub fn update_care_instructions( | ||
app: &AppHandle, | ||
id: String, | ||
title: String, | ||
content: String, | ||
frequency: Option<String>, | ||
added_by: String, | ||
) -> CareInstruction { | ||
let app_data_dir = app.path().app_data_dir().unwrap(); | ||
let conn = Connection::open(app_data_dir.join("iris.db")).unwrap(); | ||
let ts = Local::now().timestamp(); | ||
|
||
let ci = CareInstruction { | ||
id, | ||
title, | ||
content, | ||
frequency, | ||
added_by, | ||
last_updated: ts, | ||
}; | ||
|
||
conn.execute( | ||
"UPDATE care_instruction SET title=:title, content=:content, frequency=:frequency, added_by=:added_by, last_updated=:last_updated WHERE id=:id", | ||
named_params! { | ||
":id": &ci.id, | ||
":title": &ci.title, | ||
":content": &ci.content, | ||
":frequency": &ci.frequency, | ||
":added_by": &ci.added_by, | ||
":last_updated": &ci.last_updated | ||
}, | ||
) | ||
.unwrap(); | ||
|
||
ci | ||
} | ||
|
||
pub fn get_all_care_instructions(app: &AppHandle) -> Vec<CareInstruction> { | ||
let app_data_dir = app.path().app_data_dir().unwrap(); | ||
let conn = Connection::open(app_data_dir.join("iris.db")).unwrap(); | ||
|
||
let mut stmt = conn | ||
.prepare("SELECT * FROM care_instruction ORDER BY last_updated DESC") | ||
.unwrap(); | ||
let matched_ci = stmt | ||
.query_map([], |row| { | ||
Ok(CareInstruction { | ||
id: row.get(0)?, | ||
title: row.get(1)?, | ||
content: row.get(2)?, | ||
frequency: row.get(3)?, | ||
added_by: row.get(4)?, | ||
last_updated: row.get(5)?, | ||
}) | ||
}) | ||
.unwrap(); | ||
|
||
let mut vec_to_return: Vec<CareInstruction> = vec![]; | ||
for ci in matched_ci { | ||
vec_to_return.push(ci.unwrap()); | ||
} | ||
|
||
vec_to_return | ||
} |
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
18 changes: 18 additions & 0 deletions
18
src/app/care_instructions/components/CareInstructionButton.module.css
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,18 @@ | ||
/* | ||
CareInstructionButton.module.css | ||
Ojos Project | ||
*/ | ||
.single_care_instruction { | ||
width: 65dvw; | ||
margin: 20px 0; | ||
overflow-wrap: anywhere; | ||
} | ||
|
||
.single_care_instruction:hover { | ||
cursor: pointer; | ||
} | ||
|
||
.tap_message { | ||
font-size: 14px; | ||
color: grey; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/app/care_instructions/components/CareInstructionButton.tsx
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,26 @@ | ||
// CareInstructionButton.tsx | ||
// Ojos Project | ||
import { CareInstruction } from "@/types"; | ||
import classes from "./CareInstructionButton.module.css"; | ||
import Link from "next/link"; | ||
|
||
export default function CareInstructionButton(props: { | ||
instruction: CareInstruction; | ||
}) { | ||
return ( | ||
<Link | ||
style={{ color: "black", textDecoration: "none" }} | ||
href={{ | ||
pathname: "./care_instructions/view/", | ||
query: { id: props.instruction.id }, | ||
}} | ||
> | ||
<div className={classes.single_care_instruction}> | ||
<h3>{props.instruction.title}</h3> | ||
<p>{props.instruction.content}</p> | ||
|
||
<p className={classes.tap_message}>Tap for more...</p> | ||
</div> | ||
</Link> | ||
); | ||
} |
Oops, something went wrong.