Merge branch 'main' into categories

This commit is contained in:
mantikoros 2022-05-04 10:45:39 -04:00
commit b080e7187e
19 changed files with 405 additions and 228 deletions

View File

@ -172,7 +172,7 @@ export function calculateCpmmSale(
shares: number, shares: number,
outcome: string outcome: string
) { ) {
if (shares < 0) { if (Math.round(shares) < 0) {
throw new Error('Cannot sell non-positive shares') throw new Error('Cannot sell non-positive shares')
} }

View File

@ -19,8 +19,7 @@ export const charities: Charity[] = [
website: 'https://www.1daysooner.org/', website: 'https://www.1daysooner.org/',
preview: preview:
'Accelerating the development of each vaccine by even a couple of days via COVID-19 human challenge trials could save thousands of lives.', 'Accelerating the development of each vaccine by even a couple of days via COVID-19 human challenge trials could save thousands of lives.',
photo: photo: 'https://i.imgur.com/bUDdzUE.png',
'https://images.squarespace-cdn.com/content/v1/5f5f8496d1d7713486b6075a/666cbb5a-5335-4323-b9ea-b764edc826e1/OFFICIAL+1Day+Sooner+Logo.png',
description: `1Day Sooner is a non-profit that advocates on behalf of COVID-19 challenge trial volunteers. description: `1Day Sooner is a non-profit that advocates on behalf of COVID-19 challenge trial volunteers.
After a vaccine candidate is created in a lab, it is developed through a combination of pre-clinical evaluation and three phases of clinical trials that test its safety and efficacy. In traditional Phase III trials, participants receive the vaccine candidate or a placebo/active comparator, and efficacy is judged by comparing the prevalence of infection in the vaccine group and the placebo/comparator group, to test the hypothesis that significantly fewer participants in the vaccine group get infected. In these traditional trials, after receiving the treatment, participants return to their homes and their normal daily lives so as to test the treatment under real world conditions. Since only a small proportion of these participants may encounter the disease, it may take a large number of participants and a good deal of time for these trials to reveal differences between the vaccine and placebo groups. After a vaccine candidate is created in a lab, it is developed through a combination of pre-clinical evaluation and three phases of clinical trials that test its safety and efficacy. In traditional Phase III trials, participants receive the vaccine candidate or a placebo/active comparator, and efficacy is judged by comparing the prevalence of infection in the vaccine group and the placebo/comparator group, to test the hypothesis that significantly fewer participants in the vaccine group get infected. In these traditional trials, after receiving the treatment, participants return to their homes and their normal daily lives so as to test the treatment under real world conditions. Since only a small proportion of these participants may encounter the disease, it may take a large number of participants and a good deal of time for these trials to reveal differences between the vaccine and placebo groups.
@ -35,8 +34,7 @@ export const charities: Charity[] = [
website: 'https://quantifieduncertainty.org/', website: 'https://quantifieduncertainty.org/',
preview: preview:
'The Quantified Uncertainty Research Institute advances forecasting and epistemics to improve the long-term future of humanity.', 'The Quantified Uncertainty Research Institute advances forecasting and epistemics to improve the long-term future of humanity.',
photo: photo: 'https://i.imgur.com/ZsSXPjH.png',
'https://quantifieduncertainty.org/_next/image?url=https%3A%2F%2Fsuper-static-assets.s3.amazonaws.com%2F09bb1362-5e3f-4724-8ffd-f3235f67356f%2Fimages%2F6151ac3e-aed7-44c7-9827-399fe6e9222b.png&w=1920&q=80',
description: `QURI researches systematic practices to specify and estimate the most important parameters for the most important or scalable decisions. Research areas include forecasting, epistemics, evaluations, ontology, and estimation. description: `QURI researches systematic practices to specify and estimate the most important parameters for the most important or scalable decisions. Research areas include forecasting, epistemics, evaluations, ontology, and estimation.
We emphasize technological solutions that can heavily scale in the next 5 to 30 years. We emphasize technological solutions that can heavily scale in the next 5 to 30 years.
@ -47,7 +45,7 @@ export const charities: Charity[] = [
{ {
name: 'Long-Term Future Fund', name: 'Long-Term Future Fund',
website: 'https://funds.effectivealtruism.org/funds/far-future', website: 'https://funds.effectivealtruism.org/funds/far-future',
photo: 'https://app.effectivealtruism.org/logo-funds.svg', photo: 'https://i.imgur.com/C2qka9g.png',
preview: preview:
'Positively influence the long-term trajectory of civilization by making grants that address global catastrophic risks.', 'Positively influence the long-term trajectory of civilization by making grants that address global catastrophic risks.',
description: `The Fund has a broad remit to make grants that promote, implement and advocate for longtermist ideas. Many of our grants aim to address potential risks from advanced artificial intelligence and to build infrastructure and advocate for longtermist projects. However, we welcome applications related to long-term institutional reform or other global catastrophic risks (e.g., pandemics or nuclear conflict). description: `The Fund has a broad remit to make grants that promote, implement and advocate for longtermist ideas. Many of our grants aim to address potential risks from advanced artificial intelligence and to build infrastructure and advocate for longtermist projects. However, we welcome applications related to long-term institutional reform or other global catastrophic risks (e.g., pandemics or nuclear conflict).
@ -61,7 +59,7 @@ export const charities: Charity[] = [
{ {
name: 'GiveWell Maximum Impact Fund', name: 'GiveWell Maximum Impact Fund',
website: 'https://www.givewell.org/maximum-impact-fund', website: 'https://www.givewell.org/maximum-impact-fund',
photo: 'https://www.givewell.org/sites/all/themes/gw_basic/logo.png', photo: 'https://i.imgur.com/xikuDMZ.png',
preview: preview:
'We search for the charities that save or improve lives the most per dollar.', 'We search for the charities that save or improve lives the most per dollar.',
description: ` description: `
@ -98,8 +96,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Give Directly', name: 'Give Directly',
website: 'https://www.givedirectly.org/', website: 'https://www.givedirectly.org/',
ein: '27-1661997', ein: '27-1661997',
photo: photo: 'https://i.imgur.com/lrdxSyd.jpg',
'https://www.givewell.org/sites/default/files/charity_logos/GiveDirectly.jpg',
preview: 'Send money directly to people living in poverty.', preview: 'Send money directly to people living in poverty.',
description: description:
'GiveDirectly is a nonprofit that lets donors like you send money directly to the worlds poorest households. We believe people living in poverty deserve the dignity to choose for themselves how best to improve their lives — cash enables that choice. Since 2009, weve delivered $500M+ in cash directly into the hands of over 1 million families living in poverty. We currently have operations in Kenya, Rwanda, Liberia, Malawi, Morocco, Mozambique, DRC, Uganda, and the United States.', 'GiveDirectly is a nonprofit that lets donors like you send money directly to the worlds poorest households. We believe people living in poverty deserve the dignity to choose for themselves how best to improve their lives — cash enables that choice. Since 2009, weve delivered $500M+ in cash directly into the hands of over 1 million families living in poverty. We currently have operations in Kenya, Rwanda, Liberia, Malawi, Morocco, Mozambique, DRC, Uganda, and the United States.',
@ -108,8 +105,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Hellen Keller International', name: 'Hellen Keller International',
website: 'https://www.hki.org/', website: 'https://www.hki.org/',
ein: '13-5562162', ein: '13-5562162',
photo: photo: 'https://i.imgur.com/Dl97Abk.jpg',
'https://www.ntd-ngonetwork.org/sites/nnn/files/content/organisation/logos/2020-01-28/v2_HKLogo_Primary_RGB.jpg',
preview: preview:
'We envision a world where no one is deprived of the opportunity to live a healthy life and reach their true potential.', 'We envision a world where no one is deprived of the opportunity to live a healthy life and reach their true potential.',
description: description:
@ -119,8 +115,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Against Malaria Foundation', name: 'Against Malaria Foundation',
website: 'https://www.againstmalaria.com/', website: 'https://www.againstmalaria.com/',
ein: '20-3069841', ein: '20-3069841',
photo: photo: 'https://i.imgur.com/F3JoZi9.png',
'https://media-exp1.licdn.com/dms/image/C4D0BAQFvdcum9KBNfg/company-logo_200_200/0?e=2159024400&v=beta&t=hxjJCKQkMp2irTOcuJEceW7x4l3c4PD7gYCQ6ulgYlg',
preview: 'We help protect people from malaria.', preview: 'We help protect people from malaria.',
description: description:
'AMF (againstmalaria.com) provides funding for long-lasting insecticide-treated net (LLIN) distributions (for protection against malaria) in developing countries. There is strong evidence that distributing LLINs reduces child mortality and malaria cases. AMF conducts post-distribution surveys of completed distributions to determine whether LLINs have reached their intended destinations and how long they remain in good condition.', 'AMF (againstmalaria.com) provides funding for long-lasting insecticide-treated net (LLIN) distributions (for protection against malaria) in developing countries. There is strong evidence that distributing LLINs reduces child mortality and malaria cases. AMF conducts post-distribution surveys of completed distributions to determine whether LLINs have reached their intended destinations and how long they remain in good condition.',
@ -128,8 +123,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
{ {
name: 'Rethink Charity', name: 'Rethink Charity',
website: 'https://rethink.charity/', website: 'https://rethink.charity/',
photo: photo: 'https://i.imgur.com/Go7N7As.png',
'https://process.filestackapi.com/resize=width:600,height:315,fit:max/quality=value:90/jvYvq1JFQkOqo3J8hVcJ',
preview: preview:
'Providing vital support to high-impact charities and charitable projects.', 'Providing vital support to high-impact charities and charitable projects.',
description: `At Rethink Charity, were excited about improving the world by providing vital support to high-impact charities and charitable projects. We equip them with tools to boost their impact, through our projects that empower their donors with tax-efficient giving options and strategically coordinated matching opportunities. description: `At Rethink Charity, were excited about improving the world by providing vital support to high-impact charities and charitable projects. We equip them with tools to boost their impact, through our projects that empower their donors with tax-efficient giving options and strategically coordinated matching opportunities.
@ -143,8 +137,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Malaria Consortium', name: 'Malaria Consortium',
website: 'https://www.malariaconsortium.org/', website: 'https://www.malariaconsortium.org/',
ein: '98-0627052', ein: '98-0627052',
photo: photo: 'https://i.imgur.com/LGwy9d8.png ',
'https://www.malariaconsortium.org/website-2013/images_template/malaria_consortium_logo.png',
preview: preview:
'We specialise in the prevention, control and treatment of malaria and other communicable diseases.', 'We specialise in the prevention, control and treatment of malaria and other communicable diseases.',
description: description:
@ -153,7 +146,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
{ {
name: 'The Center for the Study of Partisanship and Ideology', name: 'The Center for the Study of Partisanship and Ideology',
website: 'https://cspicenter.org/', website: 'https://cspicenter.org/',
photo: 'https://cspicenter.org/wp-content/uploads/2020/02/CSPI.png', photo: 'https://i.imgur.com/O88tkOW.png',
preview: preview:
'Support and fund research on how ideology and government policy contribute to scientific, technological, and social progress.', 'Support and fund research on how ideology and government policy contribute to scientific, technological, and social progress.',
description: `Over the last few decades, scientific and technological progress have stagnated. Scientists conduct more research than ever before, but groundbreaking innovation is scarce. At the same time, identity politics and political polarization have reached new extremes, and social trends such as family stability and crime are worse than in previous decades and in some cases moving in the wrong direction. What explains these trends, and how can we reverse them? description: `Over the last few decades, scientific and technological progress have stagnated. Scientists conduct more research than ever before, but groundbreaking innovation is scarce. At the same time, identity politics and political polarization have reached new extremes, and social trends such as family stability and crime are worse than in previous decades and in some cases moving in the wrong direction. What explains these trends, and how can we reverse them?
@ -170,8 +163,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Faunalytics', name: 'Faunalytics',
website: 'https://faunalytics.org/', website: 'https://faunalytics.org/',
ein: '01-0686889', ein: '01-0686889',
photo: photo: 'https://i.imgur.com/3JXhuXl.jpg',
'https://animalcharityevaluators.org/wp-content/uploads/2016/08/logo-faunalytics2400x2400-200x200@2x.jpg',
preview: preview:
'Faunalytics conducts research and shares knowledge to help advocates help animals effectively.', 'Faunalytics conducts research and shares knowledge to help advocates help animals effectively.',
description: description:
@ -181,8 +173,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'The Humane League', name: 'The Humane League',
website: 'https://thehumaneleague.org/', website: 'https://thehumaneleague.org/',
ein: '04-3817491', ein: '04-3817491',
photo: photo: 'https://i.imgur.com/za9Rwon.jpg',
'https://animalcharityevaluators.org/wp-content/uploads/2019/03/thl-mended-heart-logo@2x-200x200@2x.jpg',
preview: preview:
'We exist to end the abuse of animals raised for food by influencing the policies of the worlds biggest companies, demanding legislation, and empowering others to take action and leave animals off their plates', 'We exist to end the abuse of animals raised for food by influencing the policies of the worlds biggest companies, demanding legislation, and empowering others to take action and leave animals off their plates',
description: description:
@ -192,8 +183,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Wild Animal Initiative', name: 'Wild Animal Initiative',
website: 'https://www.wildanimalinitiative.org/', website: 'https://www.wildanimalinitiative.org/',
ein: '82-2281466', ein: '82-2281466',
photo: photo: 'https://i.imgur.com/bOVUnDm.png',
'https://animalcharityevaluators.org/wp-content/uploads/2020/11/WAI-logo_square-gray-on-teal-1-630x630.png',
preview: 'We want to make life better for wild animals.', preview: 'We want to make life better for wild animals.',
description: description:
'Wild Animal Initiative (WAI) currently operates in the U.S., where they work to strengthen the animal advocacy movement through creating an academic field dedicated to wild animal welfare. They compile literature reviews, write theoretical and opinion articles, and publish research results on their website and/or in peer-reviewed journals. WAI focuses on identifying and sharing possible research avenues and connecting with more established fields. They also work with researchers from various academic and non-academic institutions to identify potential collaborators, and they recently launched a grant assistance program.', 'Wild Animal Initiative (WAI) currently operates in the U.S., where they work to strengthen the animal advocacy movement through creating an academic field dedicated to wild animal welfare. They compile literature reviews, write theoretical and opinion articles, and publish research results on their website and/or in peer-reviewed journals. WAI focuses on identifying and sharing possible research avenues and connecting with more established fields. They also work with researchers from various academic and non-academic institutions to identify potential collaborators, and they recently launched a grant assistance program.',
@ -202,8 +192,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'New Incentives', name: 'New Incentives',
website: 'https://www.newincentives.org/', website: 'https://www.newincentives.org/',
ein: '45-2368993', ein: '45-2368993',
photo: photo: 'https://i.imgur.com/bYl4tk3.png',
'https://uploads-ssl.webflow.com/5f7c51bf9fac9b5ed62aa37b/5f7c51bf9fac9b85c42aa3df_Group%20344%20(1).svg',
preview: 'Cash incentives to boost vaccination rates and save lives.', preview: 'Cash incentives to boost vaccination rates and save lives.',
description: description:
'New Incentives (newincentives.org) runs a conditional cash transfer (CCT) program in North West Nigeria which seeks to increase uptake of routine immunizations through cash transfers, raising public awareness of the benefits of vaccination and reducing the frequency of vaccine stockouts.', 'New Incentives (newincentives.org) runs a conditional cash transfer (CCT) program in North West Nigeria which seeks to increase uptake of routine immunizations through cash transfers, raising public awareness of the benefits of vaccination and reducing the frequency of vaccine stockouts.',
@ -212,8 +201,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'SCI foundation', name: 'SCI foundation',
website: 'https://schistosomiasiscontrolinitiative.org/', website: 'https://schistosomiasiscontrolinitiative.org/',
ein: '', ein: '',
photo: photo: 'https://i.imgur.com/sWD8zM5.png',
'https://images.easyfundraising.org.uk/cause/cropped/cause-logo-e99e0632a8a9572150fdcf3abf08ad45.png',
preview: preview:
'SCI works with governments in sub-Saharan Africa to create or scale up programs that treat schistosomiasis and soil-transmitted helminthiasis ("deworming").', 'SCI works with governments in sub-Saharan Africa to create or scale up programs that treat schistosomiasis and soil-transmitted helminthiasis ("deworming").',
description: description:
@ -223,8 +211,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Wikimedia Foundation', name: 'Wikimedia Foundation',
website: 'https://wikimediafoundation.org/', website: 'https://wikimediafoundation.org/',
ein: '20-0049703', ein: '20-0049703',
photo: photo: 'https://i.imgur.com/klEzUbR.png',
'https://2.bp.blogspot.com/-jVseU39DW0s/VjmXVMOEEEI/AAAAAAAACK8/dwUP6sLqy-Q/s1600/wikimedia.png',
preview: 'We help everyone share in the sum of all knowledge.', preview: 'We help everyone share in the sum of all knowledge.',
description: description:
'We are the people who keep knowledge free. There is an amazing community of people around the world that makes great projects like Wikipedia. We help them do that work. We take care of the technical infrastructure, the legal challenges, and the growing pains.', 'We are the people who keep knowledge free. There is an amazing community of people around the world that makes great projects like Wikipedia. We help them do that work. We take care of the technical infrastructure, the legal challenges, and the growing pains.',
@ -233,8 +220,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Rainforest Trust', name: 'Rainforest Trust',
website: 'https://www.rainforesttrust.org/', website: 'https://www.rainforesttrust.org/',
ein: '13-3500609', ein: '13-3500609',
photo: photo: 'https://i.imgur.com/6MzS530.png',
'https://ww1.prweb.com/prfiles/2019/05/29/16344590/Rrainforest%20Trust%20new%20logo%20tall-1%20copy.png',
preview: preview:
'Rainforest Trust saves endangered wildlife and protects our planet by creating rainforest reserves through partnerships, community engagement and donor support.', 'Rainforest Trust saves endangered wildlife and protects our planet by creating rainforest reserves through partnerships, community engagement and donor support.',
description: description:
@ -244,8 +230,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'The Nature Conservancy', name: 'The Nature Conservancy',
website: 'https://www.nature.org/en-us/', website: 'https://www.nature.org/en-us/',
ein: '53-0242652', ein: '53-0242652',
photo: photo: 'https://i.imgur.com/vjxkoGo.jpg',
'https://mma.prnewswire.com/media/1140905/The_Nature_Conservancy_Logo.jpg?p=facebook',
preview: 'A Future Where People and Nature Thrive', preview: 'A Future Where People and Nature Thrive',
description: description:
'The Nature Conservancy is a global environmental nonprofit working to create a world where people and nature can thrive. Founded in the U.S. through grassroots action in 1951, The Nature Conservancy has grown to become one of the most effective and wide-reaching environmental organizations in the world. Thanks to more than a million members and the dedicated efforts of our diverse staff and over 400 scientists, we impact conservation in 76 countries and territories: 37 by direct conservation impact and 39 through partners.', 'The Nature Conservancy is a global environmental nonprofit working to create a world where people and nature can thrive. Founded in the U.S. through grassroots action in 1951, The Nature Conservancy has grown to become one of the most effective and wide-reaching environmental organizations in the world. Thanks to more than a million members and the dedicated efforts of our diverse staff and over 400 scientists, we impact conservation in 76 countries and territories: 37 by direct conservation impact and 39 through partners.',
@ -254,7 +239,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Doctors Without Borders', name: 'Doctors Without Borders',
website: 'https://www.doctorswithoutborders.org/', website: 'https://www.doctorswithoutborders.org/',
ein: '13-3433452', ein: '13-3433452',
photo: 'https://www.doctorswithoutborders.org/themes/custom/msf/logo.svg', photo: 'https://i.imgur.com/xqhH9FE.png',
preview: preview:
'We provide independent, impartial medical humanitarian assistance to the people who need it most.', 'We provide independent, impartial medical humanitarian assistance to the people who need it most.',
description: description:
@ -264,8 +249,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'World Wildlife Fund', name: 'World Wildlife Fund',
website: 'https://www.worldwildlife.org/', website: 'https://www.worldwildlife.org/',
ein: '52-1693387', ein: '52-1693387',
photo: photo: 'https://i.imgur.com/hDADuqW.png',
'https://www.worldwildlife.org/assets/structure/unique/logo-c562409bb6158bf64e5f8b1be066dbd5983d75f5ce7c9935a5afffbcc03f8e5d.png',
preview: preview:
'WWF works to sustain the natural world for the benefit of people and wildlife, collaborating with partners from local to global levels in nearly 100 countries.', 'WWF works to sustain the natural world for the benefit of people and wildlife, collaborating with partners from local to global levels in nearly 100 countries.',
description: description:
@ -274,7 +258,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
{ {
name: 'UNICEF USA', name: 'UNICEF USA',
website: 'https://www.unicefusa.org/', website: 'https://www.unicefusa.org/',
photo: 'https://www.unicefusa.org/sites/default/files/UNICEFUSA_DIG_C.svg', photo: 'https://i.imgur.com/9cxuvZi.png',
ein: '13-1760110', ein: '13-1760110',
preview: preview:
"UNICEF USA helps save and protect the world's most vulnerable children.", "UNICEF USA helps save and protect the world's most vulnerable children.",
@ -285,8 +269,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Vitamin Angels', name: 'Vitamin Angels',
website: 'https://www.vitaminangels.org/', website: 'https://www.vitaminangels.org/',
ein: '77-0485881', ein: '77-0485881',
photo: photo: 'https://i.imgur.com/Mf35IOu.jpg',
'https://www.newhope.com/sites/newhope360.com/files/styles/article_featured_retina/public/vitamin-angels-logo.jpg?itok=pfNCPLE0',
preview: preview:
'By improving access to vital nutrition, everyone gets an equal chance to grow, thrive, and prosper.', 'By improving access to vital nutrition, everyone gets an equal chance to grow, thrive, and prosper.',
description: description:
@ -296,7 +279,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Free Software Foundation', name: 'Free Software Foundation',
website: 'https://www.fsf.org/', website: 'https://www.fsf.org/',
ein: '04-2888848', ein: '04-2888848',
photo: 'https://www.gnu.org/graphics/logo-fsf.org.png', photo: 'https://i.imgur.com/z87sFDE.png',
preview: preview:
'The Free Software Foundation (FSF) is a nonprofit with a worldwide mission to promote computer user freedom.', 'The Free Software Foundation (FSF) is a nonprofit with a worldwide mission to promote computer user freedom.',
description: description:
@ -306,8 +289,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Direct Relief', name: 'Direct Relief',
website: 'https://www.directrelief.org/', website: 'https://www.directrelief.org/',
ein: '95-1831116', ein: '95-1831116',
photo: photo: 'https://i.imgur.com/QS7kHAU.png',
'https://www.ngoadvisor.net/wp-content/uploads/2016/02/DirectRelief_Logo_RGB-2-1920x576.png',
preview: preview:
'Direct Relief is a humanitarian aid organization, active in all 50 states and more than 80 countries, with a mission to improve the health and lives of people affected by poverty or emergencies without regard to politics, religion, or ability to pay.', 'Direct Relief is a humanitarian aid organization, active in all 50 states and more than 80 countries, with a mission to improve the health and lives of people affected by poverty or emergencies without regard to politics, religion, or ability to pay.',
description: description:
@ -317,8 +299,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'World Resources Institute', name: 'World Resources Institute',
website: 'https://www.wri.org/', website: 'https://www.wri.org/',
ein: '52-1257057', ein: '52-1257057',
photo: photo: 'https://i.imgur.com/Bi6MgYI.png',
'https://www.americansecurityproject.org/wp-content/uploads/2016/11/WRI_logo_4c.png',
preview: preview:
'WRI is a global nonprofit organization that works with leaders in government, business and civil society to research, design, and carry out practical solutions that simultaneously improve peoples lives and ensure nature can thrive.', 'WRI is a global nonprofit organization that works with leaders in government, business and civil society to research, design, and carry out practical solutions that simultaneously improve peoples lives and ensure nature can thrive.',
description: description:
@ -328,8 +309,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'ProPublica', name: 'ProPublica',
website: 'https://www.propublica.org/', website: 'https://www.propublica.org/',
ein: '14-2007220', ein: '14-2007220',
photo: photo: 'https://i.imgur.com/R5Vt3Pb.png',
'https://seekvectorlogo.com/wp-content/uploads/2018/09/propublica-vector-logo.png',
preview: preview:
'The mission: to expose abuses of power and betrayals of the public trust by government, business, and other institutions, using the moral force of investigative journalism to spur reform through the sustained spotlighting of wrongdoing.', 'The mission: to expose abuses of power and betrayals of the public trust by government, business, and other institutions, using the moral force of investigative journalism to spur reform through the sustained spotlighting of wrongdoing.',
description: description:
@ -339,8 +319,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Dana-Farber Cancer Institute', name: 'Dana-Farber Cancer Institute',
website: 'https://www.dana-farber.org/', website: 'https://www.dana-farber.org/',
ein: '04-2263040', ein: '04-2263040',
photo: photo: 'https://i.imgur.com/SQNn97p.png',
'https://www.danafarbermasterclass.com/assets/images/DFCI-logo-lens-stacked.png',
preview: preview:
"For over 70 years, we've led the world by making life-changing breakthroughs in cancer research and patient care, providing the most advanced treatments available.", "For over 70 years, we've led the world by making life-changing breakthroughs in cancer research and patient care, providing the most advanced treatments available.",
description: description:
@ -350,8 +329,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'Save The Children', name: 'Save The Children',
website: 'https://www.savethechildren.org/', website: 'https://www.savethechildren.org/',
ein: '06-0726487', ein: '06-0726487',
photo: photo: 'https://i.imgur.com/GngYPBI.png',
'https://www.thisisclapham.co.uk/wp-content/uploads/2016/08/savethechildren.png',
preview: preview:
'Through the decades, Save the Children has continued to work to save childrens lives, and thats still what we do today.', 'Through the decades, Save the Children has continued to work to save childrens lives, and thats still what we do today.',
description: description:
@ -361,8 +339,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'World Central Kitchen Incorporated', name: 'World Central Kitchen Incorporated',
website: 'https://wck.org/', website: 'https://wck.org/',
ein: '27-3521132', ein: '27-3521132',
photo: photo: 'https://i.imgur.com/te93MaY.png',
'https://res.cloudinary.com/dktp1ybbx/image/upload/f_auto,fl_lossy,q_auto/v1560203222/organization/prod/924457/M0oxO9vaxO.png',
preview: preview:
'WCK is first to the frontlines, providing meals in response to humanitarian, climate, and community crises. We build resilient food systems with locally led solutions.', 'WCK is first to the frontlines, providing meals in response to humanitarian, climate, and community crises. We build resilient food systems with locally led solutions.',
description: description:
@ -372,8 +349,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
name: 'The Johns Hopkins Center for Health Security', name: 'The Johns Hopkins Center for Health Security',
website: 'https://www.centerforhealthsecurity.org/', website: 'https://www.centerforhealthsecurity.org/',
ein: '', ein: '',
photo: photo: 'https://i.imgur.com/gKZE2Xs.png',
'https://www.centerforhealthsecurity.org/sebin/d/d/CHS.logo.horizontal.blue.png',
preview: preview:
'Our mission: to protect peoples health from epidemics and disasters and ensure that communities are resilient to major challenges.', 'Our mission: to protect peoples health from epidemics and disasters and ensure that communities are resilient to major challenges.',
description: description:
@ -382,8 +358,7 @@ Future plans: We expect to focus on similar theoretical problems in alignment un
{ {
name: 'ALLFED', name: 'ALLFED',
website: 'https://allfed.info/', website: 'https://allfed.info/',
photo: photo: 'https://i.imgur.com/p235vwF.jpg',
'https://images1.the-dots.com/1860424/allfed-logo-1.png?p=projectImageFullJpg',
ein: '27-6601178', ein: '27-6601178',
preview: 'Feeding everyone no matter what.', preview: 'Feeding everyone no matter what.',
description: description:

View File

@ -4,6 +4,7 @@ export type Comment = {
id: string id: string
contractId: string contractId: string
betId?: string betId?: string
answerOutcome?: string
userId: string userId: string
text: string text: string

View File

@ -73,7 +73,6 @@ export const createContract = functions
) )
return { status: 'error', message: 'Invalid initial probability' } return { status: 'error', message: 'Invalid initial probability' }
const ante = FIXED_ANTE // data.ante
// uses utc time on server: // uses utc time on server:
const today = new Date().setHours(0, 0, 0, 0) const today = new Date().setHours(0, 0, 0, 0)
const userContractsCreatedTodaySnapshot = await firestore const userContractsCreatedTodaySnapshot = await firestore
@ -83,6 +82,8 @@ export const createContract = functions
.get() .get()
const isFree = userContractsCreatedTodaySnapshot.size === 0 const isFree = userContractsCreatedTodaySnapshot.size === 0
const ante = isFree ? 300 : FIXED_ANTE // data.ante
if ( if (
ante === undefined || ante === undefined ||
ante < MINIMUM_ANTE || ante < MINIMUM_ANTE ||

View File

@ -93,7 +93,8 @@ export function getHtml(parsedReq: ParsedRequest) {
creatorAvatarUrl, creatorAvatarUrl,
} = parsedReq } = parsedReq
const MAX_QUESTION_CHARS = 100 const MAX_QUESTION_CHARS = 100
const truncatedQuestion = question.length > MAX_QUESTION_CHARS const truncatedQuestion =
question.length > MAX_QUESTION_CHARS
? question.slice(0, MAX_QUESTION_CHARS) + '...' ? question.slice(0, MAX_QUESTION_CHARS) + '...'
: question : question
const hideAvatar = creatorAvatarUrl ? '' : 'hidden' const hideAvatar = creatorAvatarUrl ? '' : 'hidden'

View File

@ -8,6 +8,7 @@ import { Bet } from '../../common/bet'
import { Spacer } from './layout/spacer' import { Spacer } from './layout/spacer'
import { calculateCpmmSale } from '../../common/calculate-cpmm' import { calculateCpmmSale } from '../../common/calculate-cpmm'
import { Binary, CPMM, FullContract } from '../../common/contract' import { Binary, CPMM, FullContract } from '../../common/contract'
import { SiteLink } from './site-link'
export function AmountInput(props: { export function AmountInput(props: {
amount: number | undefined amount: number | undefined
@ -65,7 +66,16 @@ export function AmountInput(props: {
{error && ( {error && (
<div className="mb-2 mr-auto self-center whitespace-nowrap text-xs font-medium tracking-wide text-red-500"> <div className="mb-2 mr-auto self-center whitespace-nowrap text-xs font-medium tracking-wide text-red-500">
{error} {error === 'Insufficient balance' ? (
<>
Not enough funds.
<span className="ml-1 text-indigo-500">
<SiteLink href="/add-funds">Buy more?</SiteLink>
</span>
</>
) : (
error
)}
</div> </div>
)} )}

View File

@ -1,6 +1,7 @@
import { StarIcon } from '@heroicons/react/solid' import { StarIcon } from '@heroicons/react/solid'
import _ from 'lodash' import _ from 'lodash'
import Link from 'next/link' import Link from 'next/link'
import Image from 'next/image'
import { Charity } from '../../../common/charity' import { Charity } from '../../../common/charity'
import { useCharityTxns } from '../../hooks/use-charity-txns' import { useCharityTxns } from '../../hooks/use-charity-txns'
import { manaToUSD } from '../../pages/charity/[charitySlug]' import { manaToUSD } from '../../pages/charity/[charitySlug]'
@ -18,14 +19,15 @@ export function CharityCard(props: { charity: Charity }) {
<Row className="mt-6"> <Row className="mt-6">
{tags?.includes('Featured') && <FeaturedBadge />} {tags?.includes('Featured') && <FeaturedBadge />}
</Row> </Row>
<div className="px-8">
<figure className="h-32 px-4 pt-4"> <figure className="relative h-32">
{photo ? ( {photo ? (
<img className="h-full w-full object-contain" src={photo} alt="" /> <Image src={photo} alt="" layout="fill" objectFit="contain" />
) : ( ) : (
<div className="h-full w-full bg-gradient-to-r from-slate-300 to-indigo-200" /> <div className="h-full w-full bg-gradient-to-r from-slate-300 to-indigo-200" />
)} )}
</figure> </figure>
</div>
<div className="card-body"> <div className="card-body">
{/* <h3 className="card-title line-clamp-3">{name}</h3> */} {/* <h3 className="card-title line-clamp-3">{name}</h3> */}
<div className="line-clamp-4 text-sm">{preview}</div> <div className="line-clamp-4 text-sm">{preview}</div>

View File

@ -7,6 +7,7 @@ import { ContractActivity } from '../feed/contract-activity'
import { ContractBetsTable, MyBetsSummary } from '../bets-list' import { ContractBetsTable, MyBetsSummary } from '../bets-list'
import { Spacer } from '../layout/spacer' import { Spacer } from '../layout/spacer'
import { Tabs } from '../layout/tabs' import { Tabs } from '../layout/tabs'
import { Col } from '../layout/col'
export function ContractTabs(props: { export function ContractTabs(props: {
contract: Contract contract: Contract
@ -33,14 +34,34 @@ export function ContractTabs(props: {
) )
const commentActivity = ( const commentActivity = (
<>
<ContractActivity <ContractActivity
contract={contract} contract={contract}
bets={bets} bets={bets}
comments={comments} comments={comments}
user={user} user={user}
mode="comments" mode={
contract.outcomeType === 'FREE_RESPONSE'
? 'free-response-comment-answer-groups'
: 'comments'
}
betRowClassName="!mt-0 xl:hidden" betRowClassName="!mt-0 xl:hidden"
/> />
{contract.outcomeType === 'FREE_RESPONSE' && (
<Col className={'mt-8 flex w-full '}>
<div className={'text-md mt-8 mb-2 text-left'}>General Comments</div>
<div className={'mb-4 w-full border-b border-gray-200'} />
<ContractActivity
contract={contract}
bets={bets}
comments={comments}
user={user}
mode={'comments'}
betRowClassName="!mt-0 xl:hidden"
/>
</Col>
)}
</>
) )
const yourTrades = ( const yourTrades = (

View File

@ -33,6 +33,7 @@ export type CommentInputItem = BaseActivityItem & {
type: 'commentInput' type: 'commentInput'
betsByCurrentUser: Bet[] betsByCurrentUser: Bet[]
comments: Comment[] comments: Comment[]
answerOutcome?: string
} }
export type DescriptionItem = BaseActivityItem & { export type DescriptionItem = BaseActivityItem & {
@ -82,6 +83,7 @@ export type ResolveItem = BaseActivityItem & {
type: 'resolve' type: 'resolve'
} }
export const GENERAL_COMMENTS_OUTCOME_ID = 'General Comments'
const DAY_IN_MS = 24 * 60 * 60 * 1000 const DAY_IN_MS = 24 * 60 * 60 * 1000
const ABBREVIATED_NUM_COMMENTS_OR_BETS_TO_SHOW = 3 const ABBREVIATED_NUM_COMMENTS_OR_BETS_TO_SHOW = 3
@ -263,6 +265,68 @@ function getAnswerGroups(
return answerGroups return answerGroups
} }
function getAnswerAndCommentInputGroups(
contract: FullContract<DPM, FreeResponse>,
bets: Bet[],
comments: Comment[],
user: User | undefined | null
) {
let outcomes = _.uniq(bets.map((bet) => bet.outcome)).filter(
(outcome) => getOutcomeProbability(contract, outcome) > 0.0001
)
outcomes = _.sortBy(outcomes, (outcome) =>
getOutcomeProbability(contract, outcome)
)
function collateCommentsSectionForOutcome(outcome: string) {
const answerBets = bets.filter((bet) => bet.outcome === outcome)
const answerComments = comments.filter(
(comment) =>
comment.answerOutcome === outcome ||
answerBets.some((bet) => bet.id === comment.betId)
)
let items = []
items.push({
type: 'commentInput' as const,
id: 'commentInputFor' + outcome,
contract,
betsByCurrentUser: user
? bets.filter((bet) => bet.userId === user.id)
: [],
comments: comments,
answerOutcome: outcome,
})
items.push(
...getCommentsWithPositions(
answerBets,
answerComments,
contract
).reverse()
)
return items
}
const answerGroups = outcomes
.map((outcome) => {
const answer = contract.answers?.find(
(answer) => answer.id === outcome
) as Answer
const items = collateCommentsSectionForOutcome(outcome)
return {
id: outcome,
type: 'answergroup' as const,
contract,
answer,
items,
user,
}
})
.filter((group) => group.answer) as ActivityItem[]
return answerGroups
}
function groupBetsAndComments( function groupBetsAndComments(
bets: Bet[], bets: Bet[],
comments: Comment[], comments: Comment[],
@ -382,7 +446,7 @@ export function getAllContractActivityItems(
) )
) )
items.push({ items.push({
type: 'commentInput', type: 'commentInput' as const,
id: 'commentInput', id: 'commentInput',
contract, contract,
betsByCurrentUser: [], betsByCurrentUser: [],
@ -408,7 +472,7 @@ export function getAllContractActivityItems(
if (outcomeType === 'BINARY') { if (outcomeType === 'BINARY') {
items.push({ items.push({
type: 'commentInput', type: 'commentInput' as const,
id: 'commentInput', id: 'commentInput',
contract, contract,
betsByCurrentUser: [], betsByCurrentUser: [],
@ -479,7 +543,7 @@ export function getSpecificContractActivityItems(
comments: Comment[], comments: Comment[],
user: User | null | undefined, user: User | null | undefined,
options: { options: {
mode: 'comments' | 'bets' mode: 'comments' | 'bets' | 'free-response-comment-answer-groups'
} }
) { ) {
const { mode } = options const { mode } = options
@ -501,18 +565,39 @@ export function getSpecificContractActivityItems(
break break
case 'comments': case 'comments':
items.push(...getCommentsWithPositions(bets, comments, contract)) const nonFreeResponseComments = comments.filter(
(comment) => comment.answerOutcome === undefined
)
const nonFreeResponseBets =
contract.outcomeType === 'FREE_RESPONSE' ? [] : bets
items.push(
...getCommentsWithPositions(
nonFreeResponseBets,
nonFreeResponseComments,
contract
)
)
items.push({ items.push({
type: 'commentInput', type: 'commentInput',
id: 'commentInput', id: 'commentInput',
contract, contract,
betsByCurrentUser: user betsByCurrentUser: user
? bets.filter((bet) => bet.userId === user.id) ? nonFreeResponseBets.filter((bet) => bet.userId === user.id)
: [], : [],
comments: comments, comments: nonFreeResponseComments,
}) })
break break
case 'free-response-comment-answer-groups':
items.push(
...getAnswerAndCommentInputGroups(
contract as FullContract<DPM, FreeResponse>,
bets,
comments,
user
)
)
break
} }
return items.reverse() return items.reverse()

View File

@ -16,7 +16,13 @@ export function ContractActivity(props: {
bets: Bet[] bets: Bet[]
comments: Comment[] comments: Comment[]
user: User | null | undefined user: User | null | undefined
mode: 'only-recent' | 'abbreviated' | 'all' | 'comments' | 'bets' mode:
| 'only-recent'
| 'abbreviated'
| 'all'
| 'comments'
| 'bets'
| 'free-response-comment-answer-groups'
contractPath?: string contractPath?: string
className?: string className?: string
betRowClassName?: string betRowClassName?: string
@ -38,7 +44,9 @@ export function ContractActivity(props: {
? getRecentContractActivityItems(contract, bets, comments, user, { ? getRecentContractActivityItems(contract, bets, comments, user, {
contractPath, contractPath,
}) })
: mode === 'comments' || mode === 'bets' : mode === 'comments' ||
mode === 'bets' ||
mode === 'free-response-comment-answer-groups'
? getSpecificContractActivityItems(contract, bets, comments, user, { ? getSpecificContractActivityItems(contract, bets, comments, user, {
mode, mode,
}) })

View File

@ -37,7 +37,7 @@ import { fromNow } from '../../lib/util/time'
import BetRow from '../bet-row' import BetRow from '../bet-row'
import { Avatar } from '../avatar' import { Avatar } from '../avatar'
import { Answer } from '../../../common/answer' import { Answer } from '../../../common/answer'
import { ActivityItem } from './activity-items' import { ActivityItem, GENERAL_COMMENTS_OUTCOME_ID } from './activity-items'
import { import {
Binary, Binary,
CPMM, CPMM,
@ -222,52 +222,64 @@ export function CommentInput(props: {
contract: Contract contract: Contract
betsByCurrentUser: Bet[] betsByCurrentUser: Bet[]
comments: Comment[] comments: Comment[]
// Only for free response comment inputs
answerOutcome?: string
}) { }) {
const { contract, betsByCurrentUser, comments } = props const { contract, betsByCurrentUser, comments, answerOutcome } = props
const user = useUser() const user = useUser()
const [comment, setComment] = useState('') const [comment, setComment] = useState('')
const [focused, setFocused] = useState(false)
async function submitComment() {
if (!comment) return
if (!user) {
return await firebaseLogin()
}
await createComment(contract.id, comment, user)
setComment('')
}
// Should this be oldest bet or most recent bet? // Should this be oldest bet or most recent bet?
const mostRecentCommentableBet = betsByCurrentUser const mostRecentCommentableBet = betsByCurrentUser
.filter( .filter((bet) => {
(bet) => if (
canCommentOnBet(bet.userId, bet.createdTime, user) && canCommentOnBet(bet, user) &&
// The bet doesn't already have a comment
!comments.some((comment) => comment.betId == bet.id) !comments.some((comment) => comment.betId == bet.id)
) {
if (!answerOutcome) return true
// If we're in free response, don't allow commenting on ante bet
return (
bet.outcome !== GENERAL_COMMENTS_OUTCOME_ID &&
answerOutcome === bet.outcome
) )
}
return false
})
.sort((b1, b2) => b1.createdTime - b2.createdTime) .sort((b1, b2) => b1.createdTime - b2.createdTime)
.pop() .pop()
if (mostRecentCommentableBet) { const { id } = mostRecentCommentableBet || { id: undefined }
return (
<FeedBet async function submitComment(betId: string | undefined) {
contract={contract} if (!user) {
bet={mostRecentCommentableBet} return await firebaseLogin()
hideOutcome={false}
smallAvatar={false}
/>
)
} }
if (!comment) return
await createComment(contract.id, comment, user, betId, answerOutcome)
setComment('')
}
const { userPosition, userPositionMoney, yesFloorShares, noFloorShares } = const { userPosition, userPositionMoney, yesFloorShares, noFloorShares } =
getBettorsPosition(contract, Date.now(), betsByCurrentUser) getBettorsPosition(contract, Date.now(), betsByCurrentUser)
return ( return (
<> <>
<Row className={'flex w-full gap-2 pt-3'}> <Row className={'flex w-full gap-2'}>
<div> <div>
<Avatar avatarUrl={user?.avatarUrl} username={user?.username} /> <Avatar avatarUrl={user?.avatarUrl} username={user?.username} />
</div> </div>
<div className={'min-w-0 flex-1 py-1.5'}> <div className={'min-w-0 flex-1'}>
<div className="text-sm text-gray-500"> <div className="text-sm text-gray-500">
{user && userPosition > 0 && ( {mostRecentCommentableBet && (
<BetStatusText
contract={contract}
bet={mostRecentCommentableBet}
isSelf={true}
/>
)}
{!mostRecentCommentableBet && user && userPosition > 0 && (
<> <>
{'You have ' + userPositionMoney + ' '} {'You have ' + userPositionMoney + ' '}
<> <>
@ -280,30 +292,65 @@ export function CommentInput(props: {
</> </>
</> </>
)} )}
{(answerOutcome === undefined || focused) && (
<div className="mt-2"> <div className="mt-2">
<Textarea <Textarea
value={comment} value={comment}
onChange={(e) => setComment(e.target.value)} onChange={(e) => setComment(e.target.value)}
className="textarea textarea-bordered w-full resize-none" className="textarea textarea-bordered w-full resize-none"
placeholder="Add a comment..." placeholder="Add a comment..."
rows={3} autoFocus={focused}
rows={answerOutcome == undefined || focused ? 3 : 1}
onFocus={() => setFocused(true)}
onBlur={() => !comment && setFocused(false)}
maxLength={MAX_COMMENT_LENGTH} maxLength={MAX_COMMENT_LENGTH}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) { if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
submitComment() submitComment(id)
} }
}} }}
/> />
</div>
)}
</div>
{!user && (
<button <button
className={ className={
'btn btn-outline btn-sm text-transform: mt-1 capitalize' 'btn btn-outline btn-sm text-transform: mt-1 capitalize'
} }
onClick={submitComment} onClick={() => submitComment(id)}
> >
{user ? 'Comment' : 'Sign in to comment'} Sign in to Comment
</button> </button>
</div> )}
</div> {user && answerOutcome === undefined && (
<button
className={
'btn btn-outline btn-sm text-transform: mt-1 capitalize'
}
onClick={() => submitComment(id)}
>
Comment
</button>
)}
{user && answerOutcome !== undefined && (
<button
className={
focused
? 'btn btn-outline btn-sm text-transform: mt-1 capitalize'
: 'btn btn-ghost btn-sm text-transform: mt-1 capitalize'
}
onClick={() => {
if (!focused) setFocused(true)
else {
submitComment(id)
setFocused(false)
}
}}
>
{!focused ? 'Add Comment' : 'Comment'}
</button>
)}
</div> </div>
</Row> </Row>
</> </>
@ -372,24 +419,12 @@ export function FeedBet(props: {
bet: Bet bet: Bet
hideOutcome: boolean hideOutcome: boolean
smallAvatar: boolean smallAvatar: boolean
hideComment?: boolean
bettor?: User // If set: reveal bettor identity bettor?: User // If set: reveal bettor identity
}) { }) {
const { contract, bet, hideOutcome, smallAvatar, bettor, hideComment } = props const { contract, bet, hideOutcome, smallAvatar, bettor } = props
const { id, amount, outcome, createdTime, userId } = bet const { userId } = bet
const user = useUser() const user = useUser()
const isSelf = user?.id === userId const isSelf = user?.id === userId
const canComment = canCommentOnBet(userId, createdTime, user) && !hideComment
const [comment, setComment] = useState('')
async function submitComment() {
if (!user || !comment || !canComment) return
await createComment(contract.id, comment, user, id)
setComment('')
}
const bought = amount >= 0 ? 'bought' : 'sold'
const money = formatMoney(Math.abs(amount))
return ( return (
<> <>
@ -421,9 +456,36 @@ export function FeedBet(props: {
)} )}
</div> </div>
<div className={'min-w-0 flex-1 py-1.5'}> <div className={'min-w-0 flex-1 py-1.5'}>
<BetStatusText
bet={bet}
contract={contract}
isSelf={isSelf}
hideOutcome={hideOutcome}
bettor={bettor}
/>
</div>
</Row>
</>
)
}
function BetStatusText(props: {
contract: Contract
bet: Bet
isSelf: boolean
hideOutcome?: boolean
bettor?: User
}) {
const { bet, contract, hideOutcome, bettor, isSelf } = props
const { amount, outcome, createdTime } = bet
const bought = amount >= 0 ? 'bought' : 'sold'
const money = formatMoney(Math.abs(amount))
return (
<div className="text-sm text-gray-500"> <div className="text-sm text-gray-500">
<span>{isSelf ? 'You' : bettor ? bettor.name : 'A trader'}</span>{' '} <span>{isSelf ? 'You' : bettor ? bettor.name : 'A trader'}</span> {bought}{' '}
{bought} {money} {money}
{!hideOutcome && ( {!hideOutcome && (
<> <>
{' '} {' '}
@ -436,34 +498,7 @@ export function FeedBet(props: {
</> </>
)} )}
<RelativeTimestamp time={createdTime} /> <RelativeTimestamp time={createdTime} />
{(canComment || comment) && (
<div className="mt-2">
<Textarea
value={comment}
onChange={(e) => setComment(e.target.value)}
className="textarea textarea-bordered w-full resize-none"
placeholder="Add a comment..."
rows={3}
maxLength={MAX_COMMENT_LENGTH}
onKeyDown={(e) => {
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
submitComment()
}
}}
/>
<button
className="btn btn-outline btn-sm text-transform: mt-1 capitalize"
onClick={submitComment}
disabled={!canComment}
>
Comment
</button>
</div> </div>
)}
</div>
</div>
</Row>
</>
) )
} }
@ -573,14 +608,11 @@ export function FeedQuestion(props: {
) )
} }
function canCommentOnBet( function canCommentOnBet(bet: Bet, user?: User | null) {
userId: string, const { userId, createdTime, isRedemption } = bet
createdTime: number,
user?: User | null
) {
const isSelf = user?.id === userId const isSelf = user?.id === userId
// You can comment if your bet was posted in the last hour // You can comment if your bet was posted in the last hour
return isSelf && Date.now() - createdTime < 60 * 60 * 1000 return !isRedemption && isSelf && Date.now() - createdTime < 60 * 60 * 1000
} }
function FeedDescription(props: { contract: Contract }) { function FeedDescription(props: { contract: Contract }) {

View File

@ -32,7 +32,7 @@ export function Page(props: {
{children} {children}
{/* If right sidebar is hidden, place its content at the bottom of the page. */} {/* If right sidebar is hidden, place its content at the bottom of the page. */}
<div className="block xl:hidden">{rightSidebar}</div> <div className="mt-4 block xl:hidden">{rightSidebar}</div>
</main> </main>
<aside className="hidden xl:col-span-3 xl:block"> <aside className="hidden xl:col-span-3 xl:block">
<div className="sticky top-4 space-y-4">{rightSidebar}</div> <div className="sticky top-4 space-y-4">{rightSidebar}</div>

View File

@ -21,7 +21,8 @@ export async function createComment(
contractId: string, contractId: string,
text: string, text: string,
commenter: User, commenter: User,
betId?: string betId?: string,
answerOutcome?: string
) { ) {
const ref = betId const ref = betId
? doc(getCommentsCollection(contractId), betId) ? doc(getCommentsCollection(contractId), betId)
@ -39,6 +40,9 @@ export async function createComment(
if (betId) { if (betId) {
comment.betId = betId comment.betId = betId
} }
if (answerOutcome) {
comment.answerOutcome = answerOutcome
}
return await setDoc(ref, comment) return await setDoc(ref, comment)
} }

View File

@ -3,7 +3,7 @@ import _ from 'lodash'
import { Txn } from '../../../common/txn' import { Txn } from '../../../common/txn'
import { db } from './init' import { db } from './init'
import { listenForValues } from './utils' import { getValues, listenForValues } from './utils'
const txnCollection = collection(db, 'txns') const txnCollection = collection(db, 'txns')
@ -21,3 +21,9 @@ export function listenForCharityTxns(
) { ) {
return listenForValues<Txn>(getCharityQuery(charityId), setTxns) return listenForValues<Txn>(getCharityQuery(charityId), setTxns)
} }
const charitiesQuery = query(txnCollection, where('toType', '==', 'CHARITY'))
export function getAllCharityTxns() {
return getValues<Txn>(charitiesQuery)
}

View File

@ -8,7 +8,7 @@ module.exports = {
optimizeCss: true, optimizeCss: true,
}, },
images: { images: {
domains: ['lh3.googleusercontent.com'], domains: ['lh3.googleusercontent.com', 'i.imgur.com'],
}, },
async redirects() { async redirects() {
return [ return [

View File

@ -168,8 +168,7 @@ export function ContractPageContent(props: FirstArgument<typeof ContractPage>) {
comments={comments ?? []} comments={comments ?? []}
/> />
{outcomeType === 'FREE_RESPONSE' && {outcomeType === 'FREE_RESPONSE' && (
(!isResolved || resolution === 'MKT') && (
<> <>
<Spacer h={4} /> <Spacer h={4} />
<AnswersPanel <AnswersPanel
@ -179,7 +178,7 @@ export function ContractPageContent(props: FirstArgument<typeof ContractPage>) {
</> </>
)} )}
{contract.isResolved && ( {isResolved && (
<> <>
<div className="grid grid-cols-1 sm:grid-cols-2"> <div className="grid grid-cols-1 sm:grid-cols-2">
<ContractLeaderboard contract={contract} bets={bets} /> <ContractLeaderboard contract={contract} bets={bets} />

View File

@ -18,7 +18,7 @@ import { getDailyNewUsers } from '../lib/firebase/users'
export const getStaticProps = fromPropz(getStaticPropz) export const getStaticProps = fromPropz(getStaticPropz)
export async function getStaticPropz() { export async function getStaticPropz() {
const numberOfDays = 80 const numberOfDays = 90
const today = dayjs(dayjs().format('YYYY-MM-DD')) const today = dayjs(dayjs().format('YYYY-MM-DD'))
const startDate = today.subtract(numberOfDays, 'day') const startDate = today.subtract(numberOfDays, 'day')
@ -367,7 +367,7 @@ export function CustomAnalytics(props: {
<Title text="Ratio of Active Users" /> <Title text="Ratio of Active Users" />
<Tabs <Tabs
defaultIndex={0} defaultIndex={1}
tabs={[ tabs={[
{ {
title: 'Daily / Weekly', title: 'Daily / Weekly',

View File

@ -18,6 +18,7 @@ import { useCharityTxns } from '../../hooks/use-charity-txns'
import { useWindowSize } from '../../hooks/use-window-size' import { useWindowSize } from '../../hooks/use-window-size'
import Confetti from 'react-confetti' import Confetti from 'react-confetti'
import { Donation } from '../../components/charity/feed-items' import { Donation } from '../../components/charity/feed-items'
import Image from 'next/image'
export const manaToUSD = (mana: number) => export const manaToUSD = (mana: number) =>
(mana / 100).toLocaleString('en-US', { style: 'currency', currency: 'USD' }) (mana / 100).toLocaleString('en-US', { style: 'currency', currency: 'USD' })
@ -42,6 +43,7 @@ function CharityPage(props: { charity: Charity }) {
const user = useUser() const user = useUser()
const txns = useCharityTxns(charity.id) const txns = useCharityTxns(charity.id)
const newToOld = _.sortBy(txns, (txn) => -txn.createdTime)
const totalRaised = _.sumBy(txns, (txn) => txn.amount) const totalRaised = _.sumBy(txns, (txn) => txn.amount)
const fromYou = _.sumBy( const fromYou = _.sumBy(
txns.filter((txn) => txn.fromId === user?.id), txns.filter((txn) => txn.fromId === user?.id),
@ -77,11 +79,9 @@ function CharityPage(props: { charity: Charity }) {
{/* TODO: donations over time chart */} {/* TODO: donations over time chart */}
<Row className="justify-between"> <Row className="justify-between">
{photo && ( {photo && (
<img <div className="relative w-40 rounded-2xl">
src={photo} <Image src={photo} alt="" layout="fill" objectFit="contain" />
alt="" </div>
className="w-40 rounded-2xl object-contain"
/>
)} )}
<Details <Details
charity={charity} charity={charity}
@ -92,7 +92,7 @@ function CharityPage(props: { charity: Charity }) {
</Row> </Row>
<h2 className="mt-7 mb-2 text-xl text-indigo-700">About</h2> <h2 className="mt-7 mb-2 text-xl text-indigo-700">About</h2>
<Blurb text={description} /> <Blurb text={description} />
{txns.map((txn) => ( {newToOld.map((txn) => (
<Donation key={txn.id} txn={txn} /> <Donation key={txn.id} txn={txn} />
))} ))}
</Col> </Col>
@ -215,8 +215,8 @@ function DonationBox(props: {
/> />
<Col className="mt-3 w-full gap-3"> <Col className="mt-3 w-full gap-3">
<Row className="items-center justify-between text-sm"> <Row className="items-center text-sm xl:justify-between">
<span className="text-gray-500">{charity.name} receives</span> <span className="mr-1 text-gray-500">{charity.name} receives</span>
<span>{manaToUSD(amount || 0)}</span> <span>{manaToUSD(amount || 0)}</span>
</Row> </Row>
{/* TODO: matching pool */} {/* TODO: matching pool */}

View File

@ -1,17 +1,40 @@
import _ from 'lodash' import _ from 'lodash'
import { useState, useMemo } from 'react' import { useState, useMemo } from 'react'
import { charities as charityList } from '../../../common/charity' import { charities, Charity as CharityType } from '../../../common/charity'
import { CharityCard } from '../../components/charity/charity-card' import { CharityCard } from '../../components/charity/charity-card'
import { Col } from '../../components/layout/col' import { Col } from '../../components/layout/col'
import { Spacer } from '../../components/layout/spacer'
import { Page } from '../../components/page' import { Page } from '../../components/page'
import { SiteLink } from '../../components/site-link'
import { Title } from '../../components/title' import { Title } from '../../components/title'
import { getAllCharityTxns } from '../../lib/firebase/txns'
const charities = charityList.map((charity) => ({ export async function getStaticProps() {
...charity, const txns = await getAllCharityTxns()
raised: 4001, const totals = _.mapValues(_.groupBy(txns, 'toId'), (txns) =>
})) _.sumBy(txns, (txn) => txn.amount)
)
const totalRaised = _.sum(Object.values(totals))
const sortedCharities = _.sortBy(charities, [
(charity) => (charity.tags?.includes('Featured') ? 0 : 1),
(charity) => -totals[charity.id],
])
return {
props: {
totalRaised,
charities: sortedCharities,
},
revalidate: 60,
}
}
export default function Charity(props: {
totalRaised: number
charities: CharityType[]
}) {
const { totalRaised, charities } = props
export default function Charity() {
const [query, setQuery] = useState('') const [query, setQuery] = useState('')
const debouncedQuery = _.debounce(setQuery, 50) const debouncedQuery = _.debounce(setQuery, 50)
@ -25,12 +48,15 @@ export default function Charity() {
return ( return (
<Page> <Page>
<Col className="w-full items-center rounded px-4 py-6 sm:px-8 xl:w-[125%]"> <Col className="w-full rounded px-4 py-6 sm:px-8 xl:w-[125%]">
<Col className="max-w-xl gap-2"> <Col className="max-w-xl gap-2">
<Title className="!mt-0" text="Manifold for Good" /> <Title className="!mt-0" text="Manifold for Good" />
<div className="mb-6 text-gray-500"> <div className="mb-6 text-gray-500">
Donate your winnings to charity! Through the month of May, every M$ Donate your winnings to charity! Through the month of May, every M$
100 you contribute turns into $1 USD sent to your chosen charity. 100 you contribute turns into $1 USD sent to your chosen charity.
<Spacer h={5} />
Together we've donated over ${Math.floor(totalRaised / 100)} USD so
far!
</div> </div>
<input <input
@ -60,8 +86,14 @@ export default function Charity() {
></iframe> ></iframe>
<div className="mt-10 text-gray-500"> <div className="mt-10 text-gray-500">
Don't see your favorite charity? Recommend that we add it by emailing Don't see your favorite charity? Recommend it{' '}
<span className="text-indigo-500"> give@manifold.markets</span>~ <SiteLink
href="https://manifold.markets/Sinclair/which-charities-should-manifold-add"
className="text-indigo-700"
>
here
</SiteLink>
!
<br /> <br />
<br /> <br />
<span className="italic"> <span className="italic">