Skip to content

Commit

Permalink
Merge pull request #35 from GenerateNU/feature/guides-md
Browse files Browse the repository at this point in the history
Feature/guides md
  • Loading branch information
DOOduneye authored Nov 10, 2023
2 parents 0aa2d72 + 8204b5f commit d2d381a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 27 deletions.
1 change: 0 additions & 1 deletion client-new/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default function App() {
<SafeAreaProvider>
<NativeBaseProvider theme={theme}>
<Router />
getUser()
</NativeBaseProvider>
</SafeAreaProvider>
</AuthProvider>
Expand Down
1 change: 1 addition & 0 deletions client-new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@react-native-community/slider": "^4.4.3",
"@react-navigation/native": "^6.1.8",
"@react-navigation/native-stack": "^6.9.14",
"@ronradtke/react-native-markdown-display": "^8.0.0",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@types/react-native": "^0.72.3",
Expand Down
38 changes: 22 additions & 16 deletions client-new/src/screens/app/GuideScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
import { ScrollView, Box, View, Text, Image } from "native-base";
import { useEffect, useState } from "react";
import { IGuide } from "../../interfaces/IGuide";
import { getMonth } from "../../utils/DateUtils";
import { moderateScale, verticalScale } from "../../utils/FontSizeUtils";
import {
widthPercentageToDP as wp,
heightPercentageToDP as hp,
} from "react-native-responsive-screen";
import { IGuide } from "../../interfaces/IGuide";
import { getMonth } from "../../utils/DateUtils";
import { moderateScale, verticalScale } from "../../utils/FontSizeUtils";
import { getGuide } from "../../services/GuideService";
import Markdown from "@ronradtke/react-native-markdown-display";

const MarkdownWrapper: React.FC<any> = ({ children }) => {
return (
<View px={wp("14%")} py={hp("5.5%")}>
<Text
fontFamily={"dmSans"}
fontWeight={"Regular"}
fontStyle={"normal"}
fontSize={moderateScale(12)}
color={"muteEggplant"}
>
<Markdown>{children}</Markdown>
</Text>
</View>
);
};

const GuideScreen = (props) => {
// props should include a guideName field.
Expand All @@ -17,13 +34,12 @@ const GuideScreen = (props) => {
const fetchGuide = async (guideName: string) => {
try {
const guide = await getGuide(guideName);
console.log("initialize guide success: ", guide);
setState(guide);
console.log("initialize guide success: ", guide);
} catch (err) {
console.log("failed to initialize guide: ", err);
}
};

fetchGuide(props.guideName);
}, [props.guideName]);

Expand Down Expand Up @@ -102,17 +118,7 @@ const GuideScreen = (props) => {
</View>
<View>
<Box roundedTop={wp("17%")} bg="#FAF8F2" w={wp("100%")}>
<Text
px={wp("14%")}
py={hp("5.5%")}
fontFamily={"dmSans"}
fontWeight={"Regular"}
fontStyle={"normal"}
fontSize={moderateScale(12)}
color={"muteEggplant"}
>
{state.full_text}
</Text>
<MarkdownWrapper>{state.full_text}</MarkdownWrapper>
</Box>
</View>
</View>
Expand Down
8 changes: 4 additions & 4 deletions server/src/controllers/guide.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (g *guideController) GetAllGuides(c echo.Context) error {
}

func (g *guideController) GetGuide(c echo.Context) error {
guideID := c.Param("g_name")
guide, err := g.guideService.GetGuide(guideID)
guideName := c.Param("g_name")
guide, err := g.guideService.GetGuide(guideName)

if err != nil {
return c.JSON(http.StatusNotFound, "Failed to fetch guide")
Expand Down Expand Up @@ -72,8 +72,8 @@ func (g *guideController) UpdateGuide(c echo.Context) error {
}

func (g *guideController) DeleteGuide(c echo.Context) error {
guideID := c.Param("g_name")
err := g.guideService.DeleteGuide(guideID)
guideName := c.Param("g_name")
err := g.guideService.DeleteGuide(guideName)
if err != nil {
return c.JSON(http.StatusNotFound, "Failed to delete guide")
}
Expand Down
29 changes: 28 additions & 1 deletion server/src/migrations/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,34 @@ INSERT INTO persona_tasks (persona_id, task_id) VALUES

-- Creating test guides
INSERT INTO guides (guide_name, title, sub_title, author, author_image_url, mins_read, date, full_text) VALUES
('Test Guide', 'Preserving Your Legacy:', 'Practical Steps for Funeral Affordability', 'Barack Obama', 'https://images1.penguinrandomhouse.com/author/22627', 5, '2023-10-17T23:05:10.4895-04:00', 'In the grand symphony of life, there are few certainties. Among them, one stands out starkly: our time here is finite. Yet, it''s the inevitability of our final encore that many of us prefer not to dwell on. This is entirely human, but it''s a fact that can''t be brushed aside indefinitely. End-of-life planning, while often seen as daunting, can be transformed into an empowering process—a legacy of care and love for our loved ones. The Price of Peace of Mind The mention of end-of-life planning often brings to mind wills, trusts, and the distribution of assets. While these are crucial aspects, there''s another vital component that deserves your attention: funeral planning. The cost of funeral services can be staggering, leaving families not just grieving but also grappling with unexpected financial burdens. In today''s world, the average cost of a funeral can easily reach several thousand dollars, making it one of life''s most substantial expenses. This reality prompts a critical question: How can we ensure a dignified farewell without burdening our loved ones? The Legacy Solution At Legacy, we understand the importance of preserving your legacy while also being mindful of the costs involved. Our mission is to empower you to take control of your end-of-life planning with joyous urgency. We believe that by confronting these realities and making thoughtful decisions today, you can grant your loved ones the gift of peace of mind tomorrow. Step 1: Explore Your Options The first step to achieving affordable funeral arrangements is to explore your options. Funeral costs can vary significantly based on factors such as location, type of service, and personal preferences. By researching local funeral homes and considering cremation or green burial alternatives, you can discover cost-effective choices without compromising on respect and reverence. Step 2: Pre-Planning with Legacy One of the most practical ways to ease the financial burden of your final arrangements is through pre-planning. Legacy offers an intuitive platform that enables you to pre-plan your funeral with ease. By making decisions in advance and securing funds for your funeral, you ensure that your wishes are honored while alleviating the financial stress on your loved ones. Step 3: Share Your Plan Transparency is key. Once you''ve made your end-of-life plans, communicate them with your family and loved ones. Sharing your wishes not only fosters understanding but also avoids any unexpected surprises when the time comes. It ensures that your choices are respected and followed, offering a sense of closure to your loved ones. Step 4: Seek Professional Guidance Navigating the intricacies of end-of-life planning can be overwhelming. That''s where our team at Legacy shines. We connect you with trusted professionals who can provide expert guidance on legal and financial matters. Our extensive network of attorneys, doulas, and funeral planning experts ensures that you have the support you need. Step 5: Embrace Peace of Mind With your end-of-life plans in place, you can embrace the present with newfound peace of mind. Legacy''s platform streamlines the process, making it accessible, affordable, and personal. By preserving your legacy today, you create a lasting memory of love, thoughtfulness, and consideration for those who matter most. In Conclusion Preserving your legacy is a journey of love and responsibility. It''s about ensuring that your final chapter is both a celebration of life and a testament to your care for those who will remember you. Legacy is your partner in this journey, offering expertise, affordability, and a deep commitment to making the end-of-life planning process as smooth as possible. As you reflect on your life''s journey, consider the importance of end-of-life planning. Embrace the joyful urgency of today, and gift your loved ones the solace of knowing your final wishes are honored.');
('Test Guide', 'Preserving Your Legacy:', 'Practical Steps for Funeral Affordability', 'Barack Obama', 'https://images1.penguinrandomhouse.com/author/22627', 5, '2023-10-17T23:05:10.4895-04:00',
'In the grand symphony of life, there are few certainties. Among them, one stands out starkly: our time here is finite. Yet, it''s the inevitability of our final encore that many of us prefer not to dwell on. This is entirely human, but it''s a fact that can''t be brushed aside indefinitely. End-of-life planning, while often seen as daunting, can be transformed into an empowering process—a legacy of care and love for our loved ones.
**The Price of Peace of Mind**
The mention of end-of-life planning often brings to mind wills, trusts, and the distribution of assets. While these are crucial aspects, there''s another vital component that deserves your attention: funeral planning. The cost of funeral services can be staggering, leaving families not just grieving but also grappling with unexpected financial burdens.
In today''s world, the average cost of a funeral can easily reach several thousand dollars, making it one of life''s most substantial expenses. This reality prompts a critical question: How can we ensure a dignified farewell without burdening our loved ones?
The Legacy Solution
At Legacy, we understand the importance of preserving your legacy while also being mindful of the costs involved. Our mission is to empower you to take control of your end-of-life planning with joyous urgency. We believe that by confronting these realities and making thoughtful decisions today, you can grant your loved ones the gift of peace of mind tomorrow.
Step 1: Explore Your Options
The first step to achieving affordable funeral arrangements is to explore your options. Funeral costs can vary significantly based on factors such as location, type of service, and personal preferences. By researching local funeral homes and considering cremation or green burial alternatives, you can discover cost-effective choices without compromising on respect and reverence.
Step 2: Pre-Planning with Legacy
One of the most practical ways to ease the financial burden of your final arrangements is through pre-planning. Legacy offers an intuitive platform that enables you to pre-plan your funeral with ease. By making decisions in advance and securing funds for your funeral, you ensure that your wishes are honored while alleviating the financial stress on your loved ones.
Step 3: Share Your Plan
Transparency is key. Once you''ve made your end-of-life plans, communicate them with your family and loved ones. Sharing your wishes not only fosters understanding but also avoids any unexpected surprises when the time comes. It ensures that your choices are respected and followed, offering a sense of closure to your loved ones.
Step 4: Seek Professional Guidance
Navigating the intricacies of end-of-life planning can be overwhelming. That''s where our team at Legacy shines. We connect you with trusted professionals who can provide expert guidance on legal and financial matters. Our extensive network of attorneys, doulas, and funeral planning experts ensures that you have the support you need.
Step 5: Embrace Peace of Mind
With your end-of-life plans in place, you can embrace the present with newfound peace of mind. Legacy''s platform streamlines the process, making it accessible, affordable, and personal. By preserving your legacy today, you create a lasting memory of love, thoughtfulness, and consideration for those who matter most.
In Conclusion
Preserving your legacy is a journey of love and responsibility. It''s about ensuring that your final chapter is both a celebration of life and a testament to your care for those who will remember you. Legacy is your partner in this journey, offering expertise, affordability, and a deep commitment to making the end-of-life planning process as smooth as possible.
As you reflect on your life''s journey, consider the importance of end-of-life planning. Embrace the joyful urgency of today, and gift your loved ones the solace of knowing your final wishes are honored.');

-- Creating test files
INSERT INTO files (file_name, object_key, user_id) VALUES
Expand Down
10 changes: 5 additions & 5 deletions server/src/services/guide.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type GuideServiceInterface interface {
GetAllGuides() ([]models.Guide, error)
GetGuide(id string) (models.Guide, error)
GetGuide(name string) (models.Guide, error)

CreateGuide(guide models.Guide) (models.Guide, error)
UpdateGuide(id string, guide models.Guide) (models.Guide, error)
Expand All @@ -30,10 +30,10 @@ func (g *GuideService) GetAllGuides() ([]models.Guide, error) {
return guide, nil
}

func (g *GuideService) GetGuide(id string) (models.Guide, error) {
func (g *GuideService) GetGuide(name string) (models.Guide, error) {
var guide models.Guide

if err := g.DB.First(&guide, id).Error; err != nil {
if err := g.DB.Where("guide_name = ?", name).First(&guide).Error; err != nil {
return models.Guide{}, err
}

Expand Down Expand Up @@ -64,10 +64,10 @@ func (g *GuideService) UpdateGuide(id string, guide models.Guide) (models.Guide,
return existingGuide, nil
}

func (g *GuideService) DeleteGuide(id string) error {
func (g *GuideService) DeleteGuide(name string) error {
var guide models.Guide

if err := g.DB.First(&guide, id).Error; err != nil {
if err := g.DB.Where("guide_name = ?", name).First(&guide).Error; err != nil {
return err
}

Expand Down

0 comments on commit d2d381a

Please sign in to comment.